581
社区成员
发帖
与我相关
我的任务
分享
#include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#include <thrust/scan.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
int main()
{
thrust::host_vector<int> H(10, 0);
thrust::device_vector<int> D(10, 1);
thrust::inclusive_scan(D.begin(), D.end(), D.begin()); // in-place scan
thrust::copy(D.begin(), D.end(), H.begin());
for (int i = 0; i < 10; i++)
{
printf("%d, ", H[i]);
}
return 0;
//output: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
}