下面示例代码用来并行结算 100 个随机数的和:[code]#include
#include
#include
#include
#include
#include
#include
int main(void)
{
// generate random data serially
thrust::host_vector
std:generate(h_vec.begin(), h_vec.end(), rand);
// transfer to device and compute sum
thrust::device_vector
int x = thrust::reduce(d_vec.begin(), d_vec.end(), 0, thrust::plus
return 0;
}[/code]主页:http://thrust.github.com/
下载:http://cloud.github.com/downloads/thrust/thrust/thrust-1.6.0.zip
来自:开源中国社区

