lanl / nuDustC

Nucleating Dust Code in C++
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

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

Open guadabsb15 opened 1 month ago

guadabsb15 commented 1 month ago

Hi! This issue is also related to the JOSS review https://github.com/openjournals/joss-reviews/issues/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 commented 2 weeks ago

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 commented 4 days ago

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 commented 3 days ago

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