- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi to everyone,
I am parallelizing a MC code written in Fortran using OpenMP. During the development process I used the Parallel Studio Suite with great success (really, I would not be able to do it without the help of the Advisor, Amplifier and Inspector programs... I am not an expert (actually, I am physicist who loves programming, but I have had to do self-training during my career)
Now I am testing the performance of my program under various OS, compiler and CPU's. Originally, this code was expected to be compiled with gfortran and "-O3 -ffast-math" flags, is there a close equivalent to this configuration for ifort?
As a first approach I am using ifort with "-O3" and I obtain a ~20% performance gain compared with gfortran, so I would like to check if there are other flags that could improve the performance of my code. Thanks for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you failed to set -qopenmp or -openmp according to ifort version (equivalent to gfortran -fopenmp), and didn't follow the method of protecting omp function calls in #ifdef _OPENMP ... #endif you might expect such unresolved references at link time.
The legacy method of
integer omp_num_threads ! not using OpenMP header or USE
...
n = omp_get_num_threads()
should work if you don't change default integer type, and link against OpenMP library, but certain Intel tools will warn about it, as it's contrary to OpenMP standard.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I usually recommend -fast to start out - this is shorthand for a set of options that usually improve performance. It includes -O3 as well as -xHost, which lets the compiler take advantage of advanced instructions on the processor you're using.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
gfortran -O -ffast-math implies the equivalent of -complex-limited-range which affects only complex data types and is risky. It also implies the equivalent of -assume protect_parens,byterecl,buffered_io,minus0 which are all good options.
You probably do want some unrolling, which is implied by the ifort option you mentioned, but not the gfortran.
The nearest gfortran equivalent to -xHost, which Steve recommended, is -march=native. gfortran 64-bit defaults to -msse2, as does ifort.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your answers, I used "-O3 -fast" with ifort and comparing with gfortran -O3 -ffast-math I obtained a ~35% performance gain, but I have a small problem. When I use "-fast" I have some warnings during the compilation:
ipo: warning #11021: unresolved omp_get_num_threads_
Referenced in /tmp/ipo_ifortAfxRhT.o
(a lot of this kind of warnings, all related to omp_ functions)
The program executes normally and the results are correct, but I am worried about this messages, should I worry about them?
@Tim: I will try your suggestions with gfortran, thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting that you would get that warning - it's during the link phase. Do you have any OpenMP code in this program? Do you have a test case we can look at? If you don't see actual errors, I wouldn't worry, but something isn't right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I use OpenMP to parallelize it, and I call that functions to output the number of OpenMP threads, to initialize the RNG, etc...
I have a test code (attached, it was an example to another problem that I had with OpenMP - from Jim Dempsey), there I have
the following message when compiling with ifort -openmp -O3 -fast
ipo: warning #11021: unresolved omp_get_thread_num
Referenced in /tmp/ipo_iforts9U7NX.o
ipo: warning #11021: unresolved omp_set_num_threads
Referenced in /tmp/ipo_iforts9U7NX.o
ipo: remark #11001: performing single-file optimizations
ipo: remark #11006: generating object file /tmp/ipo_iforts9U7NX.o
thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you failed to set -qopenmp or -openmp according to ifort version (equivalent to gfortran -fopenmp), and didn't follow the method of protecting omp function calls in #ifdef _OPENMP ... #endif you might expect such unresolved references at link time.
The legacy method of
integer omp_num_threads ! not using OpenMP header or USE
...
n = omp_get_num_threads()
should work if you don't change default integer type, and link against OpenMP library, but certain Intel tools will warn about it, as it's contrary to OpenMP standard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks for the help, Tim, I had no idea about the correct method to use the omp functions... and by the way, I had the doubt of how to use them and being able to compile the program without the use of the omp library... thanks!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page