Master the fundamental concepts of gpu architecture through this focused micro-challenge.
SIMD (Single Instruction, Multiple Data) is a processor feature where one instruction operates on a vector of data simultaneously. SSE, AVX, and NEON are SIMD instruction sets. The programmer or compiler explicitly chooses vector width and uses blend/mask instructions to handle per-lane differences.
For example, an AVX-256 add operates on eight 32-bit floats in one instruction. The programmer controls which lanes are active.
SIMT (Single Instruction, Multiple Thread) is how NVIDIA GPUs execute. One instruction broadcasts to many execution units, but you write scalar thread code. Each thread has its own registers and can branch independently. The hardware masks off inactive threads.
Consider a warp of 32 threads where thread_id % 4 == 0 takes one path and the rest take another:
cLoading…
In pure SIMD, a skilled programmer might use blend instructions to handle both paths in one pass. In SIMT, divergence always serializes. AMD wavefronts of 64 threads follow the same rules.
You will simulate SIMT execution with boolean execution masks, show two-phase divergence for an if/else, and model early-exit loops where inactive threads stay masked until all threads finish. This task requires you to print masks per phase and calculate the divergence penalty. Understanding SIMT vs SIMD explains why GPU kernels punish data-dependent branches that CPU vector code can sometimes absorb.
Write a C program that simulates SIMT execution with divergence masks.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github