compute
1.0.0
boost.com upute是基于OpenCL的C ++的GPU/并行计算库。
核心库是OpenCL API上的薄C ++包装器,并提供对计算设备,上下文,命令队列和内存缓冲区的访问。
核心库的顶部是一个通用的,类似于STL的接口,可提供常见算法(例如transform() , accumulate() , sort() ),以及公共容器(例如vector<T> , flat_set<T> )。它还具有许多扩展名,包括并行计算算法(例如exclusive_scan() , scatter() , reduce() )和许多花式迭代器(eg transform_iterator<> , permutation_iterator<> , zip_iterator<> )。
完整的文档可在http://boostorg.github.io/compute/上找到。
以下示例显示了如何对GPU上的浮子向量进行分类:
# include < vector >
# include < algorithm >
# include < boost/compute.hpp >
namespace compute = boost::compute;
int main ()
{
// get the default compute device
compute::device gpu = compute::system::default_device ();
// create a compute context and command queue
compute::context ctx (gpu);
compute::command_queue queue (ctx, gpu);
// generate random numbers on the host
std::vector< float > host_vector ( 1000000 );
std::generate (host_vector. begin (), host_vector. end (), rand );
// create vector on the device
compute::vector< float > device_vector ( 1000000 , ctx);
// copy data to the device
compute::copy (
host_vector. begin (), host_vector. end (), device_vector. begin (), queue
);
// sort data on the device
compute::sort (
device_vector. begin (), device_vector. end (), queue
);
// copy data back to the host
compute::copy (
device_vector. begin (), device_vector. end (), host_vector. begin (), queue
);
return 0 ;
}boost.com upute是一个仅限标题库,因此不需要链接。上面的示例可以与:
g++ -I/path/to/compute/include sort.cpp -lOpenCL
可以在教程和示例目录中找到更多示例。
有关图书馆的问题(使用和开发)可以将其发布到邮件列表中。
可以通过问题跟踪器报告错误和功能请求。
还可以随意向我发送一封电子邮件,其中有任何问题,问题或反馈。
BOOST.com PUPUTE项目目前正在寻找对并行计算感兴趣的其他开发人员。
请发送电子邮件至Kyle Lutz([email protected]),以获取更多信息。