微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Thrust C++并行应用开发包

程序名称:Thrust

授权协议: Apache

操作系统: 跨平台

开发语言: C/C++

Thrust 介绍

Thrust 是一个开源的 C 库用于开发高性能并行应用程序,以 C 标准模板库为蓝本实现,Thrust 带来一系列并行计算领域的抽象层。

下面示例代码用来并行结算 100 个随机数的和:

#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/reduce.h>
#include <thrust/functional.h>
#include <algorithm>
#include <cstdlib>

int main(void)
{
  // generate random data serially
  thrust::host_vector<int> h_vec(100);
  std:generate(h_vec.begin(), h_vec.end(), rand);

  // transfer to device and compute sum
  thrust::device_vector<int> d_vec = h_vec;
  int x = thrust::reduce(d_vec.begin(), d_vec.end(), 0, thrust::plus<int>());
  return 0;
}

Thrust 官网

http://thrust.github.com/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐