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
52860a57
Commit
52860a57
authored
4 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add CRSGraph tests
Also made a few cosmetic cleanups
parent
006a7f63
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!63
Feature/utils coverage
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/utils/CRSGraph.hpp
+10
-9
10 additions, 9 deletions
src/utils/CRSGraph.hpp
src/utils/Partitioner.cpp
+6
-3
6 additions, 3 deletions
src/utils/Partitioner.cpp
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/test_CRSGraph.cpp
+44
-0
44 additions, 0 deletions
tests/test_CRSGraph.cpp
with
61 additions
and
12 deletions
src/utils/CRSGraph.hpp
+
10
−
9
View file @
52860a57
...
@@ -6,8 +6,8 @@
...
@@ -6,8 +6,8 @@
class
CRSGraph
class
CRSGraph
{
{
private:
private:
Array
<
int
>
m_entries
;
Array
<
const
int
>
m_entries
;
Array
<
int
>
m_neighbors
;
Array
<
const
int
>
m_neighbors
;
public:
public:
size_t
size_t
...
@@ -17,29 +17,30 @@ class CRSGraph
...
@@ -17,29 +17,30 @@ class CRSGraph
return
m_entries
.
size
()
-
1
;
return
m_entries
.
size
()
-
1
;
}
}
const
Array
<
int
>&
const
Array
<
const
int
>&
entries
()
const
entries
()
const
{
{
return
m_entries
;
return
m_entries
;
}
}
const
Array
<
int
>&
const
Array
<
const
int
>&
neighbors
()
const
neighbors
()
const
{
{
return
m_neighbors
;
return
m_neighbors
;
}
}
CRSGraph
&
operator
=
(
CRSGraph
&&
)
=
de
fault
;
CRSGraph
&
operator
=
(
CRSGraph
&&
)
=
de
lete
;
CRSGraph
&
operator
=
(
const
CRSGraph
&
)
=
de
fault
;
CRSGraph
&
operator
=
(
const
CRSGraph
&
)
=
de
lete
;
CRSGraph
(
const
Array
<
int
>&
entries
,
const
Array
<
int
>&
neighbors
)
:
m_entries
(
entries
),
m_neighbors
(
neighbors
)
CRSGraph
(
const
Array
<
int
>&
entries
,
const
Array
<
int
>&
neighbors
)
:
m_entries
(
entries
),
m_neighbors
(
neighbors
)
{
{
Assert
(
m_entries
.
size
()
>
0
);
Assert
(
m_entries
.
size
()
>
0
);
Assert
(
static_cast
<
size_t
>
(
m_entries
[
m_entries
.
size
()
-
1
])
==
m_neighbors
.
size
());
}
}
CRSGraph
()
=
de
fault
;
CRSGraph
()
=
de
lete
;
CRSGraph
(
CRSGraph
&&
)
=
de
fault
;
CRSGraph
(
CRSGraph
&&
)
=
de
lete
;
CRSGraph
(
const
CRSGraph
&
)
=
de
fault
;
CRSGraph
(
const
CRSGraph
&
)
=
de
lete
;
~
CRSGraph
()
=
default
;
~
CRSGraph
()
=
default
;
};
};
...
...
This diff is collapsed.
Click to expand it.
src/utils/Partitioner.cpp
+
6
−
3
View file @
52860a57
...
@@ -57,11 +57,14 @@ Partitioner::partition(const CRSGraph& graph)
...
@@ -57,11 +57,14 @@ Partitioner::partition(const CRSGraph& graph)
part
=
Array
<
int
>
(
local_number_of_nodes
);
part
=
Array
<
int
>
(
local_number_of_nodes
);
std
::
vector
<
int
>
vtxdist
{
0
,
local_number_of_nodes
};
std
::
vector
<
int
>
vtxdist
{
0
,
local_number_of_nodes
};
const
Array
<
int
>&
entries
=
graph
.
entries
();
const
Array
<
const
int
>&
entries
=
graph
.
entries
();
const
Array
<
int
>&
neighbors
=
graph
.
neighbors
();
const
Array
<
const
int
>&
neighbors
=
graph
.
neighbors
();
int
*
entries_ptr
=
const_cast
<
int
*>
(
&
(
entries
[
0
]));
int
*
neighbors_ptr
=
const_cast
<
int
*>
(
&
(
neighbors
[
0
]));
int
result
=
int
result
=
ParMETIS_V3_PartKway
(
&
(
vtxdist
[
0
]),
&
(
entries
[
0
]),
&
(
neighbors
[
0
])
,
NULL
,
NULL
,
&
wgtflag
,
&
numflag
,
&
ncon
,
&
npart
,
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
);
&
(
tpwgts
[
0
]),
&
(
ubvec
[
0
]),
&
(
options
[
0
]),
&
edgecut
,
&
(
part
[
0
]),
&
parmetis_comm
);
if
(
result
==
METIS_ERROR
)
{
if
(
result
==
METIS_ERROR
)
{
throw
UnexpectedError
(
"Metis Error"
);
throw
UnexpectedError
(
"Metis Error"
);
...
...
This diff is collapsed.
Click to expand it.
tests/CMakeLists.txt
+
1
−
0
View file @
52860a57
...
@@ -52,6 +52,7 @@ add_executable (unit_tests
...
@@ -52,6 +52,7 @@ add_executable (unit_tests
test_CG.cpp
test_CG.cpp
test_ContinueProcessor.cpp
test_ContinueProcessor.cpp
test_ConcatExpressionProcessor.cpp
test_ConcatExpressionProcessor.cpp
test_CRSGraph.cpp
test_CRSMatrix.cpp
test_CRSMatrix.cpp
test_DataVariant.cpp
test_DataVariant.cpp
test_DoWhileProcessor.cpp
test_DoWhileProcessor.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/test_CRSGraph.cpp
0 → 100644
+
44
−
0
View file @
52860a57
#ifndef TEST_CRS_GRAPH_HPP
#define TEST_CRS_GRAPH_HPP
#include
<catch2/catch.hpp>
#include
<utils/CRSGraph.hpp>
// clazy:excludeall=non-pod-global-static
TEST_CASE
(
"CRSGraph"
,
"[utils]"
)
{
Array
<
int
>
entries
{
5
};
Array
<
int
>
neighbors
{
9
};
entries
[
0
]
=
0
;
neighbors
[
0
]
=
0
;
neighbors
[
1
]
=
1
;
entries
[
1
]
=
2
;
neighbors
[
2
]
=
1
;
neighbors
[
3
]
=
3
;
entries
[
2
]
=
4
;
neighbors
[
4
]
=
2
;
neighbors
[
5
]
=
1
;
neighbors
[
6
]
=
3
;
entries
[
3
]
=
7
;
neighbors
[
7
]
=
0
;
neighbors
[
8
]
=
1
;
entries
[
4
]
=
9
;
CRSGraph
graph
(
entries
,
neighbors
);
REQUIRE
(
graph
.
numberOfNodes
()
==
4
);
REQUIRE
(
entries
.
size
()
==
graph
.
entries
().
size
());
REQUIRE
(
&
entries
[
0
]
==
&
graph
.
entries
()[
0
]);
REQUIRE
(
neighbors
.
size
()
==
graph
.
neighbors
().
size
());
REQUIRE
(
&
neighbors
[
0
]
==
&
graph
.
neighbors
()[
0
]);
}
#endif // TEST_CRS_GRAPH_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