j
jaipkg.dev
packages / binding / CUDA.jai

CUDA.jai

4faa4d0binding

Jai bindings for the CUDA 12.9 Driver API

No license · updated 12 months ago

CUDA 12.9 Driver Api Jai bindings

Use at your own risk.

Tested with Jai 0.2.012

Copy the CUDA Toolkit into the same directory as generate.jai, matching up the path with the definitions in that file.

Usually I'll have a routine like the following in my metaprogram that rebuilds the kernel code alongside the jai host program.

compile_kernels :: ()
{
	files := file_list("./src");

	cuda_kernel_files: [..] string;
	for files
	{
		if ends_with(it, ".cu") array_add(*cuda_kernel_files, it);
	}

	nvcc_options :: string.[
		"--gpu-architecture=sm_89", 
		"--cubin",
		"-Wno-deprecated-gpu-targets", 
		"-g", 
		"-lineinfo",
	];

	debug_options :: string.[
		"--optimize", 
		"0", 
		"--keep-device-functions"
	];
	
	{
		command: [..] string;
		array_add(*command, "nvcc");
		array_add(*command, ..nvcc_options);
		array_add(*command, ..cuda_kernel_files);
		array_add(*command, "-o", "out/cuda_output.cubin");

		run_command(..command, print_captured_output=true);	
	}
}