Maximum elements to loop over in fortran in linux and windows

2

I am writing some parallel Fortran90/95 code and I just came across some thing I can't understand.

I work on a Toshiba laptop with 6Go RAM.

  • In Windows 10, I use code::blocks. I have imported gfortran from MinGW as a compiler and compile my code with the -fopenmp flag.
  • I have Ubuntu 18.04 inside VirtualBox. I let it use half of my ram, that is 3Go. I compile my code on this one using gfortran -fopenmp as well.

A minimal version of the encountered code causing issue is:

program main
  implicit none

  integer :: i
  integer, parameter :: n=500000
  real, dimension(n) :: A, B
  real :: som

  som=0

  do i =1, n
    A(i)= 1.0
    B(i)= 2.0
  end do

  do i=1, n
    som = som + A(i)*B(i)
  end do

  print *,"somme:", som
end program main

I then let vary the value of the parameter n.

  • Running on Windows. For n up to approx 200.000 everything's fine. Above, I get "Process returned -1073741571 (0xC00000FD)"
  • Running on Ubuntu I can go up to 1.000.000 with no issue. Seems that the barrier is around 2.000.000 after which I got a segfault.

My question is how one can explain that ubuntu, in spite of having far less memory available can handle 10 times more iterations ?

Is there anything I can do on the Windows size to make it able to handle more loop iterations ?

windows
loops
ubuntu
fortran
codeblocks
asked on Stack Overflow Nov 28, 2018 by EdouardIFP

1 Answer

0

According to Rodrigo Rodrigues comment, I added one more flag to my compiler setting:

-fmax-stack-var-size=65535

Documentation says default is 32767 but I assume there is a different setting in code blocks and in ubuntu's native gfortran.

answered on Stack Overflow Nov 28, 2018 by EdouardIFP

User contributions licensed under CC BY-SA 3.0