Forum Discussion
Altera_Forum
Honored Contributor
11 years ago --- Quote Start --- What Mike is saying about the banking and column-wise relationship is true. However, if you are just iterating over the entire array by accessing consecutive elements, my money would be on the row-by-row access pattern. If you iterate over the entire row elements and unroll this loop, the compiler will merge the consecutive accesses into very efficient wider accesses. --- Quote End --- Ok, I should point out that for this to work, unrolling the column loop is key; this creates consecutive accesses that compiler can merge. e.g. for(row = 0; row < N; row++) { # pragma unroll for(col = 0; col < 4; col++) { A[row][col] = row + col; } } This essentially creates: for(row = 0; row < N; row++) { A[row][0] = row; A[row][1] = row + 1; A[row][2] = row + 2; A[row][3] = row + 3; } which gets translated to smth like this for(row = 0; row < N; row++) { A[row][0] = (int4)( row, row+1, row+2, row+3 ); // very efficient wide access } I think this is mentioned in the best practices guide document.