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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
5fffc1a5
Commit
5fffc1a5
authored
Oct 19, 2018
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for allToAll calls
parent
92679dad
No related branches found
No related tags found
1 merge request
!11
Feature/mpi
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/mpi_test_Messenger.cpp
+80
-0
80 additions, 0 deletions
tests/mpi_test_Messenger.cpp
with
80 additions
and
0 deletions
tests/mpi_test_Messenger.cpp
+
80
−
0
View file @
5fffc1a5
...
@@ -14,6 +14,27 @@
...
@@ -14,6 +14,27 @@
namespace
mpi_check
namespace
mpi_check
{
{
struct
integer
{
int
m_int
;
operator
int
&
()
{
return
m_int
;}
operator
const
int
&
()
const
{
return
m_int
;}
integer
&
operator
=
(
const
int
&
i
)
{
m_int
=
i
;
return
*
this
;}
};
struct
tri_int
{
int
m_int_0
;
int
m_int_1
;
int
m_int_2
;
bool
operator
==
(
const
tri_int
&
t
)
const
{
return
((
m_int_0
==
t
.
m_int_0
)
and
(
m_int_1
==
t
.
m_int_1
)
and
(
m_int_2
==
t
.
m_int_2
));
}
};
template
<
typename
T
>
template
<
typename
T
>
void
test_allToAll
()
void
test_allToAll
()
{
{
...
@@ -27,6 +48,37 @@ void test_allToAll()
...
@@ -27,6 +48,37 @@ void test_allToAll()
REQUIRE
(
exchanged_array
[
i
]
==
i
);
REQUIRE
(
exchanged_array
[
i
]
==
i
);
}
}
}
}
template
<
>
void
test_allToAll
<
bool
>
()
{
Array
<
bool
>
data_array
(
commSize
());
for
(
size_t
i
=
0
;
i
<
data_array
.
size
();
++
i
)
{
data_array
[
i
]
=
((
commRank
()
%
2
)
==
0
);
}
auto
exchanged_array
=
allToAll
(
data_array
);
for
(
size_t
i
=
0
;
i
<
data_array
.
size
();
++
i
)
{
REQUIRE
(
exchanged_array
[
i
]
==
((
i
%
2
)
==
0
));
}
}
template
<
>
void
test_allToAll
<
tri_int
>
()
{
Array
<
tri_int
>
data_array
(
commSize
());
for
(
size_t
i
=
0
;
i
<
data_array
.
size
();
++
i
)
{
const
int
val
=
1
+
commRank
();
data_array
[
i
]
=
tri_int
{
val
,
2
*
val
,
val
+
3
};
}
auto
exchanged_array
=
allToAll
(
data_array
);
for
(
size_t
i
=
0
;
i
<
data_array
.
size
();
++
i
)
{
const
int
val
=
1
+
i
;
REQUIRE
(
exchanged_array
[
i
]
==
tri_int
{
val
,
2
*
val
,
val
+
3
});
}
}
}
}
TEST_CASE
(
"Messenger"
,
"[mpi]"
)
{
TEST_CASE
(
"Messenger"
,
"[mpi]"
)
{
...
@@ -42,6 +94,34 @@ TEST_CASE("Messenger", "[mpi]") {
...
@@ -42,6 +94,34 @@ TEST_CASE("Messenger", "[mpi]") {
}
}
SECTION
(
"allToAll"
)
{
SECTION
(
"allToAll"
)
{
// chars
mpi_check
::
test_allToAll
<
char
>
();
mpi_check
::
test_allToAll
<
wchar_t
>
();
// integers
mpi_check
::
test_allToAll
<
int8_t
>
();
mpi_check
::
test_allToAll
<
int8_t
>
();
mpi_check
::
test_allToAll
<
int16_t
>
();
mpi_check
::
test_allToAll
<
int32_t
>
();
mpi_check
::
test_allToAll
<
int64_t
>
();
mpi_check
::
test_allToAll
<
uint8_t
>
();
mpi_check
::
test_allToAll
<
uint16_t
>
();
mpi_check
::
test_allToAll
<
uint32_t
>
();
mpi_check
::
test_allToAll
<
uint64_t
>
();
mpi_check
::
test_allToAll
<
signed
long
long
int
>
();
mpi_check
::
test_allToAll
<
unsigned
long
long
int
>
();
// floats
mpi_check
::
test_allToAll
<
float
>
();
mpi_check
::
test_allToAll
<
double
>
();
mpi_check
::
test_allToAll
<
long
double
>
();
// bools
mpi_check
::
test_allToAll
<
bool
>
();
// trivial simple type
mpi_check
::
test_allToAll
<
mpi_check
::
integer
>
();
// compound trivial type
mpi_check
::
test_allToAll
<
mpi_check
::
tri_int
>
();
}
}
}
}
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