Skip to content
Snippets Groups Projects
Commit bb50b9a6 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Begin unit tests writing for load balancing

parent d99bcb67
No related branches found
No related tags found
1 merge request!204Remove m_cell_global_index from Connectivity
......@@ -15,8 +15,10 @@ Partitioner::partition(const CRSGraph& graph)
case PartitionerLibrary::ptscotch: {
return PTScotchPartitioner::partition(graph);
}
// LCOV_EXCL_START
default: {
throw UnexpectedError("invalid partition library");
}
// LCOV_EXCL_STOP
}
}
......@@ -29,7 +29,7 @@ name(const PartitionerLibrary library)
case PartitionerLibrary::PT__end: {
}
}
throw UnexpectedError("Linear system library name is not defined!");
throw UnexpectedError("Partitioner library name is not defined!");
}
template <typename PartitionerEnumType>
......@@ -43,7 +43,9 @@ getPartitionerEnumFromName(const std::string& enum_name)
return PartitionerEnumType{enum_value};
}
}
throw NormalError(std::string{"could not find '"} + enum_name + "' associate type!");
// LCOV_EXCL_START
throw UnexpectedError(std::string{"could not find '"} + enum_name + "' associate type!");
// LCOV_EXCL_STOP
}
class PartitionerOptions
......
......@@ -11,8 +11,6 @@ TEST_CASE("Partitioner", "[utils]")
{
SECTION("one graph split to all")
{
Partitioner partitioner;
std::vector<int> entries_vector;
std::vector<int> neighbors_vector;
......@@ -70,17 +68,54 @@ TEST_CASE("Partitioner", "[utils]")
CRSGraph graph{entries, neighbors};
Array<int> partitioned = partitioner.partition(graph);
SECTION("ParMETIS")
{
PartitionerOptions partitioner_options;
partitioner_options.library() = PartitionerLibrary::parmetis;
Partitioner partitioner{partitioner_options};
REQUIRE((partitioned.size() + 1) == entries.size());
Array<int> partitioned = partitioner.partition(graph);
if (parallel::rank() == 0) {
std::set<int> assigned_ranks;
for (size_t i = 0; i < partitioned.size(); ++i) {
assigned_ranks.insert(partitioned[i]);
REQUIRE((partitioned.size() + 1) == entries.size());
#ifdef PUGS_HAS_PARMETIS
if (parallel::rank() == 0) {
std::set<int> assigned_ranks;
for (size_t i = 0; i < partitioned.size(); ++i) {
assigned_ranks.insert(partitioned[i]);
}
REQUIRE(assigned_ranks.size() == parallel::size());
}
#else // PUGS_HAS_PARMETIS
REQUIRE(min(partitionned == 0));
REQUIRE(max(partitionned == 0));
#endif // PUGS_HAS_PARMETIS
}
REQUIRE(assigned_ranks.size() == parallel::size());
SECTION("PTScotch")
{
PartitionerOptions partitioner_options;
partitioner_options.library() = PartitionerLibrary::ptscotch;
Partitioner partitioner{partitioner_options};
Array<int> partitioned = partitioner.partition(graph);
REQUIRE((partitioned.size() + 1) == entries.size());
#ifdef PUGS_HAS_PTSCOTCH
if (parallel::rank() == 0) {
std::set<int> assigned_ranks;
for (size_t i = 0; i < partitioned.size(); ++i) {
assigned_ranks.insert(partitioned[i]);
}
REQUIRE(assigned_ranks.size() == parallel::size());
}
#else // PUGS_HAS_PTSCOTCH
REQUIRE(min(partitionned == 0));
REQUIRE(max(partitionned == 0));
#endif // PUGS_HAS_PTSCOTCH
}
}
}
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <utils/PartitionerOptions.hpp>
// clazy:excludeall=non-pod-global-static
TEST_CASE("PartitionerOptions", "[utils]")
{
SECTION("name")
{
REQUIRE(name(PartitionerLibrary::parmetis) == "ParMetis");
REQUIRE(name(PartitionerLibrary::ptscotch) == "PTScotch");
REQUIRE_THROWS_WITH(PartitionerLibrary::PT__end, "unexpected error: Partitioner library name is not defined!");
WARN("not finished");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment