This post series is the Solutions of the Professional CUDA C Programming written by John Cheng, Max Grossman and Ty McKercher
Chapter 1: Heterogeneous Parallel Computing with CUDA
I solve the examples of Chapter 1. You can find solutions at bellow.
Hello from Cuda, first code of cuda
1 2 3 4 5 6 7 8 9 10 11 12 |
#include <stdio.h> __global__ void helloFromGPU (void){ printf("Hello from GPU\n"); } int main(void){ printf("Hello from CPU\n"); helloFromGPU <<<1,10>>>(); cudaDeviceReset(); return 0; } |
Compile with nvcc
1 |
nvcc -arch compute_72 hello.cu -o hello |
I use NVDIA Jetson Xavier so that my -arch is SM_72
Output is :
1 2 3 4 5 6 7 8 9 10 11 |
Hello from CPU Hello from GPU Hello from GPU Hello from GPU Hello from GPU Hello from GPU Hello from GPU Hello from GPU Hello from GPU Hello from GPU Hello from GPU |