Why thrust::count and thrust::count_if give diffenrent results for counting how many elements are zero in device vector?

I have a thrust device vector with 16.679.056 float elements in it. The result of int result_count_0 = thrust::count(d_result.begin(),d_result.end(), 0); is 14.786.283 But at the same time the following approach with thrust::count_if gives a different result (15.733.822) struct is_zero { __host__ __device__ bool operator()(int x) { return x == 0; } }; … is_zero iszero;… Read More Why thrust::count and thrust::count_if give diffenrent results for counting how many elements are zero in device vector?

A thrust problem: How can I copy a host_vector to device_vector with a customized permutation order?

I have an array in host, and I want to transfer it to device with a different order. I have tried this toy code complied with nvc++ test.cpp -stdpar $ cat test.cpp #include <iostream> #include <thrust/iterator/permutation_iterator.h> #include <thrust/copy.h> #include <thrust/sequence.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <array> using Real = float; int main(int argc, char* argv[])… Read More A thrust problem: How can I copy a host_vector to device_vector with a customized permutation order?