Beginner CUDA questions Tips on writing programs


I’m new to the CUDA community, but I have a pretty good understanding of C programming. If I’m writing a program that is supposed to do a series of calculations and there is a particularly complex one that I want the GPU to do, how would I go about doing that? (Just some pseudocode or a pseudo example would be great) Is there a general “template” for passing arguments to the GPU?

Heh, pretty general questions, so a pretty general answer: read the first half or so of NVIDIA_CUDA_Programming_Guide_2.2.pdf or so, located in /usr/local/cuda/doc after you install the toolkit.

The GPU, qua CUDA, is in no way a black box, it is well documented in the toolkit docs. You have to program it in CUDA-dialect C, there is a mechanism for invoking your compiled GPU code from eg main in your CPU code.

In a nutshell: in CPU side of code copy data for the CUDA kernel to from PC RAM to video card memory, invoke your kernel from the CPU, kernel calculates and stores results in video card memory, kernel finishes, CPU side code copies results back to PC RAM.

But really the details are where all the fun is. You gotta read the docs that come with the toolkit.