Extremely slow ALLOCATABLE array
robert.funnellNOSPAM_at_NOSPAMmcgill.ca
Date: 11/28/04
- Next message: glen herrmannsfeldt: "Re: g95 wish list"
- Previous message: Topspurs: "Re: max function problems"
- Next in thread: glen herrmannsfeldt: "Re: Extremely slow ALLOCATABLE array"
- Reply: glen herrmannsfeldt: "Re: Extremely slow ALLOCATABLE array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 28 Nov 2004 18:39:17 GMT
I have a case in which use of an ALLOCATABLE array is much much slower
than using a static array. The following is a small test programme
that demonstrates the problem:
IMPLICIT NONE
INTEGER, PARAMETER :: NN=860
INTEGER, PARAMETER :: NPLANES=1
INTEGER, PARAMETER :: NPIXH=NN
INTEGER, PARAMETER :: NPIXV=NN
INTEGER, PARAMETER :: NSLICE=NN
INTEGER IROW,ICOL,ISLICE,IPLANE,ISTATUS
INTEGER(1),ALLOCATABLE :: STACK_XZ(:,:,:,:)
C
INTEGER(1) :: PIX_XZ(NPLANES,NPIXH,NSLICE)
C
c INTEGER(1),ALLOCATABLE :: PIX_XZ(:,:,:)
c ALLOCATE(PIX_XZ(NPLANES,NPIXH,NSLICE),STAT=ISTATUS)
c IF(ISTATUS.NE.0) STOP 1
C
ALLOCATE(STACK_XZ(NPLANES,NPIXH,NSLICE,NPIXV),STAT=ISTATUS)
IF(ISTATUS.NE.0) STOP 2
C
OPEN(UNIT=0,CARRIAGECONTROL='FORTRAN')
C
WRITE(0,'('' Copying'',I5,'' images''/X)') NPIXV
DO IROW=1,NPIXV
IF(MOD(IROW,10).EQ.0) WRITE(0,'(''+'',I5)') IROW
c PIX_XZ=STACK_XZ(:,:,:,IROW)
DO ISLICE=1,NSLICE
DO ICOL=1,NPIXH
DO IPLANE=1,NPLANES
PIX_XZ(IPLANE,ICOL,ISLICE)=
* STACK_XZ(IPLANE,ICOL,ISLICE,IROW)
END DO
END DO
END DO
END DO
C
STOP
C
END
In the form shown here, with a static array, the run time is too short
to measure with a watch; if I comment out the static declaration of
PIX_XZ and uncomment the ALLOCATABLE declaration and its ALLOCATE, the
run time is ~13 seconds. This is on an Alpha with 768 MB using Compaq
Fortran V1.2.0 under Linux.
On an Intel laptop with 512 MB and CVF 6.6.C, the allocatable version
gets to row 550 out of 860 in about half a second then takes over 30
seconds to get to 860, paging heavily; the static version finishes in
much less than half a second. The results are about the same if I use
the commented line PIX_XZ=STACK_XZ(:,:,:,IROW) rather than the
explicit DO loops.
I don't understand why the allocatable array should be so much slower.
Can anyone offer insight? Is this something that would be fixed if I
updated my compilers?
This may be a FAQ, in which case I apologise, but I haven't found the
answer anywhere, and what I'm observing seems to be more extreme than
what I've seen described. The original context is handling CT-scan
data with up to 1024 slices, each being 1024x1024.
- Robert
- Next message: glen herrmannsfeldt: "Re: g95 wish list"
- Previous message: Topspurs: "Re: max function problems"
- Next in thread: glen herrmannsfeldt: "Re: Extremely slow ALLOCATABLE array"
- Reply: glen herrmannsfeldt: "Re: Extremely slow ALLOCATABLE array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|