Hard
An intra-warp shared-memory handoff across a divergent branch
This kernel relies on the old 'warp-synchronous programming' assumption, common in pre-Volta CUDA code, that all 32 threads of a warp are always implicitly lockstep, so no explicit synchronization is needed for one lane to see another lane's shared-memory write within the same warp. What happens when this kernel runs on a Volta-or-later GPU?
kernel.cu
__shared__ int buf[32];
__global__ void warpSyncAssumption() {
int lane = threadIdx.x % 32;
if (lane < 16) {
buf[lane] = compute(lane);
// old assumption: no __syncwarp() needed, "the warp is always in lockstep"
} else {
int v = buf[lane - 16]; // read what the "other half" of the warp wrote
use(v);
}
}30 of 46 in GPU / CUDA