Skip to content

Commit

Permalink
replace count_if with count
Browse files Browse the repository at this point in the history
  • Loading branch information
harrism committed Sep 4, 2019
1 parent c6608a1 commit 60999ce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cpp/src/trajectory/subset_trajectories.cu
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ struct subset_functor {
in_id_ptr, in_id_ptr + num_rec, hit_vec.begin());


uint32_t num_hit = thrust::count_if(exec_policy, hit_vec.begin(),
hit_vec.end(), is_true());
uint32_t num_hit = thrust::count(exec_policy, hit_vec.begin(),
hit_vec.end(), true);

RMM_TRY( RMM_ALLOC(&out_x.data, num_hit * sizeof(double), 0) );
RMM_TRY( RMM_ALLOC(&out_y.data, num_hit * sizeof(double), 0) );
Expand All @@ -94,9 +94,11 @@ struct subset_functor {
out_y_ptr,
out_id_ptr,
out_ts_ptr));

uint32_t num_keep = thrust::copy_if(exec_policy, in_itr, in_itr+num_rec,
hit_vec.begin(), out_itr,
is_true()) - out_itr;

CUDF_EXPECTS(num_hit == num_keep,
"count_if and copy_if result mismatch");

Expand Down

1 comment on commit 60999ce

@zhangjianting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More elegant for counting based on true/false!

Please sign in to comment.