From d1bae7e3e28fa7a6748bd1a36b2ccf7828ce27ce Mon Sep 17 00:00:00 2001 From: reiniscirpons Date: Mon, 9 Dec 2024 15:14:06 +0000 Subject: [PATCH] Fix test issue on platforms with less than 4 threads --- tests/test-sims.cpp | 168 ++++++++++++++++++++++++++------------------ 1 file changed, 100 insertions(+), 68 deletions(-) diff --git a/tests/test-sims.cpp b/tests/test-sims.cpp index 1a62a1b8b..45c785288 100644 --- a/tests/test-sims.cpp +++ b/tests/test-sims.cpp @@ -4578,25 +4578,29 @@ namespace libsemigroups { == fmt::format( "", to_human_readable_repr(p))); - sims1.number_of_threads(4); - sims2.number_of_threads(4); - rep_orc.number_of_threads(4); - minimal_rep_orc.number_of_threads(4); + sims1.number_of_threads(std::thread::hardware_concurrency()); + sims2.number_of_threads(std::thread::hardware_concurrency()); + rep_orc.number_of_threads(std::thread::hardware_concurrency()); + minimal_rep_orc.number_of_threads(std::thread::hardware_concurrency()); REQUIRE(to_human_readable_repr(sims1) - == fmt::format("", - to_human_readable_repr(p))); + == fmt::format("", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(sims2) - == fmt::format("", - to_human_readable_repr(p))); + == fmt::format("", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(rep_orc) == fmt::format("", - to_human_readable_repr(p))); + "target size 0 and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE( to_human_readable_repr(minimal_rep_orc) == fmt::format( - "", - to_human_readable_repr(p))); + "", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); sims1.include(01_w, 10_w); sims1.include(010_w, 101_w); sims2.include(01_w, 10_w); @@ -4607,21 +4611,25 @@ namespace libsemigroups { minimal_rep_orc.include(010_w, 101_w); REQUIRE(to_human_readable_repr(sims1) == fmt::format( - "", - to_human_readable_repr(p))); + "", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(sims2) == fmt::format( - "", - to_human_readable_repr(p))); + "", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(rep_orc) == fmt::format("", - to_human_readable_repr(p))); + "target size 0 and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(minimal_rep_orc) == fmt::format("", - to_human_readable_repr(p))); + "pairs, target size 0 and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); sims1.clear_include(); sims2.clear_include(); rep_orc.clear_include(); @@ -4632,22 +4640,26 @@ namespace libsemigroups { minimal_rep_orc.exclude(11_w, 10_w); REQUIRE(to_human_readable_repr(sims1) == fmt::format( - "", - to_human_readable_repr(p))); + "", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(sims2) == fmt::format( - "", - to_human_readable_repr(p))); + "", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE( to_human_readable_repr(rep_orc) == fmt::format( "", - to_human_readable_repr(p))); + "target size 0 and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(minimal_rep_orc) == fmt::format("", - to_human_readable_repr(p))); + "pair, target size 0 and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); sims1.include(01_w, 10_w); sims1.include(010_w, 101_w); sims2.include(01_w, 10_w); @@ -4658,22 +4670,26 @@ namespace libsemigroups { minimal_rep_orc.include(010_w, 101_w); REQUIRE(to_human_readable_repr(sims1) == fmt::format("", - to_human_readable_repr(p))); + "pairs and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(sims2) == fmt::format("", - to_human_readable_repr(p))); + "pairs and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(rep_orc) == fmt::format("", - to_human_readable_repr(p))); + "target size 0 and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(minimal_rep_orc) == fmt::format( "", - to_human_readable_repr(p))); + "pairs, target size 0 and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); std::vector forbid = {0_w, 01_w, 00_w, ""_w}; SimsRefinerFaithful pruno(forbid); @@ -4683,22 +4699,26 @@ namespace libsemigroups { minimal_rep_orc.add_pruner(pruno); REQUIRE(to_human_readable_repr(sims1) == fmt::format("", - to_human_readable_repr(p))); + "pairs, 1 pruner and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(sims2) == fmt::format("", - to_human_readable_repr(p))); + "pairs, 1 pruner and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(rep_orc) == fmt::format("", - to_human_readable_repr(p))); + "target size 0, 1 pruner and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(minimal_rep_orc) == fmt::format( "", - to_human_readable_repr(p))); + "pairs, target size 0, 1 pruner and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); SimsRefinerIdeals ideal_pruner(p); sims1.add_pruner(ideal_pruner); sims2.add_pruner(ideal_pruner); @@ -4706,22 +4726,26 @@ namespace libsemigroups { minimal_rep_orc.add_pruner(ideal_pruner); REQUIRE(to_human_readable_repr(sims1) == fmt::format("", - to_human_readable_repr(p))); + "pairs, 2 pruners and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(sims2) == fmt::format("", - to_human_readable_repr(p))); + "pairs, 2 pruners and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(rep_orc) == fmt::format("", - to_human_readable_repr(p))); + "target size 0, 2 pruners and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(minimal_rep_orc) == fmt::format( "", - to_human_readable_repr(p))); + "pairs, target size 0, 2 pruners and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); sims1.clear_exclude(); sims2.clear_exclude(); rep_orc.clear_exclude(); @@ -4736,44 +4760,52 @@ namespace libsemigroups { minimal_rep_orc.add_pruner(pruno); REQUIRE(to_human_readable_repr(sims1) == fmt::format("", - to_human_readable_repr(p))); + "pruner and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(sims2) == fmt::format("", - to_human_readable_repr(p))); + "pruner and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE( to_human_readable_repr(rep_orc) == fmt::format( "", - to_human_readable_repr(p))); + "target size 0, 1 pruner and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(minimal_rep_orc) == fmt::format("", - to_human_readable_repr(p))); + "pairs, target size 0, 1 pruner and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); sims1.add_pruner(ideal_pruner); sims2.add_pruner(ideal_pruner); rep_orc.add_pruner(ideal_pruner); minimal_rep_orc.add_pruner(ideal_pruner); REQUIRE(to_human_readable_repr(sims1) == fmt::format("", - to_human_readable_repr(p))); + "pruners and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(sims2) == fmt::format("", - to_human_readable_repr(p))); + "pruners and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE( to_human_readable_repr(rep_orc) == fmt::format( "", - to_human_readable_repr(p))); + "target size 0, 2 pruners and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); REQUIRE(to_human_readable_repr(minimal_rep_orc) == fmt::format("", - to_human_readable_repr(p))); + "pairs, target size 0, 2 pruners and {} threads>", + to_human_readable_repr(p), + std::thread::hardware_concurrency())); } LIBSEMIGROUPS_TEST_CASE("Sims1",