ParallelismBeginner~30 min

Hello CUDA

Write your first GPU kernel and understand the CUDA execution model: thread indexing, kernel launch syntax, and GPU/CPU synchronization.

kernelthreadIdxblockIdxblockDimcudaDeviceSynchronize

// TUTORIAL

GPU execution
1 / 4

Step 1 — Your first kernel

A __global__ function is a CUDA kernel — code that runs on the GPU, not the CPU.

Launch it with <<<blocks, threads>>>:
- <<<1, 1>>> = 1 block, 1 thread
- The kernel runs asynchronously, so call cudaDeviceSynchronize() before exiting.

Task: Add a printf("Hello from the GPU!\n") call inside helloKernel.
printf works inside GPU kernels (CUDA 2.0+).
main.cu
loading editor…

// expected output

Hello from the GPU!

// YOUR PROGRESS

Log in to save progress

// DETAILS

Category
Parallelism
Difficulty
Beginner
Est. time
~30 min
Prerequisites
None

// LEARN THE THEORY

Parallelism concepts