18 TEST_CASE(
"test_communicate_split_one",
"[message]")
22 auto c2 = std::make_unique<Communicate>(*c, 1);
24 REQUIRE(c2->size() == c->size());
25 REQUIRE(c2->rank() == c->rank());
29 REQUIRE(c2->isGroupLeader() ==
true);
30 auto GroupLeaderComm = c2->getGroupLeaderComm();
31 REQUIRE(GroupLeaderComm !=
nullptr);
32 REQUIRE(GroupLeaderComm->size() == 1);
33 REQUIRE(GroupLeaderComm->rank() == 0);
37 REQUIRE(c2->isGroupLeader() ==
false);
38 REQUIRE(c2->getGroupLeaderComm() ==
nullptr);
41 std::string real_name = c->getName();
43 std::string name =
"myname";
47 std::string other_name =
"myothername";
48 c->setName(other_name.data(), other_name.size());
49 REQUIRE(c->getName() == other_name);
51 c->setName(real_name);
54 TEST_CASE(
"test_communicate_split_two",
"[message]")
59 auto c2 = std::make_unique<Communicate>(*c, 2);
61 std::vector<int> new_size(2);
62 new_size[0] = c->size() / 2;
63 new_size[1] = c->size() / 2;
65 int midpoint = c->size() / 2;
66 int new_group_id = c->rank() < midpoint ? 0 : 1;
67 int new_rank = c->rank();
68 if (c->rank() >= midpoint)
73 if (c->size() % 2 == 1)
75 new_size[1] = new_size[1] + 1;
77 REQUIRE(c2->size() == new_size[new_group_id]);
78 REQUIRE(c2->rank() == new_rank);
80 if (c->rank() == 0 || c->rank() == midpoint)
82 REQUIRE(c2->isGroupLeader() ==
true);
83 auto GroupLeaderComm = c2->getGroupLeaderComm();
84 REQUIRE(GroupLeaderComm !=
nullptr);
85 REQUIRE(GroupLeaderComm->size() == 2);
88 REQUIRE(GroupLeaderComm->rank() == 0);
92 REQUIRE(GroupLeaderComm->rank() == 1);
97 REQUIRE(c2->isGroupLeader() ==
false);
98 REQUIRE(c2->getGroupLeaderComm() ==
nullptr);
107 if (c->
size() % 4 == 0)
109 auto c2 = std::make_unique<Communicate>(*c, 4);
111 REQUIRE(c2->size() == c->size() / 4);
112 int group_size = c->size() / 4;
113 int new_rank = c->rank() % group_size;
114 REQUIRE(c2->rank() == new_rank);
118 REQUIRE(c2->isGroupLeader() ==
true);
119 auto GroupLeaderComm = c2->getGroupLeaderComm();
120 REQUIRE(GroupLeaderComm !=
nullptr);
121 REQUIRE(GroupLeaderComm->size() == 4);
122 REQUIRE(GroupLeaderComm->rank() == c->rank() / group_size);
126 REQUIRE(c2->isGroupLeader() ==
false);
127 REQUIRE(c2->getGroupLeaderComm() ==
nullptr);
helper functions for EinsplineSetBuilder
TEST_CASE("complex_helper", "[type_traits]")
Communicate * Controller
Global Communicator for a process.
int size() const
return the number of tasks
Wrapping information on parallelism.
REQUIRE(std::filesystem::exists(filename))