Vectorizing Computational Fluid Dynamics (CFD) Code in C++ Using std::simd
summary
Vectorizes a real CFD code with std::simd plus a small complementary library that makes loads/stores look like scalar code (implemented as a macro). Changes touch about 200 lines in the hot paths and add ~220 lines for reflection and helpers. Results are mixed: naive AVX2 vectorization sometimes slows down (division and masked lanes cost more), but explicit unrolling recovers roughly a 2× speedup in the sweet spot. Library is a working proof of concept.
AI-written summary · about
chapters (17)
- 0:00Introduction to CFD coding
- 1:03Project goals and challenges
- 2:35CFD code context and CODA
- 4:43Scientific code vectorization
- 6:37Loop rearrangement strategies
- 9:39SIMD loop body transformation
- 11:53Index type deduction method
- 14:32The simd_access library
- 16:55SIMD_ACCESS library features
- 23:01Extended feature: reflections
- 27:26Extended feature: universal SIMD
- 31:49Handling conditions and masks
- 36:46Future extensions and gather
- 40:34C++ language improvement ideas
- 45:15Software engineering results
- 47:55Performance results and tuning
- 52:15Lessons learned and conclusion
related talks
01h 06mSIMD in C++20: eve of a new era
01h 06mUtilize your CPU power
01h 08mAn implementer's view of Boost.SIMD
11mChoosing the correct vectorization method
52mAdvanced SIMD Algorithms in Pictures
42mFaster programs with your compilers autovectorization feature
31mGPU Performance Portability Using Standard C++ with SYCL
37mC++ for multi-accelerator, multi-vendor systems
