This is a repeat of the intro to CUDA article. Here we focus on code listing rather than explanations.
You already know basic C. You have advanced skills such as malloc(). You are interested to learn how to work withe big data including using CUDA.
We allocate big arrays, intialize them, and print them out:
File link: ./prog03/prog03.c
File link: ./prog04/prog04.cu
Notice the printArr() function returns without error but does not actually print anything to our console. Execution 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.