On Sat, 16 Jun 2001, Maurice Lombardi wrote:
I have only the following experience with large arrays on gpc/djgpp (DOS): There is a 50% - 100% variation in execution times due to memory cache considerations (this cache is presumably the "level 2" 256 or 512 kB cache of the Pentiums). Matrices are stored in pascal row-wise (same for C but the opposite is true for fortran). If you access elements row after row you minimize cache breaks. In a
So how have you stored and accessed your NxM elements ?
The maximal size of my array is 2000x2000. Let's say I have:
X:array[1..N,1..M] od real;
I access it as:
for i:= 1 to N do for j:= 1 to M do bla-bla-bla.. x[i,j];
That's what you call row-wise acces or just the opposite?
miklos
Miklos Cserzo wrote:
On Sat, 16 Jun 2001, Maurice Lombardi wrote:
I have only the following experience with large arrays on gpc/djgpp (DOS): There is a 50% - 100% variation in execution times due to memory cache considerations (this cache is presumably the "level 2" 256 or 512 kB cache of the Pentiums). Matrices are stored in pascal row-wise (same for C but the opposite is true for fortran). If you access elements row after row you minimize cache breaks. In a
So how have you stored and accessed your NxM elements ?
The maximal size of my array is 2000x2000. Let's say I have:
X:array[1..N,1..M] od real;
I access it as:
for i:= 1 to N do for j:= 1 to M do bla-bla-bla.. x[i,j];
That's what you call row-wise acces or just the opposite?
Yes. You fix the row number and then increase the column number. I suppose that it is for this "natural" way of writing that matrices are stored row-wise in Pascal, but I do not know. So you have an other problem. Can you give a code snippet to see if it is present on other computers/ systems/ gpc versions.
Maurice.
On Sat, 16 Jun 2001, Maurice Lombardi wrote:
The maximal size of my array is 2000x2000. Let's say I have:
X:array[1..N,1..M] od real;
I access it as:
for i:= 1 to N do for j:= 1 to M do bla-bla-bla.. x[i,j];
That's what you call row-wise acces or just the opposite?
Yes. You fix the row number and then increase the column number. I suppose that it is for this "natural" way of writing that matrices are stored row-wise in Pascal, but I do not know. So you have an other problem. Can you give a code snippet to see if it is present on other computers/ systems/ gpc versions.
The code is too complex and requires special input files too. Right now I can not produce a reasonable skeleton demonstrating the problem. I may be able to come up with a test version a few days later. However, meantime I realized that it still could be a cash-related effect. A more detailed section of the code:
X:array[1..N,1..M] of real; A:array[1..N] of real; B:array[1..M] of real;
for i:= 1 to N do for j:= 1 to M do begin A[i]:= A[i] + X[i,j]; B[j]:= B[j] + X[i,j]; end;
So I am accessing other vectors in the same cycle, they are also big and they can exceed the cash size together. Other applications are also running on the host.
miklos
On Sat, 16 Jun 2001, Miklos Cserzo wrote:
The maximal size of my array is 2000x2000.
X:array[1..N,1..M] of real; A:array[1..N] of real; B:array[1..M] of real;
for i:= 1 to N do for j:= 1 to M do begin A[i]:= A[i] + X[i,j]; B[j]:= B[j] + X[i,j]; end;
Taking evaluating a subscript out of the inner loop might be a tad faster:
for i:= 1 to N do begin temp := 0; { or temp := A[i] if A[i] preloaded with non zero} for j := 1 to M do begin temp := temp + X[i,j]; B[j] := B[j] + X[i,j]; end; A[i] := temp; end;
Russ