CS 179: GPU Computing: Lecture 2: More Basics
CS 179: GPU Computing: Lecture 2: More Basics
CS 179: GPU Computing: Lecture 2: More Basics
Computing
LECTURE 2: MORE BASICS
Recap
Can use GPU to solve highly parallelizable problems
Straightforward extension to C++
◦ Separate CUDA code into .cu and .cuh files and compile with nvcc to
create object files (.o files)
Looked at the a[] + b[] -> c[] example
Recap
If you forgot everything, just make sure you understand that CUDA is
simply an extension of other bits of code you write!!!!
◦ Evident in .cu/.cuh vs .cpp/.hpp distinction
◦ .cu/.cuh is compiled by nvcc to produce a .o file
◦ .cpp/.hpp is compiled by g++ and the .o file from the CUDA code is
simply linked in using a "#include xxx.cuh" call
◦ No different from how you link in .o files from normal C++ code
.cu/.cuh vs .cpp/.hpp
.cu/.cuh vs .cpp/.hpp
.cu/.cuh vs .cpp/.hpp
.cu/.cuh vs .cpp/.hpp
Thread Organization
We will now look at how threads are organized and used in GPUs
◦ Keywords you MUST know to code in CUDA:
◦ Thread
◦ Block
◦ Grid
◦ Keywords you MUST know to code WELL in CUDA:
◦ (Streaming) Multiprocessor
◦ Warp
◦ Warp Divergence
Inside a GPU