Missing $(LINK_OPENMP) in Make/options
The LIB_LIBS
list in Make/options
should be changed to also contain a reference to $(LINK_OPENMP)
. Otherwise, this causes issues when trying to compile and use cfMesh binaries on macOS (in particular, the compiled binaries will fail to dynamically link against OpenMP on launch).
See also: OpenFOAM issue that introduced the $(LINK_OPENMP)
definition, example of an options
file that uses $(LINK_OPENMP)
, and bug report for this issue on OpenFOAM.app (macOS).
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Link issues together to show that they're related. Learn more.
Activity
- Author
@mark any chance this fix can be applied for the next release?
- Maintainer
Hi @gerlero - thanks for raising this again. Looks like I missed seeing this the first time. The link question is an interesting one. I've made some recent changes (in the OpenFOAM files) to handle an explicit request for openmp (uses the
+openmp
flag inWM_COMPILE_CONTROL
). For this, I've add it into linkage for the executables only and it seems to work.If I follow you correctly, we probably need to have the same thing in the various Make/options. Eg,
EXE_LIBS = \ -lfiniteVolume \ -lmeshTools \ -L$(FOAM_MODULE_LIBBIN) -lmeshLibrary $(LINK_OPENMP)
I know that @kuti thankfully has such a partly broken installation (where the omp libraries are missing). Does this fail to compile/link there?
- Author
@mark thanks for the reply.
I've made some recent changes (in the OpenFOAM files) to handle an explicit request for openmp (uses the
+openmp
flag inWM_COMPILE_CONTROL
). For this, I've add it into linkage for the executables only and it seems to work.Building against OpenMP (which on macOS must be installed as a third-party library) with Apple's dev tools requires specific compiler and linker flags to be passed, which OpenFOAM assigns here (to
$(COMP_OPENMP)
and$(LINK_OPENMP)
) when it detects macOS.Just in case, I've just tested the master branch: I can confirm that it's still the case that cfMesh binaries fail to run with an
ld
error when built on macOS without adding the missing$(LINK_OPENMP)
toMake/options
.If I follow you correctly, we probably need to have the same thing in the various Make/options
Yes, although only with the libraries that depend on OpenMP and are missing that flag in their
Make/options
. Which IIRC I've only seen here in the cfMesh module (so far I've only found I needed to add a missing$(LINK_OPENMP)
tomodules/cfMesh/meshLibrary/Make/options
). - Maintainer
Hi @gerlero - thanks for waiting this one out. I've looped back with @kuti (who fortunately has a broken openmp installation on one of his machines). From what I gather, as soon as we specify
-fopenmp
at the compile-level, the link will need to work (ie, a proper installation) or it simply fails. Thus, there is no problem with adding in the LINK_OPENMP and it can be conveniently added as a lib-lib dependency.I was slightly hesitant to change this immediately, but it looks OK. @kuti - you can compile this with the wmake
-no-openmp
option.@gerlero : are you using cfmesh extensively? I was curious about how much speed difference there is with/without openmp
- Author
From what I gather, as soon as we specify
-fopenmp
at the compile-level, the link will need to work (ie, a proper installation) or it simply fails. Thus, there is no problem with adding in the LINK_OPENMP and it can be conveniently added as a lib-lib dependency.I'm okay with this.
On macOS in particular:
- it fixes the current issue where cfMesh won't find OpenMP even though it is installed
- compilation of OpenFOAM already fails (missing
omp.h
include) if you don't actually have OpenMP and haven't set the~openmp
compile option (i.e., OpenMP is already a required dependency under the default configuration)
I was slightly hesitant to change this immediately, but it looks OK. @kuti - you can compile this with the wmake
-no-openmp
option.Eventually, I guess the presence/absence of OpenMP (and also its path, which would be really useful on macOS) could be handled by OpenFOAM as another optional dependency (i.e., like scotch, CGAL, etc.)...
@gerlero : are you using cfmesh extensively? I was curious about how much speed difference there is with/without openmp
Not a cfMesh user at all (in fact, I became aware of this problem through an issue reported on my repo).
Nonetheless, here's some numbers on macOS, for what they're worth (runtimes of
cfmesh/tutorials/Allrun
):- OpenFOAM-v2206 (with OpenMP 15.0.3 installed with Homebrew)
real 6m31.092s user 37m11.489s sys 0m20.933s
- OpenFOAM-v2206 (no OpenMP, compiled with the
~openmp
flag)
real 20m23.994s user 20m9.491s sys 0m8.187s
- Mark OLESEN mentioned in commit 8faa204a
mentioned in commit 8faa204a
- Author
Fixed in v2212
- Gabriel Gerlero closed
closed