Commit 39a16447 authored by Moritz Hanke's avatar Moritz Hanke
Browse files

adds new xt_redist interface: xt_redist_get_MPI_Comm

parent bda7c00e
......@@ -107,4 +107,11 @@ MPI_Datatype xt_redist_get_send_MPI_Datatype(Xt_redist redist, int rank);
*/
MPI_Datatype xt_redist_get_recv_MPI_Datatype(Xt_redist redist, int rank);
/**
* returns a MPI communicator, which the redistribution is based on
* @param[in] redist redistribution structure
* \return MPI communicator, which the redistribution is based on
*/
MPI_Comm xt_redist_get_MPI_Comm(Xt_redist redist);
#endif // XT_REDIST_H
......@@ -73,3 +73,8 @@ MPI_Datatype xt_redist_get_recv_MPI_Datatype(Xt_redist redist, int rank) {
return redist->vtable->get_recv_MPI_Datatype(redist, rank);
}
MPI_Comm xt_redist_get_MPI_Comm(Xt_redist redist) {
return redist->vtable->get_MPI_Comm(redist);
}
......@@ -89,12 +89,16 @@ redist_collection_get_send_MPI_Datatype(Xt_redist redist, int rank);
static MPI_Datatype
redist_collection_get_recv_MPI_Datatype(Xt_redist redist, int rank);
static MPI_Comm
redist_collection_get_MPI_Comm(Xt_redist redist);
static const struct xt_redist_vtable redist_collection_vtable = {
.delete = redist_collection_delete,
.s_exchange = redist_collection_s_exchange,
.s_exchange1 = redist_collection_s_exchange1,
.get_send_MPI_Datatype = redist_collection_get_send_MPI_Datatype,
.get_recv_MPI_Datatype = redist_collection_get_recv_MPI_Datatype
.get_recv_MPI_Datatype = redist_collection_get_recv_MPI_Datatype,
.get_MPI_Comm = redist_collection_get_MPI_Comm
};
struct redist_collection_msg {
......@@ -533,3 +537,11 @@ redist_collection_s_exchange1(Xt_redist redist, void *src_data, void *dst_data)
Xt_abort(redist_coll->comm, "ERROR: s_exchange1 is not implemented for"
" this xt_redist type (Xt_redist_collection)", __FILE__, __LINE__);
}
static MPI_Comm
redist_collection_get_MPI_Comm(Xt_redist redist) {
Xt_redist_collection redist_coll = xrc(redist);
return redist_coll->comm;
}
......@@ -71,12 +71,16 @@ redist_collection_static_get_send_MPI_Datatype(Xt_redist redist, int rank);
static MPI_Datatype
redist_collection_static_get_recv_MPI_Datatype(Xt_redist redist, int rank);
static MPI_Comm
redist_collection_static_get_MPI_Comm(Xt_redist redist);
static const struct xt_redist_vtable redist_collection_static_vtable = {
.delete = redist_collection_static_delete,
.s_exchange = redist_collection_static_s_exchange,
.s_exchange1 = redist_collection_static_s_exchange1,
.get_send_MPI_Datatype = redist_collection_static_get_send_MPI_Datatype,
.get_recv_MPI_Datatype = redist_collection_static_get_recv_MPI_Datatype
.get_recv_MPI_Datatype = redist_collection_static_get_recv_MPI_Datatype,
.get_MPI_Comm = redist_collection_static_get_MPI_Comm
};
struct redist_collection_static_msg {
......@@ -320,3 +324,11 @@ redist_collection_static_s_exchange1(Xt_redist redist, void *src_data, void *dst
free(recv_requests);
}
static MPI_Comm
redist_collection_static_get_MPI_Comm(Xt_redist redist) {
Xt_redist_collection_static redist_coll = xrcs(redist);
return redist_coll->comm;
}
......@@ -61,6 +61,7 @@ struct xt_redist_vtable {
void (*s_exchange1)(Xt_redist, void *, void *);
MPI_Datatype (*get_send_MPI_Datatype)(Xt_redist, int);
MPI_Datatype (*get_recv_MPI_Datatype)(Xt_redist, int);
MPI_Comm (*get_MPI_Comm)(Xt_redist);
};
struct Xt_redist_ {
......
......@@ -76,12 +76,16 @@ redist_p2p_get_send_MPI_Datatype(Xt_redist redist, int rank);
static MPI_Datatype
redist_p2p_get_recv_MPI_Datatype(Xt_redist redist, int rank);
static MPI_Comm
redist_p2p_get_MPI_Comm(Xt_redist redist);
static const struct xt_redist_vtable redist_p2p_vtable = {
.delete = redist_p2p_delete,
.s_exchange = redist_p2p_s_exchange,
.s_exchange1 = redist_p2p_s_exchange1,
.get_send_MPI_Datatype = redist_p2p_get_send_MPI_Datatype,
.get_recv_MPI_Datatype = redist_p2p_get_recv_MPI_Datatype
.get_recv_MPI_Datatype = redist_p2p_get_recv_MPI_Datatype,
.get_MPI_Comm = redist_p2p_get_MPI_Comm
};
struct Xt_redist_p2p_msg {
......@@ -583,3 +587,11 @@ redist_p2p_get_recv_MPI_Datatype(Xt_redist redist, int rank) {
return datatype_copy;
}
static MPI_Comm
redist_p2p_get_MPI_Comm(Xt_redist redist) {
Xt_redist_p2p redist_p2p = xrp2p(redist);
return redist_p2p->comm;
}
......@@ -52,6 +52,9 @@
static void
test_repeated_redist(int cache_size);
static int
test_communicator(MPI_Comm comm1, MPI_Comm comm2);
int main(void) {
// init mpi
......@@ -91,6 +94,11 @@ int main(void) {
redist_coll = xt_redist_collection_new(&redist, 1, -1, MPI_COMM_WORLD);
// test communicator of redist
if (!test_communicator(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
......@@ -158,6 +166,11 @@ int main(void) {
redist_coll = xt_redist_collection_new(redists, 3, -1, MPI_COMM_WORLD);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist_coll), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
xt_redist_delete(redist);
double src_data[3][5] = {{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15}};
......@@ -240,6 +253,11 @@ test_repeated_redist(int cache_size)
redist_coll = xt_redist_collection_new(redists, 3, cache_size, MPI_COMM_WORLD);
// test communicator of redist
if (!test_communicator(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
......@@ -309,3 +327,13 @@ test_repeated_redist(int cache_size)
xt_redist_delete(redist_coll);
}
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2) {
int result;
xt_mpi_call(MPI_Comm_compare(comm1, comm2, &result), MPI_COMM_WORLD);
return ((result == MPI_IDENT) || (result == MPI_CONGRUENT));
}
......@@ -48,6 +48,8 @@
#include "tests.h"
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2);
int main(void) {
// init mpi
......@@ -130,6 +132,11 @@ int main(void) {
Xt_redist redist = xt_redist_collection_new(redists, 4, -1,
MPI_COMM_WORLD);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
xt_redist_delete(redists[0]), xt_redist_delete(redists[1]);
xt_redist_delete(redists[2]), xt_redist_delete(redists[3]);
......@@ -201,6 +208,11 @@ int main(void) {
Xt_redist redist = xt_redist_collection_new(redists, 2, -1,
MPI_COMM_WORLD);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
xt_redist_delete(redists[0]), xt_redist_delete(redists[1]);
Xt_int results_1[5] = {-1,-1,-1,-1,-1}, results_2[5] = {-1,-1,-1,-1,-1};
......@@ -231,3 +243,12 @@ int main(void) {
return TEST_EXIT_CODE;
}
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2) {
int result;
xt_mpi_call(MPI_Comm_compare(comm1, comm2, &result), MPI_COMM_WORLD);
return ((result == MPI_IDENT) || (result == MPI_CONGRUENT));
}
......@@ -49,6 +49,8 @@
#include "tests.h"
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2);
int main(void) {
// init mpi
......@@ -90,6 +92,11 @@ int main(void) {
dst_displacements,
MPI_COMM_WORLD);
// test communicator of redist
if (!test_communicator(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
......@@ -151,6 +158,11 @@ int main(void) {
dst_displacements,
MPI_COMM_WORLD);
// test communicator of redist
if (!test_communicator(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
......@@ -196,3 +208,12 @@ int main(void) {
return TEST_EXIT_CODE;
}
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2) {
int result;
xt_mpi_call(MPI_Comm_compare(comm1, comm2, &result), MPI_COMM_WORLD);
return ((result == MPI_IDENT) || (result == MPI_CONGRUENT));
}
......@@ -49,6 +49,8 @@
#include "tests.h"
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2);
int main(void) {
// init mpi
......@@ -145,6 +147,11 @@ int main(void) {
= xt_redist_collection_static_new(redists, 4, src_displacements,
dst_displacements, MPI_COMM_WORLD);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
xt_redist_delete(redists[0]), xt_redist_delete(redists[1]);
xt_redist_delete(redists[2]), xt_redist_delete(redists[3]);
......@@ -215,6 +222,11 @@ int main(void) {
= xt_redist_collection_static_new(redists, 2, src_displacements,
dst_displacements, MPI_COMM_WORLD);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
xt_redist_delete(redists[0]), xt_redist_delete(redists[1]);
xt_redist_s_exchange1(redist, (void*)src_indices_, (void*)results_1);
......@@ -239,3 +251,12 @@ int main(void) {
return TEST_EXIT_CODE;
}
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2) {
int result;
xt_mpi_call(MPI_Comm_compare(comm1, comm2, &result), MPI_COMM_WORLD);
return ((result == MPI_IDENT) || (result == MPI_CONGRUENT));
}
......@@ -52,6 +52,8 @@
#include "tests.h"
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2);
int main(void) {
// init mpi
......@@ -90,6 +92,11 @@ int main(void) {
redist = xt_redist_p2p_new(xmap, MPI_DOUBLE);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
// test exchange
double src_data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13};
......@@ -152,6 +159,11 @@ int main(void) {
Xt_redist redist;
redist = xt_redist_p2p_off_new(xmap, src_pos, dst_pos, MPI_DOUBLE);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
// test exchange
const double src_data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13};
......@@ -212,6 +224,11 @@ int main(void) {
sizeof (dst_pos)/sizeof (dst_pos[0]), dst_pos,
MPI_LONG);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
// test exchange
const long src_data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13};
......@@ -244,3 +261,12 @@ int main(void) {
return TEST_EXIT_CODE;
}
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2) {
int result;
xt_mpi_call(MPI_Comm_compare(comm1, comm2, &result), MPI_COMM_WORLD);
return ((result == MPI_IDENT) || (result == MPI_CONGRUENT));
}
......@@ -52,6 +52,8 @@
#include "tests.h"
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2);
static inline int imin(int a, int b) {
return (((a)<(b))?(a):(b));
}
......@@ -99,6 +101,11 @@ int main(void) {
// redist_p2p
Xt_redist redist = xt_redist_p2p_new(xmap, MPI_DOUBLE);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
// test exchange
double src_data[dataSize];
......@@ -163,6 +170,11 @@ int main(void) {
redist = xt_redist_p2p_new(xmap, MPI_DOUBLE);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
// test exchange
double src_data[size];
......@@ -236,6 +248,12 @@ int main(void) {
// simple redist:
Xt_redist redist = xt_redist_p2p_new(xmap, MPI_INT);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
int a_surfdata[nwin];
int b_surfdata[nwin];
int b_surfdata_ref[nwin];
......@@ -324,6 +342,10 @@ int main(void) {
src_block_offsets, src_block_sizes, nwin,
dst_block_offsets, dst_block_sizes, nwin,
MPI_INT);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(block_redist), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
xt_redist_s_exchange1(block_redist, a_voldata, b_voldata);
......@@ -339,6 +361,10 @@ int main(void) {
src_block_sizes, nwin,
dst_block_sizes, nwin,
MPI_INT);
// test communicator of redist
if (!test_communicator(xt_redist_get_MPI_Comm(block_redist2), MPI_COMM_WORLD))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
for (int i = 0; i < gvol_size; i++) {
b_voldata[i] = -1;
......@@ -366,3 +392,12 @@ int main(void) {
return TEST_EXIT_CODE;
}
static int test_communicator(MPI_Comm comm1, MPI_Comm comm2) {
int result;
xt_mpi_call(MPI_Comm_compare(comm1, comm2, &result), MPI_COMM_WORLD);
return ((result == MPI_IDENT) || (result == MPI_CONGRUENT));
}
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