- Notifications
You must be signed in to change notification settings - Fork340
A C++ GPU Computing Library for OpenCL
License
boostorg/compute
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Boost.Compute is a GPU/parallel-computing library for C++ based on OpenCL.
The core library is a thin C++ wrapper over the OpenCL API and providesaccess to compute devices, contexts, command queues and memory buffers.
On top of the core library is a generic, STL-like interface providing commonalgorithms (e.g.transform(),accumulate(),sort()) along with commoncontainers (e.g.vector<T>,flat_set<T>). It also features a number ofextensions including parallel-computing algorithms (e.g.exclusive_scan(),scatter(),reduce()) and a number of fancy iterators (e.g.transform_iterator<>,permutation_iterator<>,zip_iterator<>).
The full documentation is available athttp://boostorg.github.io/compute/.
The following example shows how to sort a vector of floats on the GPU:
#include<vector>#include<algorithm>#include<boost/compute.hpp>namespacecompute= boost::compute;intmain(){// get the default compute device compute::device gpu =compute::system::default_device();// create a compute context and command queue compute::contextctx(gpu); compute::command_queuequeue(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 devicecompute::copy( host_vector.begin(), host_vector.end(), device_vector.begin(), queue );// sort data on the devicecompute::sort( device_vector.begin(), device_vector.end(), queue );// copy data back to the hostcompute::copy( device_vector.begin(), device_vector.end(), host_vector.begin(), queue );return0;}
Boost.Compute is a header-only library, so no linking is required. The exampleabove can be compiled with:
g++ -I/path/to/compute/include sort.cpp -lOpenCL
More examples can be found in thetutorial and under theexamples directory.
Questions about the library (both usage and development) can be posted to themailing list.
Bugs and feature requests can be reported through theissue tracker.
Also feel free to send me an email with any problems, questions, or feedback.
The Boost.Compute project is currently looking for additional developers withinterest in parallel computing.
Please send an email to Kyle Lutz (kyle.r.lutz@gmail.com) for more information.
About
A C++ GPU Computing Library for OpenCL
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.