A single-header C++ library for simplifying the use of CUDA Runtime Compilation (NVRTC).
Integrating NVRTC into existing and/or templated CUDA code can be tricky. Jitify aims to simplify this process by hiding the complexities behind a simple, high-level interface.
const char* program_source = "my_programn"
"templaten"
"__global__n"
"void my_kernel(T* data) {n"
" T data0 = data[0];n"
" for( int i=0; in "
" data[0] *= data0;n"
" }n"
"}n";
static jitify::JitCache kernel_cache;
jitify::Program program = kernel_cache.program(program_source);
// ...set up data etc.
dim3 grid(1);
dim3 block(1);
using jitify::reflection::type_of;
program.kernel("my_kernel")
.instantiate(3, type_of(*data))
.configure(grid, block)
.launch(data);
Jitify provides/takes care of the following things:
Things you can do with Jitify and NVRTC:
Jitify is just a single header file:
#include <jitify.hpp>
Compile with: -pthread
(not needed if JITIFY_THREAD_SAFE is defined to 0)
Link with: -lcuda -lcudart -lnvrtc
A small utility called stringify is included for converting text files into C string literals, which provides a convenient way to integrate JIT-compiled sources into a build.
Tests can be run with the following command:
$ make test
This will automatically download and build the GoogleTest library, which requires CMake to be available on the system.
See jitify_example.cpp for some examples of how to use the library. The Makefile also demonstrates how to use the provided stringify utility.
GTC 2017 Talk by Ben Barsdell and Kate Clark
Doxygen documentation can be generated by running:
$ make doc
The HTML and LaTeX results are placed into the doc/ subdirectory.
BSD-3-Clause
Ben Barsdell (NVIDIA, bbarsdell at nvidia dot com)
Kate Clark (NVIDIA, mclark at nvidia dot com)