Master the fundamental concepts of compiler optimization techniques through this focused micro-challenge.
Auto-vectorization needs provably independent iterations, aligned pointers, and no function calls in the inner loop. #pragma GCC ivdep, clang loop vectorize(enable), and OpenMP simd directives remove assumed dependencies the compiler cannot prove.
Simple counting loop, no backward dependencies, stride-one access on arrays.
cLoading…
-fopt-info-vec prints why vectorization failed__attribute__((aligned(32))) helps AVX loadsrestrict plus ivdep often unlocks SIMD togetherobjdump -d -MintelKeep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will add pragma or attribute hints to vectorize a loop and verify SIMD instructions in assembly. This exercise asks you to report speedup and name the SIMD width used.
Document one invariant you will assert in tests and how you would detect its violation from observable symptoms.
Remove vectorization barriers and enable SIMD.
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