Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29010 Discussions

Segmentation fault with OpenMP, possible bug.

jrfsousa
Beginner
305 Views
Hi all!
I get a segmentation fault when compiling with -openmp -ftrapuv
[fortran]program foo_p
  integer, parameter :: wp=kind(1.0D0)
  integer, parameter :: nst=1
  integer, parameter :: np=700000
  type foo_t
    real(kind=wp), dimension(np) :: bar
  end type foo_t
  type(foo_t) :: a, b
  integer :: ist, ip
  !$omp parallel do private(ip)
  do ist = 1, nst
    !a%bar=a%bar+b%bar
    !a%bar(1:np)=a%bar(1:np)+b%bar(1:np)
    forall(ip=1:np)a%bar(ip)=a%bar(ip)+b%bar(ip)
  end do
  !$omp end parallel do
  stop
end program foo_p
[/fortran]
Removing the !$OMP directives or changing the forall to a do loop makes the error go away.
The parameter np is a magical number for lower values it crashes less often or not at all. (doneulimit -s unlimited)
The array syntax works in this example but in more convoluted cases the "a%bar(1:np)=..." also crashes.
I have some doubts about the private clause there:
[bash]!$omp parallel do private(j)
do i=1,n
  !...
  forall(j=1:m)...
[/bash]
Because I would think that j is more like a placeholder than a variable. But it does not seem to have any effect.
Any advice?
Thank you very much.
Best regards,
Jos Rui
0 Kudos
1 Reply
jrfsousa
Beginner
305 Views
Hi all!
I think I have found a solution:
Setting theOMP_STACKSIZE environment variable...
Sure is easy know it... ;-)
Sorry for the mess up.
Best regards,
Jos Rui
0 Kudos
Reply