#include #include #include #include #include // this example computes the maximum absolute difference // between the elements of two vectors template struct abs_diff { __host__ __device__ T operator()(const T& a, const T& b) { return fabsf(b - a); } }; int main() { thrust::device_vector d_a = {1.0, 2.0, 3.0, 4.0}; thrust::device_vector d_b = {2.0, 4.0, 3.0, 0.0}; // initial value of the reduction float init = 0; // binary operations cuda::maximum binary_op1{}; abs_diff binary_op2; float max_abs_diff = thrust::inner_product(d_a.begin(), d_a.end(), d_b.begin(), init, binary_op1, binary_op2); std::cout << "maximum absolute difference: " << max_abs_diff << '\n'; return 0; }