This is a header-only library for enabling single source code (C++) to target heterogeneous platforms (CPU, GPU). The project is still in early R&D phase.
- (CPU) OpenMP
- (GPU) CUDA
- (GPU) OpenMP target - experimental
Common dependencies for all the backends:
LLVM/clang is currently the only compiler that can build all the vecpar backends. Recommended setup on a system with NVIDIA GPU:
spack install [email protected] +all_targets +cuda cuda_arch=<XY>
spack install vecmem +cuda cuda_arch=<XY>
spack install googletest
vecpar uses nestoroprysk/FunctionComposition for supporting the algorithm chaining functionality.
Any C/C++ compiler (with OpenMP support) can build the CPU OpenMP backend.
For the CUDA backend, clang
or nvcc
can be used to compile the code. Additionally, the CUDA libraries must be accessible at compile and runtime.
To compile the GPU OpenMP backend, gcc
/clang
need a specific build configuration when targeting different GPU:
- NVIDIA - this can be easily achieved by installing
gcc
orllvm
with flags+nvptx
and+cuda
respectively from spack. - AMD - the configuration steps need to be done manually as show in the online documentation. For AMD GPU, AOMP compiler can be used as an alternative.
Also, the GPU driver and the associated libraries (CUDA or ROCm) need to be accessible at compile and runtime.
Get the code
git clone --recurse-submodules https://github.com/wr-hamburg/vecpar.git
To build the code
cmake -S <source_dir> -B <build_directory>
cmake --build <build_directory> \
-DVECPAR_BUILD_OMP_BACKEND=On \
-DVECPAR_BUILD_CUDA_BACKEND=On
To enable the automated tests, set also -DVECPAR_BUILD_TESTS=On
.
By default, all build options are enabled.
To compile for aarch64, set CC/CXX environment variables to appropriate aarch64 compilers.
To install the library
cmake --install <build_directory>
To use vecpar from a different project, add the following import line into the root cmake
file:
find_package( vecpar REQUIRED 0.0.3)