boost.compute는 OpenCL을 기반으로 C ++를위한 GPU/병렬 컴퓨팅 라이브러리입니다.
핵심 라이브러리는 OpenCL API의 얇은 C ++ 래퍼이며 컴퓨팅 장치, 컨텍스트, 명령 대기열 및 메모리 버퍼에 대한 액세스를 제공합니다.
핵심 라이브러리 위에는 일반적인 컨테이너 (예 : vector<T> , flat_set<T> )와 공통 알고리즘 (예 : transform() , accumulate() , sort() )를 제공하는 일반적인 STL 유사 인터페이스가 있습니다. 또한 병렬 컴퓨팅 알고리즘 (예 : 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
더 많은 예제는 튜토리얼 및 예제 디렉토리 아래에서 찾을 수 있습니다.
도서관 (사용 및 개발)에 대한 질문은 메일 링리스트에 게시 할 수 있습니다.
문제 추적기를 통해 버그 및 기능 요청을보고 할 수 있습니다.
또한 문제, 질문 또는 피드백이 포함 된 이메일을 보내 주시기 바랍니다.
boost.compute 프로젝트는 현재 병렬 컴퓨팅에 관심이있는 추가 개발자를 찾고 있습니다.
자세한 내용은 Kyle Lutz ([email protected])에게 이메일을 보내주십시오.