Repository navigation
test(mpi): ✅ make the MPI tests meaningful and run them in every configuration #431
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dfe5d81
test(cpp): ✅ register every case and run the MPI suite with splitmix …
robertodr b1dcfde
test(cpp): ✅ skip cases that need several ranks instead of passing them
robertodr 538dab1
test(cpp): 🐛 compare serial and distributed runs on references trunca…
robertodr 94fef2a
test(cpp): ✅ check that linear routing refuses a three-rank communicator
robertodr fb8de41
test(py): ♻️ run serial tests with comm=None and distribute through a…
robertodr 5e4af55
test(py): 🥅 report failures from every MPI rank, not only rank 0
robertodr cc2449c
test(py): ✅ compare distributed Majorana and Pauli runs with the seri…
robertodr 92958f3
build(just): 🔧 run the Python MPI legs in every routing and partition…
robertodr 7b1c649
ci(test): 👷 run the MPI legs through the recipes, with a job timeout
robertodr 05cc05a
docs(mpi): 📝 document comm=None and the MPI test configurations
robertodr 9f232b9
docs(mpi): 📝 tighten the MPI test documentation
robertodr bd77372
docs(mpi): 📝 correct the splitmix rank-list advice and the three-rank…
robertodr 1579cc3
Apply suggestion from @robertodr
robertodr a733f9b
test(ci): 🐛 pin the routing of linear MPI variants and report results…
robertodr 335faa3
test(mpi): 🐛 run each Python MPI leg in exactly its own configuration…
robertodr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // Copyright 2026 Algorithmiq | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <bit> | ||
| #include <cstdlib> | ||
| #include <format> | ||
| #include <functional> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| #include <boost/test/unit_test.hpp> | ||
|
|
||
| #include "monoprop/detail/mpi/MPICompat.h" | ||
| #include "monoprop/detail/mpi/Routing.h" | ||
|
|
||
| /* | ||
| * Boost.Test preconditions for cases that need a particular MPI world. A case whose precondition | ||
| * fails is reported as skipped, with the reason, instead of passing without checking anything; | ||
| * CTest turns that report into a skip for the per-case serial entries. | ||
| */ | ||
| namespace test_utils { | ||
|
|
||
| namespace rank_detail { | ||
|
|
||
| inline auto world_size_precondition(std::function<bool(int)> accepts, std::string need) | ||
| -> boost::unit_test::decorator::precondition { | ||
| return boost::unit_test::precondition( | ||
| [accepts = std::move(accepts), need = std::move(need)](boost::unit_test::test_unit_id) { | ||
| const int ranks = monoprop::mpi::size(MPI_COMM_WORLD); | ||
| boost::test_tools::assertion_result result(accepts(ranks)); | ||
| result.message() << "needs " << need << ", MPI_COMM_WORLD has " << ranks; | ||
| return result; | ||
| }); | ||
| } | ||
|
|
||
| } // namespace rank_detail | ||
|
|
||
| /// Requires at least @p count ranks in MPI_COMM_WORLD. | ||
| inline auto min_ranks(int count) -> boost::unit_test::decorator::precondition { | ||
| return rank_detail::world_size_precondition([count](int ranks) { return ranks >= count; }, | ||
| std::format("at least {} ranks", count)); | ||
| } | ||
|
|
||
| /// Requires a power-of-two rank count of at least @p count, which the XOR pairing needs. | ||
| inline auto power_of_two_ranks(int count = 2) -> boost::unit_test::decorator::precondition { | ||
| return rank_detail::world_size_precondition( | ||
| [count](int ranks) { return ranks >= count && std::has_single_bit(static_cast<unsigned>(ranks)); }, | ||
| std::format("a power-of-two rank count of at least {}", count)); | ||
| } | ||
|
|
||
| /// Requires an even rank count, so that `rank ^ 1` pairs every rank. | ||
| inline auto even_ranks() -> boost::unit_test::decorator::precondition { | ||
| return rank_detail::world_size_precondition([](int ranks) { return ranks >= 2 && ranks % 2 == 0; }, | ||
| "an even rank count"); | ||
| } | ||
|
|
||
| /// Requires monoprop_ROUTING to resolve to linear routing. | ||
| inline auto linear_routing() -> boost::unit_test::decorator::precondition { | ||
| return boost::unit_test::precondition([](boost::unit_test::test_unit_id) { | ||
| boost::test_tools::assertion_result result(monoprop::routing::linear_requested()); | ||
| result.message() << "needs linear routing, but monoprop_ROUTING selects splitmix"; | ||
| return result; | ||
| }); | ||
| } | ||
|
|
||
| /// Requires monoprop_ROUTING to be unset, so that the shipped default is what runs. | ||
| inline auto default_routing() -> boost::unit_test::decorator::precondition { | ||
| return boost::unit_test::precondition([](boost::unit_test::test_unit_id) { | ||
| const char *mode = std::getenv("monoprop_ROUTING"); | ||
| boost::test_tools::assertion_result result(mode == nullptr || *mode == '\0'); | ||
| result.message() << "needs monoprop_ROUTING unset, but it is set"; | ||
| return result; | ||
| }); | ||
| } | ||
|
|
||
| } // namespace test_utils |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.