Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
24 Views

RESHAPE seg faults with -openmp

I am having a memory issue using RESHAPE in Fortran 90. The program faults when -openmp is used, but only for relatively large arrays--I've chosen 1000x1000 as an example. The program runs fine if RESHAPE is not called, with or without -openmp. I have two questions:
 
1) Why does this happen? 
2) Why does the traceback not point to the line with RESHAPE? Usually the traceback feature is pretty good at pinpointing the line.
 
main.f90:
<pre class="brush:fortran">
program main
   integer, parameter :: REAL_KIND = 8
   integer, parameter :: n1 = 1000
   integer, parameter :: n2 = 1000
   real(kind=REAL_KIND) :: x(n1*n2)
   real(kind=REAL_KIND) :: xx(n1,n2)
   print *, 'Before RESHAPE in main'
   x = 0.0
   xx= reshape(xx,(/n1,n2/))
   print *, 'Success in main'
end program main
</pre>
 
************** 
Scenario 1:
>> ifort -O0 -xHost -traceback -check bounds -check uninit -r8 -implicitnone -c main.f90
>> ifort -O0 -xHost -traceback -check bounds -check uninit -r8 -implicitnone -o exec main.o
>> ./exec
Before RESHAPE in main
Success in main 
 
************** 
Scenario 2: 
>> ifort -O0 -xHost -traceback -check bounds -check uninit -r8 -implicitnone -openmp -c main.f90 
>> ifort -O0 -xHost -traceback -check bounds -check uninit -r8 -implicitnone -openmp -o exec main.o 
>> ./exec 
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
exec               000000000047AB85  Unknown               Unknown  Unknown
exec               0000000000478947  Unknown               Unknown  Unknown
exec               0000000000448244  Unknown               Unknown  Unknown
exec               0000000000448056  Unknown               Unknown  Unknown
exec               00000000004271F9  Unknown               Unknown  Unknown
exec               0000000000403820  Unknown               Unknown  Unknown
libpthread.so.0    0000003E5FA0F710  Unknown               Unknown  Unknown
exec               00000000004033CB  MAIN__                      1  main.f90
exec               00000000004033AE  Unknown               Unknown  Unknown
libc.so.6          0000003E5EE1ED5D  Unknown               Unknown  Unknown
exec               0000000000403239  Unknown               Unknown  Unknown
 
************ 
Note: 
>> ifort --version
ifort (IFORT) 16.0.0 20150815 
0 Kudos
3 Replies
Highlighted
24 Views

A too large of temporary variable may have been created. You may need to adjust the stack size for both main thread (usually Linker option) and OpenMP threads (either environment variable or library call before first parallel region).

Jim Dempsey

0 Kudos
Highlighted
24 Views

On Linux the stack size is set with a shell command (ulimit -s or limit stacksize unlimited) - note that these don't actually remove a limit, but they set the size to the maximum defined in the kernel build. The environment variable OMP_STACKSIZE may also need to be defined with a higher value.

0 Kudos
Highlighted
Beginner
24 Views

I see—that makes sense.  Thank you both for the answers!

0 Kudos