Master the fundamental concepts of simd & vectorization through this focused micro-challenge.
Modern Clang and GCC scan loops for SIMD opportunities when -O3 -march=native and #pragma omp simd or __restrict__ prove independence. The compiler emits AVX2/NEON instructions you never wrote in source.
cLoading…
c might overlap a)For example, adding __restrict__ on pointers often unlocks vectorization identical to hand intrinsics.
For this exercise, you will toggle pragmas and compiler flags on the same kernel and dump assembly with objdump -d. This task asks you to document one loop the compiler vectorizes and one it refuses, with the reported reason from optimization remarks.
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.
Explore auto-vectorization by modern compilers.
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