Memory for Nvidia Cuda

Surpassing the CPU's memory allocation limit

Description

This is a repeat of the intro to CUDA article. Here we focus on C code listing rather than explanations. We also carry on from our malloc-intro tutorial where we tested for the maximum memory allocatable. We also calculate the execution times between operations without commenting on them.

Audience

You already know basic C. You are interested in Cuda.

C - Big data add

We allocate big arrays, intialize them, and print them out:

File link: ./prog03/prog03.c

CUDA - Big data add

File link: ./prog04/prog04.cu

Extra note

Notice the printArr() function returns without error. You can call printf() from within a gpu kernel. But it did not actually print anything to our console for some reason. I am not sure why. Execution of printArr() on the cpu resulted in a segmentation fault.

The documentation mentions that you can call printf() from gpu functions/kernels. We will try to execute printf() from the gpu again in the future.