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]),以獲取更多信息。