yacx-YetAnotherCudaExecutor  0.6.2
wrapper to easily compile and execute cuda kernels
docs/kernel_launch.cpp
#include "yacx/main.hpp"
Source source{
"extern \"C\" __global__\n"
"void saxpy(float a, float *x, float *y, float *out, size_t n) {\n"
" size_t tid = blockIdx.x * blockDim.x + threadIdx.x;\n"
" if (tid < n) {\n"
" out[tid] = a * x[tid] + y[tid];\n"
" }\n"
"}"};
std::vector<KernelArg> args;
args.emplace_back(KernelArg{&a});
args.emplace_back(KernelArg{hX.data(), bufferSize});
args.emplace_back(KernelArg{hY.data(), bufferSize});
args.emplace_back(KernelArg{hOut.data(), bufferSize, true, false});
args.emplace_back(KernelArg{&N});
dim3 grid(NUM_BLOCKS);
dim3 block(NUM_THREADS);
Program program = source.program("saxpy");
Kernel kernel = program.compile();
kernel.configure(grid, block);
kernel.launch(args);
// Alternatively method chaining
source.program("saxpy")
.compile()
.configure(grid, block)
.launch(args);
main.hpp
C++ bindings to easily compile and execute CUDA kernels.
yacx::Device
Definition: Devices.hpp:13
yacx::KernelArg
Definition: KernelArgs.hpp:81
yacx::Kernel
Class to help launch and configure a CUDA kernel.
Definition: Kernel.hpp:31
yacx::Source
Class to wrap kernel strings.
Definition: Source.hpp:19