Master the fundamental concepts of simd & vectorization through this focused micro-challenge.
Before SIMD, establish how fast a plain C loop runs. Compiler unrolling, autovectorization, and profile-guided optimization can surprise you, so measure with optimization flags documented.
cLoading…
cpufreq performance governor)For example, multiplying two 1M-element float arrays might run at 200 MB/s scalar but jump an order of magnitude once vectorized.
For this exercise, you will benchmark element-wise multiply-add and record ns/element. This task asks you to save this scalar baseline because every SIMD task compares speedup against it.
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.
Benchmark scalar loop performance.
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