Skip to content

Commit d578cad

Browse files
committed
Fix MPI buffer allocation in AllToAll with MPI_Probe
1 parent 7d7eeee commit d578cad

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

p2p/tst_p2p_alltoall_probe_anysource.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ int tst_p2p_alltoall_probe_anysource_init (struct tst_env * env)
7070
env->req_buffer[i] = MPI_REQUEST_NULL;
7171
memset (&(env->status_buffer[i]), 0, sizeof (MPI_Status));
7272
}
73-
74-
env->mpi_buffer_size = num_threads * (tst_type_gettypesize (env->type) * env->values_num * (comm_size - 1) + comm_size * MPI_BSEND_OVERHEAD);
73+
int num = 1 + num_threads;
74+
env->mpi_buffer_size = num * (tst_type_gettypesize (env->type) * env->values_num * (comm_size - 1) + comm_size * MPI_BSEND_OVERHEAD);
7575
if ((env->mpi_buffer = malloc (env->mpi_buffer_size)) == NULL)
7676
ERROR (errno, "malloc");
7777
#ifdef HAVE_MPI2_THREADS
78-
if ( tst_thread_get_num () == 0 ) {
78+
if ( tst_thread_get_num () == TST_THREAD_MASTER ) {
7979
#endif
8080
MPI_CHECK (MPI_Buffer_attach (env->mpi_buffer, env->mpi_buffer_size));
8181
#ifdef HAVE_MPI2_THREADS
@@ -198,7 +198,7 @@ int tst_p2p_alltoall_probe_anysource_cleanup (struct tst_env * env)
198198
int i;
199199

200200
#ifdef HAVE_MPI2_THREADS
201-
if ( tst_thread_get_num () == 0 ) {
201+
if (tst_thread_get_num () == TST_THREAD_MASTER) {
202202
#endif
203203
MPI_CHECK (MPI_Buffer_detach (&env->mpi_buffer, &env->mpi_buffer_size));
204204
#ifdef HAVE_MPI2_THREADS

0 commit comments

Comments
 (0)