From 15c4ae3391d1731d7fa4fc5a5bdc3bac3b6e7d06 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Wed, 27 Jul 2005 01:00:02 +0000 Subject: [PATCH] Fix for buglet #1423. Any non-blocking P2P function should set the request to something else then MPI_REQUEST_NULL, when passed a source/dest of MPI_PROC_NULL. Introduce a new ompi_request_empty, which returns the MPI_SOURCE=MPI_PROC_NULL, MPI_TAG=MPI_ANY_TAG, count=0 as specified by the MPI-standard. This commit was SVN r6611. --- ompi/mpi/c/bsend_init.c | 2 +- ompi/mpi/c/ibsend.c | 2 +- ompi/mpi/c/irecv.c | 2 +- ompi/mpi/c/irsend.c | 2 +- ompi/mpi/c/isend.c | 2 +- ompi/mpi/c/issend.c | 2 +- ompi/mpi/c/recv_init.c | 2 +- ompi/mpi/c/rsend_init.c | 2 +- ompi/mpi/c/send_init.c | 2 +- ompi/mpi/c/ssend_init.c | 2 +- ompi/request/request.c | 29 +++++++++++++++++++++++++++++ ompi/request/request.h | 1 + 12 files changed, 40 insertions(+), 10 deletions(-) diff --git a/ompi/mpi/c/bsend_init.c b/ompi/mpi/c/bsend_init.c index b89eef20f6..69c3482e1b 100644 --- a/ompi/mpi/c/bsend_init.c +++ b/ompi/mpi/c/bsend_init.c @@ -37,7 +37,7 @@ int MPI_Bsend_init(void *buf, int count, MPI_Datatype type, { int rc; if (dest == MPI_PROC_NULL) { - *request = MPI_REQUEST_NULL; + *request = &ompi_request_empty; return MPI_SUCCESS; } diff --git a/ompi/mpi/c/ibsend.c b/ompi/mpi/c/ibsend.c index e3bc89bb18..6ce9bf46a3 100644 --- a/ompi/mpi/c/ibsend.c +++ b/ompi/mpi/c/ibsend.c @@ -38,7 +38,7 @@ int MPI_Ibsend(void *buf, int count, MPI_Datatype type, int dest, { int rc; if (dest == MPI_PROC_NULL) { - *request = MPI_REQUEST_NULL; + *request = &ompi_request_empty; return MPI_SUCCESS; } diff --git a/ompi/mpi/c/irecv.c b/ompi/mpi/c/irecv.c index 6cbe682dcd..f0b003f451 100644 --- a/ompi/mpi/c/irecv.c +++ b/ompi/mpi/c/irecv.c @@ -37,7 +37,7 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source, { int rc; if (source == MPI_PROC_NULL) { - *request = MPI_REQUEST_NULL; + *request = &ompi_request_empty; return OMPI_SUCCESS; } diff --git a/ompi/mpi/c/irsend.c b/ompi/mpi/c/irsend.c index f1e09e8887..e54bdfa5fe 100644 --- a/ompi/mpi/c/irsend.c +++ b/ompi/mpi/c/irsend.c @@ -37,7 +37,7 @@ int MPI_Irsend(void *buf, int count, MPI_Datatype type, int dest, { int rc; if (dest == MPI_PROC_NULL) { - *request = MPI_REQUEST_NULL; + *request = &ompi_request_empty; return MPI_SUCCESS; } diff --git a/ompi/mpi/c/isend.c b/ompi/mpi/c/isend.c index d5cb35f168..8e56baea46 100644 --- a/ompi/mpi/c/isend.c +++ b/ompi/mpi/c/isend.c @@ -37,7 +37,7 @@ int MPI_Isend(void *buf, int count, MPI_Datatype type, int dest, { int rc; if (dest == MPI_PROC_NULL) { - *request = MPI_REQUEST_NULL; + *request = &ompi_request_empty; return MPI_SUCCESS; } diff --git a/ompi/mpi/c/issend.c b/ompi/mpi/c/issend.c index 80bebdb064..cc4b9360e0 100644 --- a/ompi/mpi/c/issend.c +++ b/ompi/mpi/c/issend.c @@ -38,7 +38,7 @@ int MPI_Issend(void *buf, int count, MPI_Datatype type, int dest, { int rc; if (dest == MPI_PROC_NULL) { - *request = MPI_REQUEST_NULL; + *request = &ompi_request_empty; return MPI_SUCCESS; } diff --git a/ompi/mpi/c/recv_init.c b/ompi/mpi/c/recv_init.c index 467c478c61..b523484ba7 100644 --- a/ompi/mpi/c/recv_init.c +++ b/ompi/mpi/c/recv_init.c @@ -37,7 +37,7 @@ int MPI_Recv_init(void *buf, int count, MPI_Datatype type, int source, { int rc; if (source == MPI_PROC_NULL) { - *request = &ompi_request_null; + *request = &ompi_request_empty; return MPI_SUCCESS; } diff --git a/ompi/mpi/c/rsend_init.c b/ompi/mpi/c/rsend_init.c index 7e56e0d0a0..e120e72fc3 100644 --- a/ompi/mpi/c/rsend_init.c +++ b/ompi/mpi/c/rsend_init.c @@ -38,7 +38,7 @@ int MPI_Rsend_init(void *buf, int count, MPI_Datatype type, { int rc; if (dest == MPI_PROC_NULL) { - *request = MPI_REQUEST_NULL; + *request = &ompi_request_empty; return MPI_SUCCESS; } diff --git a/ompi/mpi/c/send_init.c b/ompi/mpi/c/send_init.c index b94742b45c..d9b6d1337c 100644 --- a/ompi/mpi/c/send_init.c +++ b/ompi/mpi/c/send_init.c @@ -38,7 +38,7 @@ int MPI_Send_init(void *buf, int count, MPI_Datatype type, { int rc; if (dest == MPI_PROC_NULL) { - *request = MPI_REQUEST_NULL; + *request = &ompi_request_empty; return MPI_SUCCESS; } diff --git a/ompi/mpi/c/ssend_init.c b/ompi/mpi/c/ssend_init.c index 7d63ef0f5c..9c2180c721 100644 --- a/ompi/mpi/c/ssend_init.c +++ b/ompi/mpi/c/ssend_init.c @@ -38,7 +38,7 @@ int MPI_Ssend_init(void *buf, int count, MPI_Datatype type, { int rc; if (dest == MPI_PROC_NULL) { - *request = MPI_REQUEST_NULL; + *request = &ompi_request_empty; return MPI_SUCCESS; } diff --git a/ompi/request/request.c b/ompi/request/request.c index 764a4abb5d..5ea9dc7277 100644 --- a/ompi/request/request.c +++ b/ompi/request/request.c @@ -26,6 +26,7 @@ int ompi_request_poll_iterations = 20000; OMPI_DECLSPEC opal_mutex_t ompi_request_lock; OMPI_DECLSPEC opal_condition_t ompi_request_cond; OMPI_DECLSPEC ompi_request_t ompi_request_null; +OMPI_DECLSPEC ompi_request_t ompi_request_empty; ompi_status_public_t ompi_status_empty; @@ -67,6 +68,7 @@ int ompi_request_init(void) OBJ_CONSTRUCT(&ompi_request_lock, opal_mutex_t); OBJ_CONSTRUCT(&ompi_request_cond, opal_condition_t); OBJ_CONSTRUCT(&ompi_request_null, ompi_request_t); + OBJ_CONSTRUCT(&ompi_request_empty, ompi_request_t); ompi_request_null.req_status.MPI_SOURCE = MPI_PROC_NULL; ompi_request_null.req_status.MPI_TAG = MPI_ANY_TAG; @@ -87,6 +89,33 @@ int ompi_request_init(void) return OMPI_ERR_REQUEST; } + /* We need a way to distinguish between the user provided + * MPI_REQUEST_NULL to MPI_Wait* and a non-active (MPI_PROC_NULL) + * request passed to any P2P non-blocking function. + * + * The main difference to ompi_request_null is + * req_state being OMPI_REQUEST_ACTIVE, so that MPI_Waitall + * does not set the status to ompi_status_empty. + */ + ompi_request_empty.req_status.MPI_SOURCE = MPI_PROC_NULL; + ompi_request_empty.req_status.MPI_TAG = MPI_ANY_TAG; + ompi_request_empty.req_status.MPI_ERROR = MPI_SUCCESS; + ompi_request_empty.req_status._count = 0; + ompi_request_empty.req_status._cancelled = 0; + + ompi_request_empty.req_state = OMPI_REQUEST_ACTIVE; + ompi_request_empty.req_complete = true; + ompi_request_empty.req_type = OMPI_REQUEST_NULL; + ompi_request_empty.req_fini = ompi_request_null_free; + ompi_request_empty.req_free = ompi_request_null_free; + ompi_request_empty.req_cancel = ompi_request_null_cancel; + ompi_request_empty.req_f_to_c_index = + ompi_pointer_array_add(&ompi_request_f_to_c_table, &ompi_request_empty); + + if (1 != ompi_request_empty.req_f_to_c_index) { + return OMPI_ERR_REQUEST; + } + ompi_status_empty.MPI_SOURCE = MPI_ANY_SOURCE; ompi_status_empty.MPI_TAG = MPI_ANY_TAG; ompi_status_empty.MPI_ERROR = MPI_SUCCESS; diff --git a/ompi/request/request.h b/ompi/request/request.h index 283b3cbb26..d26e773517 100644 --- a/ompi/request/request.h +++ b/ompi/request/request.h @@ -142,6 +142,7 @@ OMPI_DECLSPEC extern opal_mutex_t ompi_request_lock; OMPI_DECLSPEC extern opal_condition_t ompi_request_cond; OMPI_DECLSPEC extern int ompi_request_poll_iterations; OMPI_DECLSPEC extern ompi_request_t ompi_request_null; +OMPI_DECLSPEC extern ompi_request_t ompi_request_empty; OMPI_DECLSPEC extern ompi_status_public_t ompi_status_empty;