Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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
Hide 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,100 +70,99 @@ int main(void) {
...
@@ -64,100 +70,99 @@ int main(void) {
xt_initialize
(
MPI_COMM_WORLD
);
xt_initialize
(
MPI_COMM_WORLD
);
{
// general test with one redist
simple_test
(
MPI_COMM_WORLD
);
// set up data
enum
{
src_slice_len
=
5
,
dst_slice_len
=
3
};
Xt_xmap
xmap
=
build_odd_selection_xmap
(
src_slice_len
);
Xt_redist
redist
=
xt_redist_p2p_new
(
xmap
,
MPI_DOUBLE
);
xt_xmap_delete
(
xmap
);
// generate redist_collection
Xt_redist
redist_coll
;
static
const
MPI_Aint
displacements
[
1
]
=
{
0
};
redist_coll
=
xt_redist_collection_static_new
(
&
redist
,
1
,
displacements
,
displacements
,
MPI_COMM_WORLD
);
// test communicator of redist
if
(
!
communicators_are_congruent
(
xt_redist_get_MPI_Comm
(
redist_coll
),
MPI_COMM_WORLD
))
PUT_ERR
(
"error in xt_redist_get_MPI_Comm
\n
"
);
xt_redist_delete
(
redist
);
// test exchange
static
const
double
src_data
[]
=
{
1
,
2
,
3
,
4
,
5
};
xt_finalize
();
static
const
double
ref_dst_data
[]
=
{
1
,
3
,
5
};
MPI_Finalize
();
enum
{
num_dst_elems
=
sizeof
(
ref_dst_data
)
/
sizeof
(
ref_dst_data
[
0
])
};
double
dst_data
[
num_dst_elems
];
check_redist
(
redist_coll
,
src_data
,
num_dst_elems
,
dst_data
,
fill_array_double
,
NULL
,
ref_dst_data
,
MPI_DOUBLE
,
MPI_DOUBLE
);
// clean up
xt_redist_delete
(
redist_coll
)
;
return
TEST_EXIT_CODE
;
}
}
{
// test with one redist used three times (two exchanges)
static
void
// set up data
simple_test
(
MPI_Comm
comm
)
enum
{
src_slice_len
=
5
,
{
// general test with one redist
dst_slice_len
=
(
src_slice_len
+
1
)
/
2
};
// set up data
Xt_xmap
xmap
=
build_odd_selection_xmap
(
5
)
;
enum
{
src_slice_len
=
5
,
dst_slice_len
=
3
}
;
Xt_
redist
redist
=
xt_redist_p2p_new
(
xmap
,
MPI_DOUBLE
);
Xt_
xmap
xmap
=
build_odd_selection_xmap
(
src_slice_len
);
xt_xmap_delete
(
xmap
);
Xt_redist
redist
=
xt_redist_p2p_new
(
xmap
,
MPI_DOUBLE
);
// generate redist_collection
xt_xmap_delete
(
xmap
);
Xt_redist
redists
[
3
]
=
{
redist
,
redist
,
redist
};
static
const
double
src_data
[
3
][
src_slice_len
]
=
{{
1
,
2
,
3
,
4
,
5
},{
6
,
7
,
8
,
9
,
10
},{
11
,
12
,
13
,
14
,
15
}};
double
dst_data
[
3
][
3
];
MPI_Aint
src_displacements
[
3
]
=
{
0
,
(
MPI_Aint
)((
size_t
)(
src_data
[
1
]
-
src_data
[
0
])
*
sizeof
(
double
)),
(
MPI_Aint
)((
size_t
)(
src_data
[
2
]
-
src_data
[
0
])
*
sizeof
(
double
))
};
MPI_Aint
dst_displacements
[
3
]
=
{
0
,
(
MPI_Aint
)((
size_t
)(
dst_data
[
1
]
-
dst_data
[
0
])
*
sizeof
(
double
)),
(
MPI_Aint
)((
size_t
)(
dst_data
[
2
]
-
dst_data
[
0
])
*
sizeof
(
double
))
};
Xt_redist
redist_coll
// generate redist_collection
=
xt_redist_collection_static_new
(
redists
,
3
,
src_displacements
,
dst_displacements
,
MPI_COMM_WORLD
);
// test communicator of redist
static
const
MPI_Aint
displacements
[
1
]
=
{
0
};
if
(
!
communicators_are_congruent
(
xt_redist_get_MPI_Comm
(
redist_coll
),
Xt_redist
redist_coll
MPI_COMM_WORLD
))
=
xt_redist_collection_static_new
(
&
redist
,
1
,
displacements
,
PUT_ERR
(
"error in xt_redist_get_MPI_Comm
\n
"
);
displacements
,
comm
);
xt_redist_delete
(
redist
);
// test communicator of
redist
// test exchange
if
(
!
communicators_are_congruent
(
xt_redist_get_MPI_Comm
(
redist_coll
),
comm
))
PUT_ERR
(
"error in xt_redist_get_MPI_Comm
\n
"
);
static
const
double
ref_dst_data
[
3
][
3
]
=
{{
1
,
3
,
5
},{
6
,
8
,
10
},{
11
,
13
,
15
}};
xt_redist_delete
(
redist
);
check_redist
(
redist_coll
,
src_data
,
sizeof
(
dst_data
)
/
sizeof
(
dst_data
[
0
][
0
]),
dst_data
,
fill_array_double
,
NULL
,
ref_dst_data
,
MPI_DOUBLE
,
MPI_DOUBLE
);
// clean up
// test exchange
static
const
double
src_data
[]
=
{
1
,
2
,
3
,
4
,
5
};
static
const
double
ref_dst_data
[]
=
{
1
,
3
,
5
};
enum
{
num_dst_elems
=
sizeof
(
ref_dst_data
)
/
sizeof
(
ref_dst_data
[
0
])
};
xt_redist_delete
(
redist_coll
);
double
dst_data
[
num_dst_elems
];
}
check_redist
(
redist_coll
,
src_data
,
num_dst_elems
,
dst_data
,
fill_array_double
,
NULL
,
ref_dst_data
,
MPI_DOUBLE
,
MPI_DOUBLE
);
xt_finalize
();
// clean up
MPI_Finalize
();
xt_redist_delete
(
redist_coll
);
}
return
TEST_EXIT_CODE
;
static
void
test_repeated_redist
(
MPI_Comm
comm
)
{
// test with one redist used three times (two exchanges)
// set up data
enum
{
src_slice_len
=
5
,
dst_slice_len
=
(
src_slice_len
+
1
)
/
2
};
Xt_xmap
xmap
=
build_odd_selection_xmap
(
5
);
Xt_redist
redist
=
xt_redist_p2p_new
(
xmap
,
MPI_DOUBLE
);
xt_xmap_delete
(
xmap
);
// generate redist_collection
Xt_redist
redists
[
3
]
=
{
redist
,
redist
,
redist
};
static
const
double
src_data
[
3
][
src_slice_len
]
=
{{
1
,
2
,
3
,
4
,
5
},{
6
,
7
,
8
,
9
,
10
},{
11
,
12
,
13
,
14
,
15
}};
double
dst_data
[
3
][
3
];
MPI_Aint
src_displacements
[
3
]
=
{
0
,
(
MPI_Aint
)((
size_t
)(
src_data
[
1
]
-
src_data
[
0
])
*
sizeof
(
double
)),
(
MPI_Aint
)((
size_t
)(
src_data
[
2
]
-
src_data
[
0
])
*
sizeof
(
double
))
};
MPI_Aint
dst_displacements
[
3
]
=
{
0
,
(
MPI_Aint
)((
size_t
)(
dst_data
[
1
]
-
dst_data
[
0
])
*
sizeof
(
double
)),
(
MPI_Aint
)((
size_t
)(
dst_data
[
2
]
-
dst_data
[
0
])
*
sizeof
(
double
))
};
Xt_redist
redist_coll
=
xt_redist_collection_static_new
(
redists
,
3
,
src_displacements
,
dst_displacements
,
comm
);
// test communicator of redist
if
(
!
communicators_are_congruent
(
xt_redist_get_MPI_Comm
(
redist_coll
),
comm
))
PUT_ERR
(
"error in xt_redist_get_MPI_Comm
\n
"
);
xt_redist_delete
(
redist
);
// test exchange
static
const
double
ref_dst_data
[
3
][
3
]
=
{{
1
,
3
,
5
},{
6
,
8
,
10
},{
11
,
13
,
15
}};
check_redist
(
redist_coll
,
src_data
,
sizeof
(
dst_data
)
/
sizeof
(
dst_data
[
0
][
0
]),
dst_data
,
fill_array_double
,
NULL
,
ref_dst_data
,
MPI_DOUBLE
,
MPI_DOUBLE
);
// clean up
xt_redist_delete
(
redist_coll
);
}
}
/*
/*
* Local Variables:
* Local Variables:
* c-basic-offset: 2
* c-basic-offset: 2
...
...
Write
Preview
Markdown
is supported
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