Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Jahns
yaxt
Commits
1bc9267d
Commit
1bc9267d
authored
Mar 23, 2020
by
Thomas Jahns
🤸
Browse files
Extract test code to mirror Fortran version.
parent
dffddc00
Pipeline
#2400
passed with stages
in 38 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
tests/test_redist_collection_static.c
View file @
1bc9267d
...
@@ -56,6 +56,12 @@
...
@@ -56,6 +56,12 @@
#include
"tests.h"
#include
"tests.h"
#include
"test_redist_common.h"
#include
"test_redist_common.h"
static
void
simple_test
(
MPI_Comm
comm
);
static
void
test_repeated_redist
(
MPI_Comm
comm
);
int
main
(
void
)
{
int
main
(
void
)
{
// init mpi
// init mpi
...
@@ -64,7 +70,17 @@ int main(void) {
...
@@ -64,7 +70,17 @@ int main(void) {
xt_initialize
(
MPI_COMM_WORLD
);
xt_initialize
(
MPI_COMM_WORLD
);
{
// general test with one redist
simple_test
(
MPI_COMM_WORLD
);
xt_finalize
();
MPI_Finalize
();
return
TEST_EXIT_CODE
;
}
static
void
simple_test
(
MPI_Comm
comm
)
{
// general test with one redist
// set up data
// set up data
enum
{
src_slice_len
=
5
,
dst_slice_len
=
3
};
enum
{
src_slice_len
=
5
,
dst_slice_len
=
3
};
Xt_xmap
xmap
=
build_odd_selection_xmap
(
src_slice_len
);
Xt_xmap
xmap
=
build_odd_selection_xmap
(
src_slice_len
);
...
@@ -75,23 +91,20 @@ int main(void) {
...
@@ -75,23 +91,20 @@ int main(void) {
// generate redist_collection
// generate redist_collection
Xt_redist
redist_coll
;
static
const
MPI_Aint
displacements
[
1
]
=
{
0
};
static
const
MPI_Aint
displacements
[
1
]
=
{
0
};
redist
_coll
=
xt_redist_collection_static_new
(
&
redist
,
1
,
displacements
,
Xt_
redist
redist_coll
displacements
,
=
xt_redist_collection_static_new
(
&
redist
,
1
,
displacements
,
MPI_COMM_WORLD
);
displacements
,
comm
);
// test communicator of redist
// test communicator of redist
if
(
!
communicators_are_congruent
(
xt_redist_get_MPI_Comm
(
redist_coll
),
if
(
!
communicators_are_congruent
(
xt_redist_get_MPI_Comm
(
redist_coll
),
comm
))
MPI_COMM_WORLD
))
PUT_ERR
(
"error in xt_redist_get_MPI_Comm
\n
"
);
PUT_ERR
(
"error in xt_redist_get_MPI_Comm
\n
"
);
xt_redist_delete
(
redist
);
xt_redist_delete
(
redist
);
// test exchange
// test exchange
static
const
double
src_data
[]
=
{
1
,
2
,
3
,
4
,
5
};
static
const
double
src_data
[]
=
{
1
,
2
,
3
,
4
,
5
};
static
const
double
ref_dst_data
[]
=
{
1
,
3
,
5
};
static
const
double
ref_dst_data
[]
=
{
1
,
3
,
5
};
enum
{
num_dst_elems
=
sizeof
(
ref_dst_data
)
/
sizeof
(
ref_dst_data
[
0
])
};
enum
{
num_dst_elems
=
sizeof
(
ref_dst_data
)
/
sizeof
(
ref_dst_data
[
0
])
};
...
@@ -102,11 +115,12 @@ int main(void) {
...
@@ -102,11 +115,12 @@ int main(void) {
ref_dst_data
,
MPI_DOUBLE
,
MPI_DOUBLE
);
ref_dst_data
,
MPI_DOUBLE
,
MPI_DOUBLE
);
// clean up
// clean up
xt_redist_delete
(
redist_coll
);
xt_redist_delete
(
redist_coll
);
}
}
{
// test with one redist used three times (two exchanges)
static
void
test_repeated_redist
(
MPI_Comm
comm
)
{
// test with one redist used three times (two exchanges)
// set up data
// set up data
enum
{
src_slice_len
=
5
,
enum
{
src_slice_len
=
5
,
dst_slice_len
=
(
src_slice_len
+
1
)
/
2
};
dst_slice_len
=
(
src_slice_len
+
1
)
/
2
};
...
@@ -129,18 +143,15 @@ int main(void) {
...
@@ -129,18 +143,15 @@ int main(void) {
Xt_redist
redist_coll
Xt_redist
redist_coll
=
xt_redist_collection_static_new
(
redists
,
3
,
src_displacements
,
=
xt_redist_collection_static_new
(
redists
,
3
,
src_displacements
,
dst_displacements
,
MPI_COMM_WORLD
);
dst_displacements
,
comm
);
// test communicator of redist
// test communicator of redist
if
(
!
communicators_are_congruent
(
xt_redist_get_MPI_Comm
(
redist_coll
),
comm
))
if
(
!
communicators_are_congruent
(
xt_redist_get_MPI_Comm
(
redist_coll
),
MPI_COMM_WORLD
))
PUT_ERR
(
"error in xt_redist_get_MPI_Comm
\n
"
);
PUT_ERR
(
"error in xt_redist_get_MPI_Comm
\n
"
);
xt_redist_delete
(
redist
);
xt_redist_delete
(
redist
);
// test exchange
// test exchange
static
const
double
ref_dst_data
[
3
][
3
]
=
{{
1
,
3
,
5
},{
6
,
8
,
10
},{
11
,
13
,
15
}};
static
const
double
ref_dst_data
[
3
][
3
]
=
{{
1
,
3
,
5
},{
6
,
8
,
10
},{
11
,
13
,
15
}};
check_redist
(
redist_coll
,
src_data
,
check_redist
(
redist_coll
,
src_data
,
sizeof
(
dst_data
)
/
sizeof
(
dst_data
[
0
][
0
]),
sizeof
(
dst_data
)
/
sizeof
(
dst_data
[
0
][
0
]),
...
@@ -148,16 +159,10 @@ int main(void) {
...
@@ -148,16 +159,10 @@ int main(void) {
ref_dst_data
,
MPI_DOUBLE
,
MPI_DOUBLE
);
ref_dst_data
,
MPI_DOUBLE
,
MPI_DOUBLE
);
// clean up
// clean up
xt_redist_delete
(
redist_coll
);
xt_redist_delete
(
redist_coll
);
}
xt_finalize
();
MPI_Finalize
();
return
TEST_EXIT_CODE
;
}
}
/*
/*
* Local Variables:
* Local Variables:
* c-basic-offset: 2
* c-basic-offset: 2
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment