From 3da0a360fecd25a53e76722565484915d5e72f37 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Thu, 7 Jan 2016 09:20:40 +0000 Subject: [PATCH] Store MPI datatype as raw value and not pointer. --- src/engine.c | 12 ++++++------ src/engine.h | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/engine.c b/src/engine.c index c9a1de94cf..d2b861b49d 100644 --- a/src/engine.c +++ b/src/engine.c @@ -217,11 +217,11 @@ void engine_redistribute(struct engine *e) { offset_recv += counts[ind_recv]; } else { if (MPI_Isend(&s->parts[offset_send], counts[ind_send], - *(e->part_mpi_type), k, 2 * ind_send + 0, MPI_COMM_WORLD, + e->part_mpi_type, k, 2 * ind_send + 0, MPI_COMM_WORLD, &reqs[4 * k]) != MPI_SUCCESS) error("Failed to isend parts to node %i.", k); if (MPI_Isend(&s->xparts[offset_send], counts[ind_send], - *(e->xpart_mpi_type), k, 2 * ind_send + 1, MPI_COMM_WORLD, + e->xpart_mpi_type, k, 2 * ind_send + 1, MPI_COMM_WORLD, &reqs[4 * k + 1]) != MPI_SUCCESS) error("Failed to isend xparts to node %i.", k); offset_send += counts[ind_send]; @@ -229,11 +229,11 @@ void engine_redistribute(struct engine *e) { } if (k != nodeID && counts[ind_recv] > 0) { if (MPI_Irecv(&parts_new[offset_recv], counts[ind_recv], - *(e->part_mpi_type), k, 2 * ind_recv + 0, MPI_COMM_WORLD, + e->part_mpi_type, k, 2 * ind_recv + 0, MPI_COMM_WORLD, &reqs[4 * k + 2]) != MPI_SUCCESS) error("Failed to emit irecv of parts from node %i.", k); if (MPI_Irecv(&xparts_new[offset_recv], counts[ind_recv], - *(e->xpart_mpi_type), k, 2 * ind_recv + 1, MPI_COMM_WORLD, + e->xpart_mpi_type, k, 2 * ind_recv + 1, MPI_COMM_WORLD, &reqs[4 * k + 3]) != MPI_SUCCESS) error("Failed to emit irecv of parts from node %i.", k); offset_recv += counts[ind_recv]; @@ -2201,8 +2201,8 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, /* Construct types for MPI communications */ #ifdef WITH_MPI - part_create_mpi_type(e->part_mpi_type); - xpart_create_mpi_type(e->xpart_mpi_type); + part_create_mpi_type(&e->part_mpi_type); + xpart_create_mpi_type(&e->xpart_mpi_type); #endif /* First of all, init the barrier and lock it. */ diff --git a/src/engine.h b/src/engine.h index 4ab86288a0..017455dc7d 100644 --- a/src/engine.h +++ b/src/engine.h @@ -134,9 +134,11 @@ struct engine { struct link *links; int nr_links, size_links; +#ifdef WITH_MPI /* MPI data type for the particle transfers */ - MPI_Datatype *part_mpi_type; - MPI_Datatype *xpart_mpi_type; + MPI_Datatype part_mpi_type; + MPI_Datatype xpart_mpi_type; +#endif }; /* Function prototypes. */ -- GitLab