Master the fundamental concepts of simd & vectorization through this focused micro-challenge.
AVX2 widens integer and floating SIMD to 256 bits (__m256i). One VADDPS fuses eight 32-bit floats, doubling theoretical throughput versus SSE on the same core (when ports support AVX).
cLoading…
Some Intel CPUs downclock when AVX-heavy code runs (AVX-512 more so). Measure end-to-end time, not just instruction count.
_mm256_load_ps-mavx2 -mfma as neededFor this exercise, you will port your SSE2 kernel to AVX2 and compare GB/s. This task asks you to handle remainder elements scalarly while keeping the hot loop on __m256 operations.
Keep the relevant datasheet, ISA manual, or architecture textbook chapter open while you implement. When your output disagrees with the reference trace on the same program, the bug is usually a mis-decoded opcode, a stale register read, or a flag bit left unchanged after arithmetic.
For this exercise, you will use those habits while implementing the requirement in the starter code. Microarchitectural product names change across CPU generations, but the control ideas (fetch, bypass, cache lines, vector lanes) stay stable enough to debug from first principles.
Upgrade SSE2 code to AVX2 for 256-bit vectors.
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