[Beowulf] g77 limits...

Toon Moene toon at moene.indiv.nluug.nl
Thu Feb 23 14:40:21 EST 2006


Robert G. Brown wrote:

> What are the current limits on the size of arrays that can be allocated
> in g77?  I know that this is almost a FAQ, but I cannot look back at the
> archives because it is so time dependent an answer.  In particular, can
> an x64 box with a modern linux kernel and a modern g77 allocate 4-8 GB
> arrays (presuming, of course, that one uses a long int for an index)?  I
> have seen references to "using an offset" in a few google hits (that
> were not very informative) -- does that basically mean doing pointer
> arithmetic in fortran?

> (I know Toone works on this and am hoping he's paying attention so I can
> get a really authoritative and informative answer...:-)

Well (thanks), I did work on removing a rather silly limit whereby no 
array could be larger than 2^32 *bits* in g77 (due to the backend 
expressing every size in bits).

I was able to show that - due to the fact that the minimum *unit* in 
Fortran indexing was a byte - that the real limit was 2^32 *bytes* (by 
showing that constant folding in the compiler's backend would always 
remove the bit size "limitation").

However, I never have been able to try out the limits of using a > 2 
Gbyte array - while doing the indexing with INTEGER*8 - because my 64 
bit machines are simply to small.

The following code works on my 0.5 Gbyte RAM / 1.5 Gbyte SWAP Athlon 64 
laptop with gfortran (the new Fortran 95 GNU Fortran), albeit horribly 
slowly:

       INTEGER*8 I, NSIZE
       PARAMETER (NSIZE = 100 000 000_8)
       DIMENSION A(3*NSIZE), A1(NSIZE), A2(NSIZE), A3(NSIZE)
       EQUIVALENCE (A(        1), A1(1))
       EQUIVALENCE (A(  NSIZE+1), A2(1))
       EQUIVALENCE (A(2*NSIZE+1), A3(1))
       DO I = 1, NSIZE
          A1(I) = 0.0
          A2(I) = 0.0
          A3(I) = 0.0
       ENDDO
       DO I = 1, 3*NSIZE
          A(I) = I
       ENDDO
       DO I = 1, NSIZE
          IF (A1(I) .NE. A(        I)) CALL ABORT
          IF (A2(I) .NE. A(  NSIZE+I)) CALL ABORT
          IF (A3(I) .NE. A(2*NSIZE+I)) CALL ABORT
       ENDDO
       DO I = 1, NSIZE
          A1(I) = 0.0
          A2(I) = 0.0
          A3(I) = 0.0
       ENDDO
       CALL SUB(A, 3*NSIZE)
       DO I = 1, NSIZE
          IF (A1(I) .NE. A(        I)) CALL ABORT
          IF (A2(I) .NE. A(  NSIZE+I)) CALL ABORT
          IF (A3(I) .NE. A(2*NSIZE+I)) CALL ABORT
       ENDDO
       END
       SUBROUTINE SUB(A, N)
       DIMENSION A(N)
       DO I = 1, N
          A(I) = I
       ENDDO
       END

This is the compiler that will be in GCC 4.1 (which will be out in about 
a week).  Perhaps you can jazz this up by increasing NSIZE so that you 
go over the 4 Gbyte limit on a machine with enough memory ...

Hope this helps,

-- 
Toon Moene - e-mail: toon at moene.indiv.nluug.nl - phone: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
A maintainer of GNU Fortran 95: http://gcc.gnu.org/fortran/
My next laptop will have a crank
_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf



More information about the Beowulf mailing list