'What are the equivalent compilation options for gfort given the ifort compilation?
I am trying to compile a code using gfortran instead of ifortran. The gfortran code runs much much slower than the ifortran code. It does not even use all threads from my computer. I have 40 cores and 80 threads. ifort uses all of them.I think it has to do with the ifort flag /Qm64 but can't be sure (using the /Qm32 flag on ifort is slower and does not use all the threads on openmp - not sure why).
This is the way that visual studio seems to be compiling my code:
Compiling with Intel® Fortran Compiler Classic 2021.4.0 [Intel(R) 64]...
ifort /nologo /O2 /Qopenmp /module:"x64\Release\\" /object:"x64\Release\\" /Fd"x64\Release\vc160.pdb" /libs:dll /threads /c /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64" /Qm64 "D:\test\main1.f90"
Linking...
Link /OUT:"x64\Release\DebtDuration.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"x64\Release\DebtDuration.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /SUBSYSTEM:CONSOLE /STACK:999999999 /IMPLIB:"D:\test\x64\Release\DebtDuration.lib" -qm64 "x64\Release\splint.obj" "x64\Release\linspace.obj" "x64\Release\random_normal.obj" "x64\Release\spline.obj" "x64\Release\rouwenhorst.obj" "x64\Release\bspline_sub_module.obj" "x64\Release\main1.obj"
Embedding manifest...
Here's how I was trying to compile in gfortran:
gfortran -c -O2 -m64 bspline_sub_module.f90
gfortran -w -ffree-form -ffree-line-length-0 -m64 -O2 -fopenmp main1.f90 random_normal.f90 linspace.f90 bspline_sub_module.o rouwenhorst.f90 spline.f90 splint.f90
gfortran -fopenmp main1.o random_normal.o linspace.o bspline_sub_module.o rouwenhorst.o spline.o splint.o
What am I doing wrong?
Here's a video with what I mean in terms of differences in thread/core usage: https://www.dropbox.com/s/sc2ebrzckz9y0m1/Video_fortran.mp4?dl=0
If I compile my ifort code with \qm32 flag it gets similar performance to the gfortran.
Solution 1:[1]
It seems you are not enabling any compiler optimizations for gfortran. It is pointless to reason about performance without them. Try at least -O2 or -O3. They are not necesarily equivalent for.both compilers, but similar. There are many other optimizations flags available in the manual. See https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vladimir F ГероÑм Ñлава |
