This library is a header-only, stateless and lightweight wrapper for the CUDA driver and runtime libraries. It wraps the C and C++ CUDA functions calls in easy to use C++ STL like objects.
The library was originally created for the project HAL’s MD package but can be used as a standalone library.
Unfortunately, there is no documentation (contributions welcome), but there is an example code and pretty detailed unit tests so you may have a look at those.
- error handling using exceptions
- device managment
- allocator
- device and host vectors (with automatic allocation and iterators)
- copy functions (using the vector iterators)
- kernel configuration and launch
- streams
- events
- symbols
- textures using the texture object API
A minimal working example with CUDA code and C++ host code in different compilation units can be found at examples/minimal.
- CUDA ≥ 7.0 support
- C++11 compiler
- CMake ≥ 2.8.12
cuda-wrapper uses CMake, the headers are just installed into the directory specified to CMake:
$ cmake path/to/cuda-wrapper $ make $ make install
cuda-wrapper uses the Boost testing framework, if it is not found unit tests are disabled. To start testing, just run (after building):
$ ctest
We initially intended to completely switch to the driver library because it offers much finer control over the devices and contexts than the runtime. The problem with the driver API are functions and symbols: You need to load an already compiled ptx or cubin file at runtime and than reference a function or symbol with a string. This would be very unclean for a library so some functions still use the runtime.