I've been approached by Gentoo user who told me that he's been able to achieve superior performance when building OpenMP programs using gfortran against libomp (instead of libgomp). I'll link or attach his results when I get a confirmation that it's fine to do so. However, doing that seems non-trivial. It seems that gcc strongly prefers files from /usr/lib/gcc..., so in order to enforce libomp we'd either have to replace libgomp.so or libgomp.spec. Does anyone have a better idea? Maybe it'd be possible to override openmp link libraries via Gentoo .spec files?
I thought that the openmp stuff in gcc was heavily tied to libgomp and other implementations weren't compatible (in that to use them you didn't pass -fopenmp but just linked in the wanted library, eg. intel's libiomp worked that way). That was several years ago though so things may have changed?
I think you need -fopenmp to get the needed pragmas. $ gfortran omptry.f90 -lomp $ ./a.out max threads: 0 20000 $ gfortran omptry.f90 -fopenmp $ ./a.out max threads: 2 20000 I could do '-fopenmp -lomp' but that links both libraries in, so probably not a good idea at all. However, the following seems to work: $ gfortran omptry.f90 -fopenmp -c $ gfortran omptry.o -lomp $ ./a.out max threads: 2 20000 However, it's a little inconvenient ;-).
(In reply to Michał Górny from comment #0) > I've been approached by Gentoo user who told me that he's been able to > achieve superior performance when building OpenMP programs using gfortran > against libomp (instead of libgomp). I'll link or attach his results when I > get a confirmation that it's fine to do so. Any news here? > > However, doing that seems non-trivial. It seems that gcc strongly prefers > files from /usr/lib/gcc..., so in order to enforce libomp we'd either have > to replace libgomp.so or libgomp.spec. Does anyone have a better idea? Maybe > it'd be possible to override openmp link libraries via Gentoo .spec files? No clue, but if it's worthwhile researching...
I don't really know. I probably never got any reply, and I don't even really recall where to look for it.