没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
试读
42页
Thrust 1.2是个CUDA并行算法库,含有一个类似于C++标准模板库(STL)的界面。Thrust提供了一个灵活的高级GPU编程接口,可以极大地增强开放者的生产力,可以利用Thrust迅速开发高性能的应用程序。这是一个非常重要的第三方CUDA开发库。 Thrust is a CUDA library of parallel algorithms with an interface resembling the C++ Standard Template Library (STL). Thrust provides a flexible high-level interface for GPU programming that greatly enhances developer productivity. Develop high-performance applications rapidly with Thrust!
资源推荐
资源详情
资源评论
NVIDIA Research
Thrust
Jared Hoberock and Nathan Bell
© 2008 NVIDIA Corporation
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
int main(void)
{
// generate 16M random numbers on the host
thrust::host_vector<int> h_vec(1 << 24);
thrust::generate(h_vec.begin(), h_vec.end(), rand);
// transfer data to the device
thrust::device_vector<int> d_vec = h_vec;
// sort data on the device
thrust::sort(d_vec.begin(), d_vec.end());
// transfer data back to host
thrust::copy(d_vec.begin(), d_vec.end(), h_vec.begin());
return 0;
}
Diving In
© 2008 NVIDIA Corporation
Programmer productivity
Rapidly develop complex applications
Leverage parallel primitives
Encourage generic programming
Don’t reinvent the wheel
E.g. one reduction to rule them all
High performance
With minimal programmer effort
Interoperability
Integrates with CUDA C/C++ code
Objectives
3
© 2008 NVIDIA Corporation
What is Thrust?
C++ template library for CUDA
Mimics Standard Template Library (STL)
Containers
thrust::host_vector<T>
thrust::device_vector<T>
Algorithms
thrust::sort()
thrust::reduce()
thrust::inclusive_scan()
Etc.
4
© 2008 NVIDIA Corporation
Containers
Make common operations concise and readable
Hides cudaMalloc, cudaMemcpy and cudaFree
// allocate host vector with two elements
thrust::host_vector<int> h_vec(2);
// copy host vector to device
thrust::device_vector<int> d_vec = h_vec;
// manipulate device values from the host
d_vec[0] = 13;
d_vec[1] = 27;
std::cout << "sum: " << d_vec[0] + d_vec[1] << std::endl;
// vector memory automatically released w/ free() or cudaFree()
5
剩余41页未读,继续阅读
资源评论
- p3vsea20022012-11-15为数不多的翻译好的Thrust文档,翻译的还行
beyondht2003
- 粉丝: 2
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功