Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Which loop is faster?

Name: Anonymous 2012-01-16 8:59


for (I = 0; I < N; I++)
  for (J = 0; J < M; J++)
    update(Xs[I][J]);

or

for (I = 0; I < N; I++)
  for (J = 0; J < M; J++)
    update(Xs[J][I]);

???

Name: Anonymous 2012-01-16 10:56

Thats which uses sequential access in linear order will be cached. That which does not and skip rows will suffer unpredictable uncached access times(since some will be cached) but if the data is small enough it would not be felt since its cached entirely at start.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List