Comments (10)
Narrowing this down and it is a problem/missing feature in CMake:
We are attempting to allow Spack to build the MPI itself, hopefully this goes well.
Thanks for helping track this down and there is nothing MFEM could do to work around this.
from mfem.
This is normal since MFEM's make config
does not really try to automate the config process for dependencies. It provides sensible defaults for the variables <PACKAGE>_OPT
(compile flags) and <PACKAGE>_LIB
(link flags). If these defaults do not work, the user is expected to define them on the make config ...
command line or in their config/user.mk
file (which should be copied from config/defaults.mk
and then modified where needed).
In the case of STRUMPACK, STRUMPACK_LIB
uses another variable to configure the MPI+fortran dependence -- MPI_FORTRAN_LIB
. In your case, it sounds like it will be sufficient to just modify accordingly this variable and leave STRUMPACK_{OPT,LIB}
as they are.
For example, on my Mac, I modify MPI_FORTRAN_LIB
by adding the following to my user.mk
:
# Additional Fortran library:
MPI_FORTRAN_LIB += -L$(BREW_DIR)/Cellar/gcc/13.1.0/lib/gcc/13 -lgfortran
where BREW_DIR
is the path to my Homebrew directory.
In your case, you probably just need to add the path to where libmpi_mpifh.*
is, before -lmpi_mpifh
. Normally, this path will already be specified on the linking command line, so it is not explicitly needed. However, in your case, the MPI link path probably appears after -lmpi_mpifh
. So maybe a simpler solution is to just move the MPI link path before the MFEM flags.
from mfem.
I just realized that you may be using config.mk
file from the CMake build system where things should be a bit more automated. Are you using CMake to build MFEM?
from mfem.
This is building MFEM through Spack on OSX, so it would be your Makefile build system. Should a fix go into your Spack package?
Maybe something like:
// Get MPI_DIR
// Get MPI_LIB
MPI_FORTRAN_LIB += -L$(MPI_DIR) -l$(MPI_LIB)
I'll figure out the specifics later when caffiene kicks in.
from mfem.
In Spack this should be handled -- in the contents of MFEM_EXT_LIBS
, I see the flags: -Wl,-rpath,/opt/local/lib -L/opt/local/lib -lmpi_mpifh
. The path /opt/local/lib
is obtained from mpi.prefix.lib
, see here: https://github.com/spack/spack/blob/c38ef72b0668b02a566ce7f5cee114f776ccc9b6/var/spack/repos/builtin/packages/mfem/package.py#L751-L752. I'm not sure what's wrong -- isn't libmpi_mpifh
in that directory? Or is this an MPI implementation that is not handled? We have logic for the following MPI implementations: https://github.com/spack/spack/blob/c38ef72b0668b02a566ce7f5cee114f776ccc9b6/var/spack/repos/builtin/packages/mfem/package.py#L749-L754.
from mfem.
mpi_mpifh
was in the correct directory but no -L<mpi directory>
was being added to the link line.
from mfem.
Shouldn't -L<mpi directory> -lmpi
(or something like that) be added to the link line where you're linking an MPI executable without the MPI compiler wrapper?
If we want to add these flags to MFEM_EXT_LIBS
, (by setting MPI_{OPT,LIB}
) we may need a lot of extra logic to figure out what flags are actually added by the MPI wrapper -- it is not always just -I<mpi dir>/include
and -L<mpi dir>/lib -lmpi
. It is much more portable to just rely on the MPI wrapper, I think.
Maybe specifically in Spack this is easier to do? Do you know if we can get the needed MPI flags from Spack or the MPI-provider packages in Spack?
from mfem.
Shouldn't
-L<mpi directory> -lmpi
(or something like that) be added to the link line where you're linking an MPI executable without the MPI compiler wrapper?
Kind of, it generally adds an absolute path to the MPI libraries (we don't add the Fortran MPI library because we don't explicitly require it) but that isn't the problem. MPI_EXT_LIBS
adds the Fortran MPI library to the link line w/o the directory to find it.
If we want to add these flags to
MFEM_EXT_LIBS
, (by settingMPI_{OPT,LIB}
) we may need a lot of extra logic to figure out what flags are actually added by the MPI wrapper -- it is not always just-I<mpi dir>/include
and-L<mpi dir>/lib -lmpi
. It is much more portable to just rely on the MPI wrapper, I think.
The includes are and the absolute C++ libraries are added by our project but no -L
's.
Maybe specifically in Spack this is easier to do? Do you know if we can get the needed MPI flags from Spack or the MPI-provider packages in Spack?
Staring at the multiple levels, I think what is happening is the Spack package adds the proper information to STRUMPACK_LIB
so that MFEM itself builds, but that information is not getting passed to the config/defaults.mk
|whatever generates the config.mk
. I could be wrong but I think this line is injecting the $(MPI_FORTRAN_LIB)
but not the -L
:
Line 331 in ac88580
Does the Makefile build system not override that command line STRUMPACK_LIB
before it generates the outputted config.mk
? I don't fully understand how your Makefile generates that file w/o more effort.
from mfem.
When @btalamini gets back I can get the command line from Spack to see if it will show more information of what is going on. I can't reproduce this myself.
from mfem.
Just to clarify: the MFEM's spack packages does add the correct path for -lmpi_mpifh
or, more precisely, what I think is the correct path derived from the MPI package: the MPI prefix + /lib
. This is done on this line:
sp_lib += [ld_flags_from_dirs([mpi.prefix.lib], ["mpi_mpifh"])]
(direct link to the above code)
In this context, the variable mpi
is defined as:
mpi = strumpack["mpi"]
(direct link to the above code)
Judging by the value of MFEM_EXT_LIBS
posted above, the path mpi.prefix.lib
resolved to /opt/local/lib
. Is this not the correct path? Maybe the libraries are in lib64
sub-directory and not in lib
? If this is the case, I can fix the code to actually look at the file system to determine the right path.
from mfem.
Related Issues (20)
- Issue with GPU Computation Execution in CUDA Mode HOT 4
- Compilation issue when compiling for GPU -- missing header HOT 1
- Strange behavior with ProjectCoefficient HOT 3
- vertices indices are not unique HOT 9
- Linking against Spack MFEM package HOT 4
- 【Usage】 How to caculate the right hand side (q\nabla T, v) HOT 5
- Spiro: perhaps an alternative for bezier spline by nurbs for more quality and faster optimization
- Matthek triangle method for fast optimization of edges in mechanics and fluid simulation
- How to extract solution at certain positions in mfem HOT 34
- Overlapping boundary attributes not inherited in submesh HOT 10
- Bug using mesh refinement and BC's HOT 5
- MFEM program crashes when solving linear static analysis problem when using AddBdrTriangle HOT 2
- Adding heat source to ex16 HOT 3
- Can MFEM handle multiple sources at the right hand side of equation HOT 3
- PrintVTK issues HOT 2
- Change some MFEM_ASSERT to MFEM_VERIFY, or report more info's to the users? HOT 2
- Face dofs for Periodic meshes HOT 5
- Inconsistency Between MFEM + ParaView for Symmetric Tensor Outputs HOT 1
- Request for an EasyBuild Configueation file HOT 2
- ND_R2D visualization with glvis fails HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mfem.