Skip to main content

RMK014: The vectorization cost model states the loop is not a SIMD opportunity due to unpredictable memory accesses in the loop body

Issue

Loop is not a SIMD opportunity because of the unpredictable memory accesses in the loop body.

Actions

Use pwdirectives to vectorize the loop.

Alternatively, you can perform loop fission to isolate the unpredictable memory accesses to a separate loop.

Relevance

Memory access pattern is very important for good software performance. The loop contains unpredictable memory accesses (either because of dereferencing a pointer or because it accesses array elements indirectly). This type of memory access pattern is very inefficient from the memory subsystem perspective, and these loops are typically not good SIMD opportunities.

Occasionally, loops with unpredictable memory access pattern can benefit from vectorization: if the loop is computationally expensive, using loop fission to isolate the unpredictable accesses to a separate loop can help vectorize the remaining part of the loop. Alternatively, if the dataset the loop is processing is really small, the loop can benefit from explicit vectorization using compiler pragmas. Another idea: if the loop in question is a part of a loop nest, performing loop interchange or loop tiling can decrease the pressure on the memory subsystem as well.