TriBITSPub / TriBITS

TriBITS: Tribal Build, Integrate, and Test System,
http://tribits.org
Other
36 stars 46 forks source link

Using a custom MPI library #534

Closed ibaned closed 1 year ago

ibaned commented 1 year ago

I've found a solution for this issue that I will outline below, but I thought it was appropriate to describe here as its own GitHub issue. I use my own implementation of MPI for one rank with TriBITS-based projects: https://github.com/sandialabs/fbmpi.

When using TriBITS' MPI TPL, I couldn't specify my own TPL_MPI_INCLUDE_DIRS unless the call to tribits_tpl_find_include_dirs_and_libraries had a REQUIRED_HEADERS argument. We can provide this with mpi.h, because that is what all MPI codes include. Once that modification is made, I was able to specify the following at configuration time:

-DTPL_ENABLE_MPI=ON
-DTPL_MPI_INCLUDE_DIRS=$MY_INCLUDE_PATH
-DTPL_MPI_LIBRARIES=$MY_LIBRARY
-DMPI_LIBRARY_NAMES=fbmpi

This issue can form a useful anchor for related branches and pull requests with this change

ibaned commented 1 year ago

@bartlettroscoe I might need your help with this too... as you point out it breaks normal Trilinos builds:

https://github.com/trilinos/Trilinos/pull/11175#discussion_r1001979683

Is there a way that the TriBITS MPI TPL can be set up to work both with the usual MPI compiler wrappers and with a specified include dir and library? Right now I'm running into this line which erases my TPL_MPI_INCLUDE_DIRS setting:

https://github.com/TriBITSPub/TriBITS/blob/2a389b7bf4203941a548a31d4e3cea0dbbfc2c3e/tribits/core/package_arch/TribitsTplFindIncludeDirsAndLibraries.cmake#L680

ibaned commented 1 year ago

actually... maybe that file is different in my copy of SEACAS and latest TriBITS...

ibaned commented 1 year ago

Nope, even with the latest snapshot of TriBITS this doesn't work

bartlettroscoe commented 1 year ago

https://github.com/TriBITSPub/TriBITS/blob/2a389b7bf4203941a548a31d4e3cea0dbbfc2c3e/tribits/core/package_arch/TribitsTplFindIncludeDirsAndLibraries.cmake#L680

The simple fix would be to change that line to:

      # Library has no header files, no user override, so just set them to null by default
      if ("${TPL_${TPL_NAME}_INCLUDE_DIRS}" STREQUAL "")
        global_null_set(TPL_${TPL_NAME}_INCLUDE_DIRS "")
      endif()

Can you try that and see if it fixes your use case?

It should be the case that if TPL_${TPL_NAME}_INCLUDE_DIRS is set by the user, then it should be used no questions asked.

ibaned commented 1 year ago

Thanks @bartlettroscoe ! I'm trying this now

ibaned commented 1 year ago

Yes! This is working for my use case! Thank you!