Re: multidimensional array order in memory
- From: Gary Scott <garylscott@xxxxxxxxxxxxx>
- Date: Sat, 07 Feb 2009 09:43:29 -0600
rusi_pathan wrote:
On Feb 7, 2:39 am, Glen Herrmannsfeldt <g...@xxxxxxxxxxxxxxxx> wrote:You would think :)
Terence wrote:
Given an array X(I,J,K), I was "brought uo" on the rule that arrays
are stored in column-major order; i.e. that the left-most index
changed most rapidly in passing memory-sequentially over the array in
memory.
And this implies it is slightly faster to access locations (fewer
computations) if a nest of three loops has the I loop K inside the J
loop, inside the K loop:-
In the old days it may have been slightly faster. With cache on
current machines it can make a very significant difference.
With virtual storage and large arrays it can make a
huge difference.
DO 3 K=1,maxk
DO 2 J=1,maxj
DO 1 I=1,maxi
...
1 CONTINUE
2 CONTINUE
3 CONTINUE
Is this aove definition more or less still the standard for modern
Fortran?
It is still that way.
Cant modern compilers figure that out automatically meaning I write
straightforward code (K inside J inside I) and the compilers change
the order minimizing cache miss?
--
Gary Scott
mailto:garylscott@sbcglobal dot net
Fortran Library: http://www.fortranlib.com
Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html
If you want to do the impossible, don't hire an expert because he knows it can't be done.
-- Henry Ford
.
- References:
- multidimensional array order in memory
- From: Terence
- Re: multidimensional array order in memory
- From: Glen Herrmannsfeldt
- Re: multidimensional array order in memory
- From: rusi_pathan
- multidimensional array order in memory
- Prev by Date: Re: Direct Access input of newline characters
- Next by Date: Re: multidimensional array order in memory
- Previous by thread: Re: multidimensional array order in memory
- Next by thread: Re: multidimensional array order in memory
- Index(es):
Relevant Pages
|