Mettle

strided-accessThe loop steps more than one element at a time

Reported by --explain after a verdict.

mettle explain strided-access

rgb[i * 3 + 1], dst[i * 2], and any other non-unit stride. Every kernel walks its arrays one contiguous vector per iteration, so a strided access has no kernel to land in. There is no gather or scatter form.

The stride is usually the data layout, not an accident, so there is often nothing to change. When the layout IS free, splitting an interleaved array into one array per component makes every loop over it unit-stride:

// instead of rgb[i*3+0], rgb[i*3+1], rgb[i*3+2]
r[i], g[i], b[i]        // three loops, all vectorized

Related