When we use thrust::reduce in the following example, the output is an int. Is this output (sum variable in code) located on the GPU or CPU RAM?
If it is in CPU RAM, how to access/retain the variable in the gpu? The reduce operation happens on the device(GPU) so at some point the output should be in the GPU.
#include <thrust/reduce.h>
#include <thrust/execution_policy.h>
#include <thrust/device_vector.h>
int main()
{
thrust::device_vector<int> D(6);
D[0]=0;
D[1]=1;
D[2]=2;
D[3]=3;
D[4]=4;
D[5]=5;
int sum = thrust::reduce(thrust::device,D.begin(), D.end(), (int) 0, thrust::plus<int>());
}