Skip to content

andrewrichards/SyclParallelSTL

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SYCL Parallel STL

This project features an implementation of the Parallel STL library using the Khronos SYCL standard.

What is Parallel STL

Parallel STL is an implementation of the Technical Specification for C++ Extensions for Parallelism, current document number N4507. This technical specification describes a set of requirements for implementations of an interface that computer programs written in C++ programming language may use to invoke algorithms with parallel execution. In practice, this specification aimed at the next C++ standard, offers the opportunity to users to specify execution policies to traditional STL algorithms, which will enable the execution of those algorithms in parallel. The various policies can specify different kinds of parallel execution. For example,

std::vector<int> v = ...
// Traditional sequential sort
std::sort(vec.begin(), vec.end());
// Explicit sequential sort
std::sort(seq, vec.begin(), vec.end());
// Explicit parallel sort
std::sort(par, vec.begin(), vec.end());

What is SYCL

SYCL is a royalty-free, cross-platform C++ abstraction layer that builds on top of OpenCL. SYCL enables single-source development of OpenCL applications in C++ whilst enabling traditional host compilers to produce standard C++ code.

The SyclSTL

SyclSTL exposes a SYCL policy on the experimental::parallel namespace that can be passed to standard STL algorithms for them to run on SYCL. Currently, the following STL algorithms are implemented:

  • sort : Bitonic sort for ranges which size is power of two, sequential sort otherwise.
  • transform : Parallel iteration (one thread per element) on the device.
  • for_each : Parallel iteration (one thread per element) on the device.

Some optimizations are implemented, for example, the ability of passing iterators to buffers rather than STL containers to reduce the amount of information copied in and out, and the ability of specifying a queue to the SYCL policy so that queue is used for the various kernels (potentially enabling asynchronous execution of the calls).

Building the project

The project uses CMake in order to produce build files. Simply create a build directory and run CMake as follows:

$ mkdir build
$ cd build
$ cmake ../ -DSYCL_PATH=/path/to/sycl \
            -DOPENCL_ROOT_DIR=/path/to/opencl/dir
$ make

Usual CMake options are available (e.g. building debug or release).

If Google Mock is found in external/gmock, a set of unit tests is built. Unit tests can be run by running Ctest in the binary directory.

Building the documentation

Source code is documented using Doxygen. To build the documentation as an HTML file, navigate to the doc directory and run doxygen from there.

$ cd doc
$ doxygen

This will generate the html pages inside the doc_output directory.

Limitations

The Lambda functions that you can pass to the algorithms have the same restrictions as any SYCL kernel.

While using lambda functions, the compiler needs to find a name for that lambda function. To provide a lambda name, the user do the following:

cl::sycl::queue q;S
sycl::sycl_execution_policy<class SortAlgorithm3> snp(q);
sort(snp, v.begin(), v.end(), [=](int a, int b) { return a >= b; });

About

Open Source Parallel STL implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 95.4%
  • CMake 4.6%