advanced

Fast at 1023 Columns, Slow at 1024

Read the counters before the options. Nothing here is labelled with the answer.

The report

Our image convolution has a column-summing pass. It runs fine on most images. On one specific size it takes about six times longer, and the sizes either side of it are fine. Someone suggested it is a coincidence in our test data, but it reproduces every time on exactly that width.

The column pass — stride equals the row width
// matrix is row-major, width columns per row
for col in 0 .. width-1:
    sum = 0
    for row in 0 .. height-1:
        sum += matrix[row * width + col]   // stride = width elements
    out[col] = sum
CountersSIMULATED
instructionsidentical at width 1023 and 1024The same work is performed at both widths, to within noise.
cycles6.1× higher at width 1024One specific width takes six times as many cycles for identical work.
L1-dcache-load-misses3.1% at 1023, 97.4% at 1024Nearly every load misses at the problem width; almost none do next to it.
LLC-load-misses2.9% at 1023, 3.2% at 1024The amount of data reaching main memory is essentially unchanged.
dTLB-load-misses0.6% at both widthsAddress translation is not a differentiator here.
What is the hardware doing?