windows - Maximum elements to loop over in fortran in linux and windows
问题描述
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 ?
解决方案
根据 Rodrigo Rodrigues 的评论,我在编译器设置中又添加了一个标志:
-fmax-stack-var-size=65535
文档说默认值为 32767,但我认为代码块和 ubuntu 的本机 gfortran 中有不同的设置。
推荐阅读
- javascript - 如何在 chrome/safari 上显示多个谷歌地图信息窗口?
- java - 为多个并行流更新一个计数器
- python - 使用python进行多项式加法
- configuration - 弹簧型材。配置数据库问题
- jquery - owl carousel 跳转到特定幻灯片并为其添加类
- javascript - React Native Wix 日历标记日期显示错误
- asp.net - 需要在 MVC 中渲染部分视图以代替具有相同布局的另一个部分视图
- python - 我需要为 python pandas 中的缺失索引插入空值
- node.js - webpack 配置文件中没有定义插件
- reactjs - React-select 在 Laravel-mix 中没有显示价值