From 43bd5cac2356b9a7b04dd6e255302d6511e524c2 Mon Sep 17 00:00:00 2001 From: Juniper Tyree Date: Sun, 2 Jun 2024 11:16:01 +0000 Subject: [PATCH] Add utility error when using MPI with non-MPI partitioning --- rustcoalescence/src/cli/simulate/parse/partitioning.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rustcoalescence/src/cli/simulate/parse/partitioning.rs b/rustcoalescence/src/cli/simulate/parse/partitioning.rs index 28387f622..c89a1b43f 100644 --- a/rustcoalescence/src/cli/simulate/parse/partitioning.rs +++ b/rustcoalescence/src/cli/simulate/parse/partitioning.rs @@ -12,6 +12,16 @@ pub(in super::super) fn parse_and_normalise( normalised_args.partitioning(&partitioning); + #[cfg(feature = "mpi-partitioning")] + if !matches!(&partitioning, Partitioning::Mpi(_)) { + match necsim_partitioning_mpi::MpiPartitioning::initialise() { + Ok(_) | Err(necsim_partitioning_mpi::MpiPartitioningError::AlreadyInitialised) => { + anyhow::bail!("MPI should not be used together with a non-MPI partitioning") + }, + Err(necsim_partitioning_mpi::MpiPartitioningError::NoParallelism) => (), + } + } + Ok(partitioning) }