From f5b0376823ed3658847fdf2f3447c87fcdec15ff Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 21 Sep 2009 11:27:23 -0500 Subject: CarpetInterp: Avoid possible race condition when creating new MPI datatypes Ignore-this: 1770a5adf6184bcbb3cef19359d3a0c9 --- Carpet/CarpetInterp/src/interp.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Carpet/CarpetInterp') diff --git a/Carpet/CarpetInterp/src/interp.cc b/Carpet/CarpetInterp/src/interp.cc index 4707fd7cc..d6e791261 100644 --- a/Carpet/CarpetInterp/src/interp.cc +++ b/Carpet/CarpetInterp/src/interp.cc @@ -509,7 +509,7 @@ namespace CarpetInterp { } #endif { - MPI_Datatype datatype = dist::mpi_datatype (tmp[0]); + MPI_Datatype const datatype = dist::mpi_datatype (tmp[0]); MPI_Datatype vdatatype; MPI_Type_vector(1, ndims, 0, datatype, &vdatatype); MPI_Type_commit(&vdatatype); @@ -708,8 +708,9 @@ namespace CarpetInterp { #undef TYPECASE default: { CCTK_WARN (0, "invalid datatype"); abort(); } } - MPI_Type_vector(1, N_output_arrays, 0, datatype, &datatype); - MPI_Type_commit(&datatype); + MPI_Datatype vdatatype; + MPI_Type_vector(1, N_output_arrays, 0, datatype, &vdatatype); + MPI_Type_commit(&vdatatype); static Timer * timer = NULL; if (not timer) { @@ -718,12 +719,12 @@ namespace CarpetInterp { timer->start (); // distribute the results the same way as the coordinates were gathered // simply by interchanging the send/recv counts/displacements - MPI_Alltoallv (&outputs_buffer[0], &recvcnt[0], &recvdispl[0], datatype, - &tmp[0], &sendcnt[0], &senddispl[0], datatype, + MPI_Alltoallv (&outputs_buffer[0], &recvcnt[0], &recvdispl[0], vdatatype, + &tmp[0], &sendcnt[0], &senddispl[0], vdatatype, dist::comm()); timer->stop (N_interp_points * N_output_arrays * vtypesize); - MPI_Type_free(&datatype); + MPI_Type_free(&vdatatype); outputs_buffer.swap (tmp); } -- cgit v1.2.3