Ch35 Discussion

Discussion Guide

Warm-up (think–pair–share, 5 min). "You move your slow simulation to a GPU and it gets slower. Before we explain how, guess: what part of the program could possibly be the culprit if the GPU cores themselves are faster?" Surfaces the host–device transfer as the hidden cost and primes §35.4.

Main discussion (15–20 min). 1. The doorway. Use the two-kitchens image. Ask: "When is sending work to the thousand line cooks across the street a win, and when is it a disaster?" Draw out that the number of trips through the door — not the speed of the cooks — decides. Map it onto !$acc data vs per-step copy. 2. One clause vs one kernel. Put the OpenACC SAXPY and the CUDA Fortran SAXPY side by side. "Same answer. When is the extra 30 lines of the CUDA version worth it?" Guide toward: rarely for most science; OpenACC first, CUDA for control you can prove you need (Case Study 2's reduction is the sharpest example — the directive is not just easier but better). 3. Whose fault is the slowdown? Give Case Study 1's setup (10×-faster kernel, net slowdown). Have half the room argue "the kernel is too slow" and half "the kernel is fine." Reveal the transfer audit: the kernel was never the problem. Cements "optimize the data movement, not the arithmetic."

Group activity (10 min). In pairs, students take a memory-bound kernel of their choice (a stencil, a normalize, a daxpy inside a time loop) and write, in directives only, the correct resident-data offload: !$acc data` placement, `present` on the per-step kernel, and where an `!$acc update self would go for periodic output. Then estimate — bytes ÷ bandwidth × crossings vs compute — whether it beats the CPU. Collect two or three; score by the transfer count, not the kernel.

Exit ticket. "A solver is 98% offloadable stencil. (a) You make it 25× faster on the GPU but a per-step transfer adds cost equal to the compute each step — is it faster or slower than the CPU, and why? (b) You instead keep the field resident — now what's the bottleneck? (c) Name the OpenACC directive that made the difference." (Answers: (a) transfer-bound, likely slower — per-step transfer swamps a memory-bound kernel; (b) the remaining serial fraction / one-time transfer — Amdahl; (c) !$acc data region around the time loop.)