Master the fundamental concepts of simd & vectorization through this focused micro-challenge.
SSE2 extends x86 registers to 128 bits (__m128i, __m128d). Intrinsics map directly to instructions like PADDQ and MULPD, giving deterministic vector code without inline assembly.
cLoading…
_mm_load_si128 requires 16-byte alignment_mm_loadu_si128 for heap buffersFor example, adding four 32-bit integers in one instruction uses one __m128i chunk instead of four scalar adds.
For this exercise, you will rewrite the scalar loop using SSE2 integer or double intrinsics. This task asks you to verify results bit-identical to scalar code before claiming speedup.
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.
Implement SIMD operations using SSE2 intrinsics.
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