- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
we have encountered a problem with copying large arrays. The following program illustrates
this. Some details: we use Intel Fortran 11.1.065 on Windows XP (it happens with 11.0.72 and
11.1.54 as well, but not with 11.0 on Linux).
The output from the program is:
forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
bigarrays.exe 0042A157 Unknown Unknown Unknown
bigarrays.exe 00401296 Unknown Unknown Unknown
bigarrays.exe 00440183 Unknown Unknown Unknown
bigarrays.exe 0042A303 Unknown Unknown Unknown
kernel32.dll 7C817027 Unknown Unknown Unknown
The problem occurs at the statement "xr =x" in the program below.
There are several ways of solving it:
- Use explicit loops
- Use an associate block
Still, this is an annoying phenomenon.
Regards,
Arjen
----
! bigarrays.f90 --
! Try and reproduce a stack overflow problem with large
! arrays
!
module griddata
implicit none
integer, parameter :: double = kind(1.0d0)
type grid_t
real(double), dimension(:,:), pointer :: x
real(double), dimension(:,:), pointer :: y
end type grid_t
type(grid_t) :: grid
contains
subroutine copy_grid_arrays( grid )
type(grid_t), target :: grid
real(double), dimension(:,:), pointer :: x, y
real(double), dimension(:,:), pointer :: xr, yr
integer :: m, n
x => grid%x
y => grid%y
m = size(grid%x, 1)
n = size(grid%x, 2)
allocate( xr(m,n) )
allocate( yr(m,n) )
xr = x
yr = y
end subroutine copy_grid_arrays
end module griddata
program bigarrays
use griddata
implicit none
integer :: m, n
m = 1500
n = 700
allocate( grid%x(m,n) )
allocate( grid%y(m,n) )
grid%x = 1.0_double
grid%y = 1.0_double
call copy_grid_arrays( grid )
end program bigarrays
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
xr = x
to function without causing stack overflow, the memory allocated for the copy operation is released/reused for the next statement:
yr = y
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In my viewpoint, if another compiler (e.g. gfortran) is able to compile the code without using a temporary (thus consuming more cache), it is a worthwhile challenge for ifort to eliminate the temporary.
I don't have a copy of the compiler you used. The latest ifort for Win64 has solved some such problems; as far as I can see, this case may be one of those which is fixed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On Linux I noticed messages from the Intel compiler about loops being vectorised that I do
not see on Windows (they correspond to the array assignments).
It may have to do with the allocation of temporary arrays - ISRT gfortran always uses the
heap and only recently acquired the possibility to use the stack instead for performance
reasons.
The issue is solved if I use the -heap-arrays option.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also, as of 11.1 the Intel compiler no longer issues vectorization messages by default.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To prevent aliasing to wreck havoc? (I probably found the reason myself while formulating my
question ;))
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
we have compilers to do the tough work :).
Regards,
Arjen
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page