Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to build with MPI and/or OpenMP #4

Open
guadabsb15 opened this issue May 16, 2024 · 7 comments
Open

Not able to build with MPI and/or OpenMP #4

guadabsb15 opened this issue May 16, 2024 · 7 comments

Comments

@guadabsb15
Copy link

Hi! This issue is also related to the JOSS review openjournals/joss-reviews#6637

Thank you for the description provided for installation, although I was able to build nuDustC serially, when trying to build with NUDUSTC_ENABLE_MPI=ON , I get the following error :

CMake Error at CMakeLists.txt:86 (target_link_libraries):
  Target "nudustc++" links to:

    "MPI::MPI_CXX"

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

I get an analogous error when using NUDUSTC_ENABLE_OPENMP=ON I tried both using cmake 3.29 and cmake 3.23.3, but it looks like the quotes inside the generator $<${with_mpi}:"MPI::MPI_CXX"> in CMakeLists.txt might be causing an issue. CMake seems to find the path to the MPI relevant paths, so I'm not sure that is the problem.

@sarahstangl-lanl
Copy link
Collaborator

I'm unable to recreate this error. It looks like there is an issue with cmake finding MPI. You might need to specify the path to the MPI build and ensure the correct MPI is called in CMake is installed.

@steven-murray
Copy link

I also am having trouble installing on Ubuntu. My error is that it just can't find mpi.h, but I have installed MPICH with apt. I can't find where to specify the include directory for MPI. This error occurs even if I set

option(NUDUSTC_ENABLE_MPI OFF "Use MPI for cell/particle parallelization")

in the CMakeLists.txt (it is ON by default, despite what the readme says).

@steven-murray
Copy link

steven-murray commented Jul 4, 2024

I tried again on Manjaro linux (essentialy Arch), and got a different MPI-based error:

[ 12%] Building CXX object CMakeFiles/nudustc++.dir/src/cell.cpp.o
[ 25%] Building CXX object CMakeFiles/nudustc++.dir/src/cellobserver.cpp.o
[ 37%] Building CXX object CMakeFiles/nudustc++.dir/src/configuration.cpp.o
/home/sgm/work/joss-reviews/nudustc/src/configuration.cpp: In constructor ‘configuration::configuration()’:
/home/sgm/work/joss-reviews/nudustc/src/configuration.cpp:39:102: warning: overflow in conversion from ‘float’ to ‘int’ changes value from ‘+QNaNf’ to ‘0’ [-Woverflow]
   39 |     desc.add_options() ( "number_of_size_bins", options::value<int> ( &bin_number )->default_value ( NAN ), "bin number" );
      |                                                                                                      ^~~
[ 50%] Building CXX object CMakeFiles/nudustc++.dir/src/main.cpp.o
[ 62%] Building CXX object CMakeFiles/nudustc++.dir/src/network.cpp.o
[ 75%] Building CXX object CMakeFiles/nudustc++.dir/src/nudust.cpp.o
[ 87%] Building CXX object CMakeFiles/nudustc++.dir/src/reaction.cpp.o
[100%] Linking CXX executable nudustc++
/usr/sbin/ld: CMakeFiles/nudustc++.dir/src/main.cpp.o: warning: relocation against `ompi_mpi_comm_world' in read-only section `.text'
/usr/sbin/ld: CMakeFiles/nudustc++.dir/src/main.cpp.o: in function `main':
main.cpp:(.text+0x7e): undefined reference to `MPI_Init'
/usr/sbin/ld: main.cpp:(.text+0x97): undefined reference to `MPI_Init'
/usr/sbin/ld: main.cpp:(.text+0x117): undefined reference to `ompi_mpi_comm_world'
/usr/sbin/ld: main.cpp:(.text+0x11f): undefined reference to `MPI_Comm_rank'
/usr/sbin/ld: main.cpp:(.text+0x136): undefined reference to `ompi_mpi_comm_world'
/usr/sbin/ld: main.cpp:(.text+0x13e): undefined reference to `MPI_Comm_size'
/usr/sbin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/nudustc++.dir/build.make:197: nudustc++] Error 1
make[1]: *** [CMakeFiles/Makefile2:100: CMakeFiles/nudustc++.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Again, this happens whether or not I switch on MPI in the CMakeLists.txt.

This is with gcc 14 and openmpi 5

@guadabsb15
Copy link
Author

With recent changes in the repository, I also get the errors @steven-murray mentions. I'm using ubuntu and gcc14, and tried with both openmpi 5 and 4.1

@sarahstangl-lanl
Copy link
Collaborator

sarahstangl-lanl commented Jul 10, 2024 via email

@guadabsb15
Copy link
Author

I just tried again "cmake -DNUDUSTC_ENABLE_MPI=ON" to make sure that MPI is enabled. The output I get is

MPI Found
-- Configuring done
CMake Error at CMakeLists.txt:91 (target_link_libraries):
  Target "nudustc++" links to:

    "MPI::MPI_CXX"

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

So MPI is found, as shown by the recent message you added for that purpose. Also, looking at the CMakeCache.txt in the build directory I can see MPI_mpi_LIBRARY:FILEPATH=/home/mgbarrioss/miniforge3/envs/joss_nuDustc_3/lib/libmpi.so

However the original issue message remains in the output.

As I said originally I suspect the problem is with the quotes around MPI::MPI_CXX in line 99 of CMakeLists.txt. If I remove those quotes, the build process finishes.

@sarahstangl-lanl
Copy link
Collaborator

sarahstangl-lanl commented Jul 11, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants