Commit 1bc9267d authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Extract test code to mirror Fortran version.

parent dffddc00
Pipeline #2400 passed with stages
in 38 seconds
......@@ -56,6 +56,12 @@
#include "tests.h"
#include "test_redist_common.h"
static void
simple_test(MPI_Comm comm);
static void
test_repeated_redist(MPI_Comm comm);
int main(void) {
// init mpi
......@@ -64,7 +70,17 @@ int main(void) {
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
enum { src_slice_len = 5, dst_slice_len = 3 };
Xt_xmap xmap = build_odd_selection_xmap(src_slice_len);
......@@ -75,23 +91,20 @@ int main(void) {
// 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);
Xt_redist redist_coll
= xt_redist_collection_static_new(&redist, 1, displacements,
displacements, comm);
// test communicator of redist
if (!communicators_are_congruent(xt_redist_get_MPI_Comm(redist_coll),
MPI_COMM_WORLD))
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 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]) };
......@@ -102,11 +115,12 @@ int main(void) {
ref_dst_data, MPI_DOUBLE, MPI_DOUBLE);
// clean up
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
enum { src_slice_len = 5,
dst_slice_len = (src_slice_len+1)/2 };
......@@ -129,18 +143,15 @@ int main(void) {
Xt_redist redist_coll
= xt_redist_collection_static_new(redists, 3, src_displacements,
dst_displacements, MPI_COMM_WORLD);
dst_displacements, comm);
// test communicator of redist
if (!communicators_are_congruent(xt_redist_get_MPI_Comm(redist_coll),
MPI_COMM_WORLD))
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]),
......@@ -148,16 +159,10 @@ int main(void) {
ref_dst_data, MPI_DOUBLE, MPI_DOUBLE);
// clean up
xt_redist_delete(redist_coll);
}
xt_finalize();
MPI_Finalize();
return TEST_EXIT_CODE;
}
/*
* Local Variables:
* c-basic-offset: 2
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment