Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
c3f29d20
Commit
c3f29d20
authored
4 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add Partitioner tests
parent
fdab3fbc
No related branches found
No related tags found
1 merge request
!63
Feature/utils coverage
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/utils/Partitioner.cpp
+7
-3
7 additions, 3 deletions
src/utils/Partitioner.cpp
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/test_Partitioner.cpp
+91
-0
91 additions, 0 deletions
tests/test_Partitioner.cpp
with
99 additions
and
3 deletions
src/utils/Partitioner.cpp
+
7
−
3
View file @
c3f29d20
...
...
@@ -26,7 +26,7 @@ Partitioner::partition(const CRSGraph& graph)
std
::
vector
<
float
>
tpwgts
(
npart
,
1.
/
npart
);
std
::
vector
<
float
>
ubvec
{
1.05
};
std
::
vector
<
int
>
options
{
1
,
1
,
0
};
std
::
vector
<
int
>
options
{
1
,
0
,
0
};
int
edgecut
=
0
;
Array
<
int
>
part
(
0
);
...
...
@@ -66,9 +66,11 @@ Partitioner::partition(const CRSGraph& graph)
int
result
=
ParMETIS_V3_PartKway
(
&
(
vtxdist
[
0
]),
entries_ptr
,
neighbors_ptr
,
NULL
,
NULL
,
&
wgtflag
,
&
numflag
,
&
ncon
,
&
npart
,
&
(
tpwgts
[
0
]),
&
(
ubvec
[
0
]),
&
(
options
[
0
]),
&
edgecut
,
&
(
part
[
0
]),
&
parmetis_comm
);
// LCOV_EXCL_START
if
(
result
==
METIS_ERROR
)
{
throw
UnexpectedError
(
"Metis Error"
);
}
// LCOV_EXCL_STOP
MPI_Comm_free
(
&
parmetis_comm
);
}
...
...
@@ -81,9 +83,11 @@ Partitioner::partition(const CRSGraph& graph)
#else // PUGS_HAS_MPI
Array
<
int
>
Partitioner
::
partition
(
const
CRSGraph
&
)
Partitioner
::
partition
(
const
CRSGraph
&
graph
)
{
return
Array
<
int
>
(
0
);
Array
<
int
>
partition
{
graph
.
entries
().
size
()
-
1
};
partition
.
fill
(
0
);
return
partition
;
}
#endif // PUGS_HAS_MPI
This diff is collapsed.
Click to expand it.
tests/CMakeLists.txt
+
1
−
0
View file @
c3f29d20
...
...
@@ -94,6 +94,7 @@ add_executable (unit_tests
add_executable
(
mpi_unit_tests
mpi_test_main.cpp
test_Messenger.cpp
test_Partitioner.cpp
)
add_library
(
test_Pugs_MeshDataBase
...
...
This diff is collapsed.
Click to expand it.
tests/test_Partitioner.cpp
0 → 100644
+
91
−
0
View file @
c3f29d20
#ifndef TEST_PARTITIONER_HPP
#define TEST_PARTITIONER_HPP
#include
<catch2/catch.hpp>
#include
<utils/Messenger.hpp>
#include
<utils/Partitioner.hpp>
#include
<set>
// clazy:excludeall=non-pod-global-static
TEST_CASE
(
"Partitioner"
,
"[utils]"
)
{
SECTION
(
"one graph split to all"
)
{
Partitioner
partitioner
;
std
::
vector
<
int
>
entries_vector
;
std
::
vector
<
int
>
neighbors_vector
;
entries_vector
.
push_back
(
neighbors_vector
.
size
());
if
(
parallel
::
rank
()
==
0
)
{
neighbors_vector
.
push_back
(
1
);
neighbors_vector
.
push_back
(
2
);
neighbors_vector
.
push_back
(
4
);
entries_vector
.
push_back
(
neighbors_vector
.
size
());
neighbors_vector
.
push_back
(
0
);
neighbors_vector
.
push_back
(
3
);
neighbors_vector
.
push_back
(
5
);
entries_vector
.
push_back
(
neighbors_vector
.
size
());
neighbors_vector
.
push_back
(
0
);
neighbors_vector
.
push_back
(
2
);
neighbors_vector
.
push_back
(
5
);
entries_vector
.
push_back
(
neighbors_vector
.
size
());
neighbors_vector
.
push_back
(
0
);
neighbors_vector
.
push_back
(
2
);
neighbors_vector
.
push_back
(
5
);
entries_vector
.
push_back
(
neighbors_vector
.
size
());
neighbors_vector
.
push_back
(
3
);
neighbors_vector
.
push_back
(
5
);
neighbors_vector
.
push_back
(
7
);
entries_vector
.
push_back
(
neighbors_vector
.
size
());
neighbors_vector
.
push_back
(
3
);
neighbors_vector
.
push_back
(
5
);
neighbors_vector
.
push_back
(
6
);
entries_vector
.
push_back
(
neighbors_vector
.
size
());
neighbors_vector
.
push_back
(
5
);
neighbors_vector
.
push_back
(
6
);
neighbors_vector
.
push_back
(
7
);
entries_vector
.
push_back
(
neighbors_vector
.
size
());
neighbors_vector
.
push_back
(
3
);
neighbors_vector
.
push_back
(
5
);
neighbors_vector
.
push_back
(
7
);
entries_vector
.
push_back
(
neighbors_vector
.
size
());
neighbors_vector
.
push_back
(
4
);
neighbors_vector
.
push_back
(
6
);
neighbors_vector
.
push_back
(
7
);
entries_vector
.
push_back
(
neighbors_vector
.
size
());
}
Array
<
int
>
entries
=
convert_to_array
(
entries_vector
);
Array
<
int
>
neighbors
=
convert_to_array
(
neighbors_vector
);
CRSGraph
graph
{
entries
,
neighbors
};
Array
<
int
>
partitioned
=
partitioner
.
partition
(
graph
);
REQUIRE
((
partitioned
.
size
()
+
1
)
==
entries
.
size
());
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
());
}
}
}
#endif // TEST_PARTITIONER_HPP
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment