Bridging the Gap: Writing Portable C++ Programs for CPU and GPU
Talkat CppCon 2024 · on Monday, 2024-09-16· at 15:15· Cottonwood 8/9, 6700 North Gaylord Rockies Boulevard·
summary
Concrete patterns and tradeoffs for running the same C++ code on NVIDIA GPUs (CUDA) and CPUs, with compiler-tested examples: how nvcc vs clang differ, a quiz that shows nvcc producing a silent undefined-behavior instantiation, use of macros to fake __host__/__device__ for non‑CUDA builds, the pitfalls of Host device everything and Constexpr everything (experimental relaxed constexpr can silently change semantics), macro/micro solutions for Conditional Host Device Template, and a language proposal for conditional host/device annotations.
AI-written summary · about
chapters (10)
- 0:00Introduction and motivation
- 0:31CUDA crash course and quiz
- 5:54Analyzing bad cross-function calls
- 12:56Early patterns and workarounds
- 16:36Handling conditional logic
- 21:11Constexpr and experimental features
- 25:56Disabling CUDA compiler warnings
- 31:16Host-device template patterns
- 38:10Function dispatching
- 41:17Proposals and Q&A
related talks
36mCUDA Kernels with C++
59mUsing Template Magic to Automatically Generate Hybrid CPU/GPU-Code
37mC++ for multi-accelerator, multi-vendor systems
56m“Towards Heterogeneous Programming in C++"
01h 32mHeterogeneous Programming in C++ today
27mVendor-Neutral GPU Programming in Chapel
01h 17m📚 Advanced NCCL Tutorial: Beyond Collectives
52mC++ Standard Parallelism
