boost.computeは、openclに基づくC ++のGPU/並列コンピューティングライブラリです。
コアライブラリは、OPENCL API上の薄いC ++ラッパーであり、デバイス、コンテキスト、コマンドキュー、メモリバッファを計算することができます。
コアライブラリの上にはflat_set<T>一般的なアルゴリズム( transform() 、 accumulate() 、 sort() )を提供する一般的なSTLのようなインターフェイスvector<T>あります。また、パラレルコンピューティングアルゴリズム( exclusive_scan() 、 scatter() 、 reduce() )と多数のファンシーイテレーター( 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.computeはヘッダーのみのライブラリであるため、リンクは必要ありません。上記の例は、次の例をまとめることができます。
g++ -I/path/to/compute/include sort.cpp -lOpenCL
より多くの例は、チュートリアルとExamples Directoryの下にあります。
ライブラリに関する質問(使用と開発の両方)は、メーリングリストに投稿できます。
バグと機能のリクエストは、問題トラッカーを介して報告できます。
また、問題、質問、またはフィードバックを含むメールをお気軽に送ってください。
Boost.comPuteプロジェクトは現在、並行コンピューティングに関心のある追加の開発者を探しています。
詳細については、Kyle Lutz([email protected])にメールを送信してください。