Compilers
Which kind of instruction does a compiler's automatic vectorization use?
- AInstructions that raise interrupts
- BSIMD instructions handling multiple data at once
- CInstructions that erase the entire contents of the cache at once
Show answer and explanation
Answer: B. SIMD instructions handling multiple data at once
Automatic vectorization finds loops that perform the same computation on each array element and replaces them with SIMD instructions that process several elements at once. A 128-bit SIMD register can add four 32-bit numbers simultaneously, potentially cutting the loop's operation count to a quarter. Conditions include no dependences between iterations and contiguous data, and possible pointer overlap can cause the compiler to give up. Interrupt or cache-management instructions are unrelated.
- A. Interrupt-raising instructions are not used.
- B. Correct. SIMD instructions process multiple elements together.
- C. It has nothing to do with cache-clearing instructions.