8.4 GPU Architecture and Programming
8.4 GPU Architecture and Programming
Programming
System with simple CPU and Video Cards
System with GPU
Multicore CPU vs GPU
CUDA Applications
on GPU
Example 1 : Hello World from GPU (1x10)
$ ./hello
#include <stdio.h>
Hello World from CPU!
__global__ void helloFromGPU (void) Hello World from GPU!
{ Hello World from GPU!
Hello World from GPU!
printf(“Hello World from GPU!\n”); Hello World from GPU!
} Hello World from GPU!
int main(void) Hello World from GPU!
Hello World from GPU!
{ Hello World from GPU!
// hello from cpu Hello World from GPU!
printf(“Hello World from CPU!\n”); Hello World from GPU!
helloFromGPU <<<1, 10>>>();
cudaDeviceReset();
return 0;
}
Memory Management Functions
Data Transfer between CPU and GPU
Example 2 : Data Transfer CPU GPU
CUDA Threads (SIMT)
Thread Hierarchy
• https://developer.nvidia.com/cuda-gpus
• https://docs.nvidia.com/cuda/cuda-c-programming-guide/
index.html#features-and-technical-specifications
Reference
• Book : CUDA C/C++ Programming Guide
https://docs.nvidia.com/cuda/cuda-c-programming-guide
• Book : PROFESSIONAL CUDA® C Programming – 2014
https://www.cs.utexas.edu/~rossbach/cs380p/papers/cuda-programming.pdf