C8 Computer organization · Practice
SIMD and vector instructions
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
0 solved
0 in a row
0 of 7 kinds solid
Check
A fraction 0.8 of a program's time vectorizes perfectly onto 4 lanes. What's the overall speedup?
Check
A strip-mined vector loop processes 101 elements, at most 8 per iteration. How many iterations does it run?
Check
A loop moves 8 bytes of memory per element and does 8 floating-point operations per element. With 25 GB/s of memory bandwidth, what's the most it can compute, in billions of operations per second?
Check
a0 and a1 each hold four packed bytes. Put their lane-by-lane sums (each modulo 256) in a2, without letting carries cross between bytes.
RISC-V RV32IM (base integer plus multiply and divide). End your program with ebreak. Tab indents; press Esc and then Tab to move on.
Check
Write two SWAR functions for 32-bit words: add_bytes(a, b), lane-wise byte addition modulo 256 using the masking trick, and has_zero_byte(x) returning True if any byte of x is zero, using . Keep results in 32 bits. They'll be checked against byte-by-byte references on random words from random.Random(seed).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A fraction 0.75 vectorizes onto 2 lanes. What's the speedup?
Check
A vector loop with 8-element vectors processes 500 elements. How many does its last, partial iteration handle?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in C8