Skip to content

Commit

Permalink
Do not pass a second output iterator in copy_if
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Apr 17, 2024
1 parent dd141c2 commit efc14e7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions thrust/thrust/system/cuda/detail/copy_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ struct DispatchCopyIf
size_t& temp_storage_bytes,
InputIt first,
StencilIt stencil,
OutputIt output,
OutputIt& output,
Predicate predicate,
OffsetT num_items,
OutputIt& output_end)
OffsetT num_items)
{
using num_selected_out_it_t = OffsetT*;
using equality_op_t = cub::NullType;
Expand Down Expand Up @@ -147,7 +146,7 @@ struct DispatchCopyIf
// Return for empty problems
if (num_items == 0)
{
output_end = output;
output;
return status;
}

Expand Down Expand Up @@ -181,7 +180,7 @@ struct DispatchCopyIf
CUDA_CUB_RET_IF_FAIL(status);
OffsetT num_selected = get_value(policy, d_num_selected_out);

output_end = output + num_selected;
output += num_selected;
return status;
}
};
Expand All @@ -197,8 +196,7 @@ THRUST_RUNTIME_FUNCTION OutputIt copy_if(
{
using size_type = typename iterator_traits<InputIt>::difference_type;

size_type num_items = static_cast<size_type>(thrust::distance(first, last));
OutputIt output_end{};
size_type num_items = static_cast<size_type>(thrust::distance(first, last));
cudaError_t status = cudaSuccess;
size_t temp_storage_bytes = 0;

Expand All @@ -214,7 +212,7 @@ THRUST_RUNTIME_FUNCTION OutputIt copy_if(
dispatch32_t::dispatch,
dispatch64_t::dispatch,
num_items,
(policy, nullptr, temp_storage_bytes, first, stencil, output, predicate, num_items_fixed, output_end));
(policy, nullptr, temp_storage_bytes, first, stencil, output, predicate, num_items_fixed));
cuda_cub::throw_on_error(status, "copy_if failed on 1st step");

// Allocate temporary storage.
Expand All @@ -227,10 +225,10 @@ THRUST_RUNTIME_FUNCTION OutputIt copy_if(
dispatch32_t::dispatch,
dispatch64_t::dispatch,
num_items,
(policy, temp_storage, temp_storage_bytes, first, stencil, output, predicate, num_items_fixed, output_end));
(policy, temp_storage, temp_storage_bytes, first, stencil, output, predicate, num_items_fixed));
cuda_cub::throw_on_error(status, "copy_if failed on 2nd step");

return output_end;
return output;
}

} // namespace detail
Expand Down

0 comments on commit efc14e7

Please sign in to comment.