Skip to content

Conversation

@mathstuf
Copy link
Contributor

Otherwise projects using conduit::conduit_mpi may get errors about MPI::MPI_C not being a target without finding it themselves.

@cyrush
Copy link
Member

cyrush commented Nov 20, 2025

We made a choice that folks can use a conduit built with MPI, downstream w/o using its MPI features w/o having to locate mpi.

We actually have tests that support this use case, one is our basic example of how to build conduit with cmake:

https://github.com/LLNL/conduit/blob/develop/src/examples/using-with-cmake/CMakeLists.txt

This means that downstream use must find MPI when using Conduit's MPI features.

The need to find mpi downstream is reflected in our using-with-cmake-mpi example:

There are some other caveats about this: Even when MPI is on we may not search for it when it is implicitly supported by the compiler (cray use cases...)

This config var reveals if that is the case:

set(CONDUIT_USE_CMAKE_MPI_TARGETS "@CONDUIT_USE_CMAKE_MPI_TARGETS@")

@mathstuf
Copy link
Contributor Author

Can it be requested that Conduit does it via a component?

find_package(Conduit COMPONENTS MPI)?

@cyrush
Copy link
Member

cyrush commented Nov 20, 2025

@mathstuf yes, that sounds like a much nicer way to formalize this

The package is intended to be found via `find_package(Conduit)`, so set
the package name's `_FOUND` variable directly.
@mathstuf mathstuf force-pushed the find-mpi-dep branch 4 times, most recently from f9806f2 to 678113d Compare November 20, 2025 20:04
@mathstuf
Copy link
Contributor Author

OK, I've added logic to handle components and then added support for the MPI component which takes the considerations you mentioned into account. I also updated the example to use the MPI component and bail if it isn't reported as being found. The example was also unconditionally using MPI::MPI_C which isn't correct when MPI is implicit in the toolchain (i.e., the targets aren't being used), so that is also removed.

Copy link
Member

@cyrush cyrush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for adding the component based logic and updating the examples.

I have one question about the cmake config changes.

@mathstuf mathstuf changed the title config/cmake: find MPI if the relay MPI targets are provided config/cmake: find MPI if the MPI component is requested Nov 20, 2025
@mathstuf mathstuf force-pushed the find-mpi-dep branch 2 times, most recently from 3172368 to 3c49e34 Compare November 20, 2025 21:25
Otherwise projects using `conduit::conduit_mpi` may get errors about
`MPI::MPI_C` not being a target without finding it themselves. Instead
of requesting users to find MPI themselves, let them request support via
an MPI component.
Also drop the explicit `MPI::MPI_C` link as `conduit::conduit_mpi`
already does this.
Two subsequent searches could have different component requests, so
remove the `CONDUIT_FOUND` guard that skips over that logic.
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

Successfully merging this pull request may close these issues.

2 participants