Two dimensional array access should be similar to:
array[(rowIndex * columnCount) + columnIndex]
But for example:
|
for(int i = 0; i < cols; i++) |
|
{ |
|
for(int j = 0; j < rows; j++) |
|
{ |
|
array[(i * cols) + j]++; |
|
} |
|
} |
which is
array[(columnIndex * columnCount) + rowIndex]
The results seem to be aligned with your course outline because one of them is using the outer loop index while other uses the inner loop. But that will need a fix when you have different column and row counts. It is useful to have different counts, if you want to keep the array size same and increase column size to see the effect of different levels of cache.
Two dimensional array access should be similar to:
array[(rowIndex * columnCount) + columnIndex]But for example:
DataOrientedDesign/DoDSamples/Samples/Benchmarks/RowsVsCols.cs
Lines 33 to 39 in 49c1a08
which is
array[(columnIndex * columnCount) + rowIndex]The results seem to be aligned with your course outline because one of them is using the outer loop index while other uses the inner loop. But that will need a fix when you have different column and row counts. It is useful to have different counts, if you want to keep the array size same and increase column size to see the effect of different levels of cache.