From 2ce7ca725bb38acf1dbde871cc0f09d7b15f3dac Mon Sep 17 00:00:00 2001 From: Tim Woodall Date: Thu, 24 Jun 2004 16:47:00 +0000 Subject: [PATCH] - cleanup of some of the c bindings - for threaded case - cleanup event libraries progress thread - cleanup of request handling for persistent sends - added support for buffered sends This commit was SVN r1461. --- src/communicator/communicator.h | 2 +- src/errhandler/errhandler.h | 2 +- src/errhandler/errhandler_invoke.c | 2 +- src/event/event.c | 32 ++- src/event/event.h | 1 + src/include/constants.h | 4 +- src/mca/allocator/bucket/allocator_bucket.c | 10 +- .../allocator/bucket/allocator_bucket_alloc.c | 3 +- .../allocator/bucket/allocator_bucket_alloc.h | 11 + src/mca/mpool/mpool.h | 9 +- src/mca/pml/base/Makefile.am | 2 + src/mca/pml/base/pml_base_bsend.c | 248 ++++++++++++++++++ src/mca/pml/base/pml_base_bsend.h | 20 ++ src/mca/pml/teg/src/pml_teg.h | 21 ++ src/mca/pml/teg/src/pml_teg_module.c | 9 +- src/mca/pml/teg/src/pml_teg_recvreq.h | 1 + src/mca/pml/teg/src/pml_teg_sendreq.c | 4 +- src/mca/pml/teg/src/pml_teg_sendreq.h | 19 +- src/mca/pml/teg/src/pml_teg_start.c | 72 ++++- src/mca/pml/teg/src/pml_teg_test.c | 14 +- src/mca/pml/teg/src/pml_teg_wait.c | 18 +- src/mca/ptl/base/ptl_base_recvreq.h | 1 + src/mca/ptl/base/ptl_base_sendreq.h | 2 +- src/mca/ptl/self/src/ptl_self.c | 7 +- src/mca/ptl/tcp/src/ptl_tcp_module.c | 2 +- src/mpi/c/address.c | 2 +- src/mpi/c/allgather.c | 2 +- src/mpi/c/alltoall.c | 2 +- src/mpi/c/attr_delete.c | 2 +- src/mpi/c/attr_get.c | 2 +- src/mpi/c/attr_put.c | 2 +- src/mpi/c/barrier.c | 2 +- src/mpi/c/bcast.c | 2 +- src/mpi/c/bsend.c | 40 ++- src/mpi/c/bsend_init.c | 23 +- src/mpi/c/buffer_attach.c | 10 +- src/mpi/c/buffer_detach.c | 8 +- src/mpi/c/comm_create_keyval.c | 2 +- src/mpi/c/comm_delete_attr.c | 2 +- src/mpi/c/comm_free_keyval.c | 2 +- src/mpi/c/comm_get_attr.c | 2 +- src/mpi/c/comm_set_attr.c | 2 +- src/mpi/c/gather.c | 2 +- src/mpi/c/get_address.c | 2 +- src/mpi/c/ibsend.c | 29 +- src/mpi/c/irecv.c | 14 +- src/mpi/c/irsend.c | 14 +- src/mpi/c/isend.c | 14 +- src/mpi/c/issend.c | 14 +- src/mpi/c/keyval_create.c | 2 +- src/mpi/c/keyval_free.c | 2 +- src/mpi/c/pack.c | 2 +- src/mpi/c/pack_size.c | 2 +- src/mpi/c/recv.c | 14 +- src/mpi/c/recv_init.c | 14 +- src/mpi/c/request_free.c | 22 +- src/mpi/c/rsend.c | 14 +- src/mpi/c/rsend_init.c | 14 +- src/mpi/c/send.c | 5 +- src/mpi/c/send_init.c | 14 +- src/mpi/c/sendrecv.c | 18 +- src/mpi/c/ssend.c | 14 +- src/mpi/c/ssend_init.c | 14 +- src/mpi/c/test.c | 15 +- src/mpi/c/test_cancelled.c | 1 + src/mpi/c/testany.c | 12 +- src/mpi/c/testsome.c | 12 +- src/mpi/c/type_commit.c | 2 +- src/mpi/c/type_contiguous.c | 2 +- src/mpi/c/type_create_hindexed.c | 2 +- src/mpi/c/type_create_hvector.c | 2 +- src/mpi/c/type_create_indexed_block.c | 2 +- src/mpi/c/type_create_keyval.c | 2 +- src/mpi/c/type_create_resized.c | 2 +- src/mpi/c/type_create_struct.c | 2 +- src/mpi/c/type_delete_attr.c | 2 +- src/mpi/c/type_dup.c | 2 +- src/mpi/c/type_free.c | 2 +- src/mpi/c/type_free_keyval.c | 2 +- src/mpi/c/type_get_attr.c | 2 +- src/mpi/c/type_get_contents.c | 2 +- src/mpi/c/type_get_envelope.c | 2 +- src/mpi/c/type_get_extent.c | 2 +- src/mpi/c/type_get_true_extent.c | 2 +- src/mpi/c/type_indexed.c | 2 +- src/mpi/c/type_match_size.c | 2 +- src/mpi/c/type_set_attr.c | 2 +- src/mpi/c/type_size.c | 2 +- src/mpi/c/type_vector.c | 2 +- src/mpi/c/unpack.c | 2 +- src/mpi/c/wait.c | 18 +- src/mpi/c/waitall.c | 11 +- src/mpi/c/waitany.c | 12 +- src/mpi/c/waitsome.c | 11 +- src/mpi/c/win_create_keyval.c | 2 +- src/mpi/c/win_delete_attr.c | 2 +- src/mpi/c/win_free_keyval.c | 2 +- src/mpi/c/win_get_attr.c | 2 +- src/mpi/c/win_set_attr.c | 2 +- src/mpi/c/win_wait.c | 3 + src/mpi/f77/profile/Makefile.am | 1 + src/request/request.c | 3 +- src/request/request.h | 6 +- src/runtime/ompi_progress.c | 1 + 104 files changed, 783 insertions(+), 242 deletions(-) create mode 100644 src/mca/pml/base/pml_base_bsend.c create mode 100644 src/mca/pml/base/pml_base_bsend.h diff --git a/src/communicator/communicator.h b/src/communicator/communicator.h index 60ac09f3c4..d271dd42fd 100644 --- a/src/communicator/communicator.h +++ b/src/communicator/communicator.h @@ -100,7 +100,7 @@ extern ompi_communicator_t *ompi_mpi_comm_parent; */ static inline int ompi_comm_invalid(ompi_communicator_t* comm) { - if ( comm->c_flags & OMPI_COMM_ISFREED ) + if ((NULL == comm) || (MPI_COMM_NULL == comm) || (comm->c_flags & OMPI_COMM_ISFREED )) return true; else return false; diff --git a/src/errhandler/errhandler.h b/src/errhandler/errhandler.h index b9f9c5c745..362eaa1541 100644 --- a/src/errhandler/errhandler.h +++ b/src/errhandler/errhandler.h @@ -225,7 +225,7 @@ extern "C" { * may not return (e.g., for MPI_ERRORS_ARE_FATAL). */ int ompi_errhandler_invoke(ompi_errhandler_t *errhandler, void *mpi_object, - int err_code, char *message); + int err_code, const char *message); /** diff --git a/src/errhandler/errhandler_invoke.c b/src/errhandler/errhandler_invoke.c index 3d2b630ace..db899e05c1 100644 --- a/src/errhandler/errhandler_invoke.c +++ b/src/errhandler/errhandler_invoke.c @@ -11,7 +11,7 @@ int ompi_errhandler_invoke(ompi_errhandler_t *errhandler, void *mpi_object, - int err_code, char *message) + int err_code, const char *message) { int fortran_handle; ompi_communicator_t *comm; diff --git a/src/event/event.c b/src/event/event.c index 2c941efecd..3157e7452d 100644 --- a/src/event/event.c +++ b/src/event/event.c @@ -131,11 +131,12 @@ struct ompi_event_list ompi_signalqueue; struct ompi_event_list ompi_eventqueue; static struct timeval ompi_event_tv; ompi_mutex_t ompi_event_lock; +static int ompi_event_inited; #if OMPI_HAVE_THREADS -ompi_thread_t ompi_event_thread; -ompi_event_t ompi_event_pipe_event; -int ompi_event_pipe[2]; -int ompi_event_pipe_signalled; +static ompi_thread_t ompi_event_thread; +static ompi_event_t ompi_event_pipe_event; +static int ompi_event_pipe[2]; +static int ompi_event_pipe_signalled; #endif static int @@ -198,13 +199,12 @@ static void ompi_event_pipe_handler(int sd, short flags, void* user) int ompi_event_init(void) { - static int inited = false; int i; #if OMPI_HAVE_THREADS int rc; #endif - if(inited) + if(ompi_event_inited++ != 0) return OMPI_SUCCESS; ompi_event_sigcb = NULL; @@ -253,10 +253,26 @@ ompi_event_init(void) log_to(stderr); log_debug_cmd(LOG_MISC, 80); #endif - inited = true; return OMPI_SUCCESS; } +int ompi_event_fini(void) +{ +#if OMPI_HAVE_THREADS + if(ompi_event_inited && --ompi_event_inited == 0) { + if(ompi_event_pipe_signalled == 0) { + unsigned char byte = 0; + if(write(ompi_event_pipe[1], &byte, 1) != 1) + ompi_output(0, "ompi_event_add: write() to ompi_event_pipe[1] failed with errno=%d\n", errno); + ompi_event_pipe_signalled++; + } + ompi_thread_join(&ompi_event_thread, NULL); + } +#endif + return OMPI_SUCCESS; +} + + int ompi_event_haveevents(void) { @@ -315,7 +331,7 @@ ompi_event_loop(int flags) } done = 0; - while (!done) { + while (!done && ompi_event_inited) { while (ompi_event_gotsig) { ompi_event_gotsig = 0; if (ompi_event_sigcb) { diff --git a/src/event/event.h b/src/event/event.h index 308457c8cf..c26076cd58 100644 --- a/src/event/event.h +++ b/src/event/event.h @@ -143,6 +143,7 @@ struct ompi_eventop { int ompi_event_init(void); +int ompi_event_fini(void); int ompi_event_dispatch(void); int ompi_event_loop(int); diff --git a/src/include/constants.h b/src/include/constants.h index fe360c96fd..b8e2aaac14 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -23,7 +23,9 @@ enum { OMPI_ERR_WOULD_BLOCK = -13, OMPI_ERR_IN_ERRNO = -14, OMPI_ERR_UNREACH = -15, - OMPI_ERR_NOT_FOUND = -16 + OMPI_ERR_NOT_FOUND = -16, + OMPI_ERR_BUFFER = -17, /* equivalent to MPI_ERR_BUFFER */ + OMPI_ERR_REQUEST = -18 /* equivalent to MPI_ERR_REQUEST */ }; #endif /* OMPI_CONSTANTS_H */ diff --git a/src/mca/allocator/bucket/allocator_bucket.c b/src/mca/allocator/bucket/allocator_bucket.c index 14c0ae43bd..1235b539ac 100644 --- a/src/mca/allocator/bucket/allocator_bucket.c +++ b/src/mca/allocator/bucket/allocator_bucket.c @@ -18,6 +18,13 @@ static int mca_allocator_num_buckets; +int mca_allocator_bucket_finalize(struct mca_allocator_t* allocator) +{ + mca_allocator_bucket_cleanup(allocator); + free(allocator); + return(OMPI_SUCCESS); +} + struct mca_allocator_t* mca_allocator_bucket_module_init( bool *allow_multi_user_threads, mca_allocator_segment_alloc_fn_t segment_alloc, @@ -38,7 +45,8 @@ struct mca_allocator_t* mca_allocator_bucket_module_init( allocator->super.alc_alloc = mca_allocator_bucket_alloc_wrapper; allocator->super.alc_realloc = mca_allocator_bucket_realloc; allocator->super.alc_free = mca_allocator_bucket_free; - allocator->super.alc_finalize = mca_allocator_bucket_cleanup; + allocator->super.alc_return = mca_allocator_bucket_cleanup; + allocator->super.alc_finalize = mca_allocator_bucket_finalize; return((mca_allocator_t *) allocator); } diff --git a/src/mca/allocator/bucket/allocator_bucket_alloc.c b/src/mca/allocator/bucket/allocator_bucket_alloc.c index fc37fb26cb..ad4458176c 100644 --- a/src/mca/allocator/bucket/allocator_bucket_alloc.c +++ b/src/mca/allocator/bucket/allocator_bucket_alloc.c @@ -317,7 +317,8 @@ int mca_allocator_bucket_cleanup(mca_allocator_t * mem) segment = *segment_header; *segment_header = segment->next_segment; /* free the memory */ - mem_options->free_mem_fn(segment); + if(mem_options->free_mem_fn) + mem_options->free_mem_fn(segment); } else { /* go to next segment */ segment_header = &((*segment_header)->next_segment); diff --git a/src/mca/allocator/bucket/allocator_bucket_alloc.h b/src/mca/allocator/bucket/allocator_bucket_alloc.h index 65e2bf8e34..18dc8d39a8 100644 --- a/src/mca/allocator/bucket/allocator_bucket_alloc.h +++ b/src/mca/allocator/bucket/allocator_bucket_alloc.h @@ -189,6 +189,17 @@ extern "C" { */ int mca_allocator_bucket_cleanup(mca_allocator_t * mem); +/** + * Cleanup all resources held by this allocator. + * + * @param mem_options A pointer to the appropriate struct for the area of + * memory. + * + * @retval None + * + */ + int mca_allocator_bucket_finalize(mca_allocator_t * mem); + #if defined(c_plusplus) || defined(__cplusplus) } #endif diff --git a/src/mca/mpool/mpool.h b/src/mca/mpool/mpool.h index 9e6d6ae5aa..e3557365f4 100644 --- a/src/mca/mpool/mpool.h +++ b/src/mca/mpool/mpool.h @@ -21,6 +21,11 @@ typedef void* (*mca_mpool_base_address_fn_t)(void); */ typedef void* (*mca_mpool_base_alloc_fn_t)(size_t size, size_t align); +/** + * allocate function typedef + */ +typedef void* (*mca_mpool_base_alloc_and_register_fn_t)(size_t size, size_t align, void* user); + /** * realloc function typedef */ @@ -34,12 +39,12 @@ typedef void (*mca_mpool_base_free_fn_t)(void *); /** * register memory */ -typedef void (*mca_mpool_base_register_fn_t)(void * addr, size_t size, void* user); +typedef int (*mca_mpool_base_register_fn_t)(void * addr, size_t size, void* user); /** * deregister memory */ -typedef void (*mca_mpool_base_deregister_fn_t)(void * addr, size_t size); +typedef int (*mca_mpool_base_deregister_fn_t)(void * addr, size_t size); /** * finalize diff --git a/src/mca/pml/base/Makefile.am b/src/mca/pml/base/Makefile.am index 7e8f401105..0901a78859 100644 --- a/src/mca/pml/base/Makefile.am +++ b/src/mca/pml/base/Makefile.am @@ -14,10 +14,12 @@ AM_CPPFLAGS = -I$(top_builddir)/src headers = \ base.h \ + pml_base_bsend.h \ pml_base_request.h libmca_pml_base_la_SOURCES = \ $(headers) \ + pml_base_bsend.c \ pml_base_close.c \ pml_base_request.c \ pml_base_open.c \ diff --git a/src/mca/pml/base/pml_base_bsend.c b/src/mca/pml/base/pml_base_bsend.c new file mode 100644 index 0000000000..1392e1e1db --- /dev/null +++ b/src/mca/pml/base/pml_base_bsend.c @@ -0,0 +1,248 @@ +#include "mca/allocator/base/base.h" +#include "mca/allocator/allocator.h" +#include "mca/base/mca_base_param.h" +#include "mca/pml/pml.h" +#include "mca/pml/base/pml_base_request.h" +#include "mca/ptl/base/ptl_base_sendreq.h" +#include "pml_base_bsend.h" + +static ompi_mutex_t mca_pml_bsend_mutex; /* lock for thread safety */ +static ompi_condition_t mca_pml_bsend_condition; /* condition variable to block on detach */ +static mca_allocator_base_module_t* mca_pml_bsend_allocator_component; +static mca_allocator_t* mca_pml_bsend_allocator; /* sub-allocator to manage users buffer */ +static unsigned char *mca_pml_bsend_base; /* base address of users buffer */ +static unsigned char *mca_pml_bsend_addr; /* current offset into users buffer */ +static size_t mca_pml_bsend_size; /* size of users buffer */ +static size_t mca_pml_bsend_count; /* number of outstanding requests */ +static size_t mca_pml_bsend_pagesz; /* mmap page size */ +static int mca_pml_bsend_pagebits; /* number of bits in pagesz */ + + + +/* + * Routine to return pages to sub-allocator as needed + */ +static void* mca_pml_bsend_alloc_segment(size_t* size_inout) +{ + void *addr; + size_t size = *size_inout; + size_t pages = 1; + + /* determine number of pages to allocate */ + while(size > mca_pml_bsend_pagesz) { + size >>= mca_pml_bsend_pagebits; + pages++; + } + + if(mca_pml_bsend_addr + size > mca_pml_bsend_base + mca_pml_bsend_size) { + if( mca_pml_bsend_addr + *size_inout <= mca_pml_bsend_base + mca_pml_bsend_size ) { + size = *size_inout; + } else { + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return NULL; + } + } + addr = mca_pml_bsend_addr; + mca_pml_bsend_addr += size; + *size_inout = size; + return addr; +} + + +/* + * One time initialization at startup + */ +int mca_pml_base_bsend_init(bool* thread_safe) +{ + int id = mca_base_param_register_string("pml", "base", "bsend_allocator", NULL, "bucket"); + mca_allocator_t *allocator; + char *name; + size_t tmp; + + /* initialize static objects */ + OBJ_CONSTRUCT(&mca_pml_bsend_mutex, ompi_mutex_t); + OBJ_CONSTRUCT(&mca_pml_bsend_condition, ompi_condition_t); + + /* lookup name of the allocator to use for buffered sends */ + mca_base_param_lookup_string(id, &name); + if(NULL == (mca_pml_bsend_allocator_component = mca_allocator_component_lookup(name))) { + free(name); + return OMPI_ERR_BUFFER; + } + free(name); + + /* try to create an instance of the allocator - to determine thread safety level */ + allocator = mca_pml_bsend_allocator_component->allocator_init(thread_safe, mca_pml_bsend_alloc_segment, NULL); + if(NULL == allocator) { + return OMPI_ERR_BUFFER; + } + allocator->alc_finalize(allocator); + + /* determine page size */ + tmp = mca_pml_bsend_pagesz = sysconf(_SC_PAGESIZE); + mca_pml_bsend_pagebits = 0; + while( tmp != 0 ) { + tmp >>= 1; + mca_pml_bsend_pagebits++; + } + return OMPI_SUCCESS; +} + + +/* + * One-time cleanup at shutdown - release any resources. + */ +int mca_pml_base_bsend_fini() +{ + if(NULL != mca_pml_bsend_allocator) + mca_pml_bsend_allocator->alc_finalize(mca_pml_bsend_allocator); + mca_pml_bsend_allocator = NULL; + + OBJ_DESTRUCT(&mca_pml_bsend_condition); + OBJ_DESTRUCT(&mca_pml_bsend_mutex); + return OMPI_SUCCESS; +} + + +/* + * User-level call to attach buffer. + */ +int mca_pml_base_bsend_attach(void* addr, int size) +{ + bool thread_safe; + if(NULL == addr || size <= 0) { + return OMPI_ERR_BUFFER; + } + + /* check for buffer already attached */ + THREAD_LOCK(&mca_pml_bsend_mutex); + if(NULL != mca_pml_bsend_allocator) { + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return OMPI_ERR_BUFFER; + } + + /* try to create an instance of the allocator - to determine thread safety level */ + mca_pml_bsend_allocator = mca_pml_bsend_allocator_component->allocator_init(&thread_safe, mca_pml_bsend_alloc_segment, NULL); + if(NULL == mca_pml_bsend_allocator) { + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return OMPI_ERR_BUFFER; + } + + /* setup local variables */ + mca_pml_bsend_base = addr; + mca_pml_bsend_addr = addr; + mca_pml_bsend_size = size; + mca_pml_bsend_count = 0; + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return OMPI_SUCCESS; +} + +/* + * User-level call to detach buffer + */ +int mca_pml_base_bsend_detach(void* addr, int* size) +{ + THREAD_LOCK(&mca_pml_bsend_mutex); + + /* is buffer attached */ + if(NULL == mca_pml_bsend_allocator) { + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return OMPI_ERR_BUFFER; + } + + /* wait on any pending requests */ + while(mca_pml_bsend_count != 0) + ompi_condition_wait(&mca_pml_bsend_condition, &mca_pml_bsend_mutex); + + /* free resources associated with the allocator */ + mca_pml_bsend_allocator->alc_finalize(mca_pml_bsend_allocator); + mca_pml_bsend_allocator = NULL; + + /* return current settings */ + if(NULL != addr) + *((void**)addr) = mca_pml_bsend_base; + if(NULL != size) + *size = mca_pml_bsend_size; + + /* reset local variables */ + mca_pml_bsend_base = NULL; + mca_pml_bsend_addr = NULL; + mca_pml_bsend_size = 0; + mca_pml_bsend_count = 0; + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return OMPI_SUCCESS; +} + + +/* + * Initialize a request for use w/ buffered send + */ +int mca_pml_base_bsend_request_init(ompi_request_t* request, bool persistent) +{ + mca_ptl_base_send_request_t* sendreq = (mca_ptl_base_send_request_t*)request; + struct iovec iov; + void* buf; + int rc; + + THREAD_LOCK(&mca_pml_bsend_mutex); + if(NULL == mca_pml_bsend_addr) { + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return OMPI_ERR_BUFFER; + } + + /* allocate a buffer to hold packed message */ + buf = mca_pml_bsend_allocator->alc_alloc(mca_pml_bsend_allocator, sendreq->req_bytes_packed, 0); + if(NULL == buf) { + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return OMPI_ERR_BUFFER; + } + + /* pack users message into buffer */ + iov.iov_base = buf; + iov.iov_len = sendreq->req_bytes_packed; + if((rc = ompi_convertor_pack(&sendreq->req_convertor, &iov, 1)) < 0) { + mca_pml_bsend_allocator->alc_free(mca_pml_bsend_allocator, buf); + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return OMPI_ERROR; + } + + /* setup convertor to reflect contiguous buffer */ + if((rc = ompi_convertor_init_for_send(&sendreq->req_convertor, 0, MPI_BYTE, iov.iov_len, iov.iov_base, 0)) != OMPI_SUCCESS) { + mca_pml_bsend_allocator->alc_free(mca_pml_bsend_allocator, buf); + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return rc; + } + + /* increment count of pending requests */ + mca_pml_bsend_count++; + + /* set flag indicating mpi layer is done */ + sendreq->super.req_persistent = persistent; + sendreq->super.req_mpi_done = true; + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return OMPI_SUCCESS; +} + + +/* + * Request completed - free buffer and decrement pending count + */ +int mca_pml_base_bsend_request_fini(ompi_request_t* request) +{ + mca_ptl_base_send_request_t* sendreq = (mca_ptl_base_send_request_t*)request; + + /* remove from list of pending requests */ + THREAD_LOCK(&mca_pml_bsend_mutex); + + /* free buffer */ + mca_pml_bsend_allocator->alc_free(mca_pml_bsend_allocator, sendreq->req_convertor.pBaseBuf); + + /* decrement count of buffered requests */ + if(--mca_pml_bsend_count == 0) + ompi_condition_signal(&mca_pml_bsend_condition); + + THREAD_UNLOCK(&mca_pml_bsend_mutex); + return OMPI_SUCCESS; +} + + diff --git a/src/mca/pml/base/pml_base_bsend.h b/src/mca/pml/base/pml_base_bsend.h new file mode 100644 index 0000000000..a16f3e9612 --- /dev/null +++ b/src/mca/pml/base/pml_base_bsend.h @@ -0,0 +1,20 @@ +#ifndef _MCA_PML_BASE_BSEND_H_ +#define _MCA_PML_BASE_BSEND_H_ + +#include "mca/pml/pml.h" +#include "request/request.h" + +struct mca_ptl_base_send_request_t; + +int mca_pml_base_bsend_init(bool*); +int mca_pml_base_bsend_fini(void); + +int mca_pml_base_bsend_attach(void* addr, int size); +int mca_pml_base_bsend_detach(void* addr, int* size); + +int mca_pml_base_bsend_request_init(ompi_request_t*, bool persistent); +int mca_pml_base_bsend_request_fini(ompi_request_t*); + + +#endif + diff --git a/src/mca/pml/teg/src/pml_teg.h b/src/mca/pml/teg/src/pml_teg.h index d343e22598..ac437cae78 100644 --- a/src/mca/pml/teg/src/pml_teg.h +++ b/src/mca/pml/teg/src/pml_teg.h @@ -15,6 +15,7 @@ #include "request/request.h" #include "mca/pml/pml.h" #include "mca/pml/base/pml_base_request.h" +#include "mca/pml/base/pml_base_bsend.h" #include "mca/ptl/base/ptl_base_sendreq.h" #include "mca/ptl/ptl.h" @@ -249,17 +250,37 @@ extern int mca_pml_teg_free( ompi_request_t** request ); + +#define MCA_PML_TEG_FINI(request) \ +{ \ + mca_pml_base_request_t* pml_request = *(mca_pml_base_request_t**)(request); \ + if(pml_request->req_persistent) { \ + if(pml_request->req_free_called) { \ + MCA_PML_TEG_FREE(request); \ + } else { \ + pml_request->super.req_state = OMPI_REQUEST_INACTIVE; \ + } \ + } else { \ + MCA_PML_TEG_FREE(request); \ + } \ +} + + #define MCA_PML_TEG_FREE(request) \ { \ mca_pml_base_request_t* pml_request = *(mca_pml_base_request_t**)(request); \ pml_request->req_free_called = true; \ if(pml_request->req_pml_done == true) \ { \ + OMPI_REQUEST_FINI(*request); \ switch(pml_request->req_type) { \ case MCA_PML_REQUEST_SEND: \ { \ mca_ptl_base_send_request_t* sendreq = (mca_ptl_base_send_request_t*)pml_request; \ mca_ptl_t* ptl = sendreq->req_owner; \ + if(sendreq->req_send_mode == MCA_PML_BASE_SEND_BUFFERED) { \ + mca_pml_base_bsend_request_fini((ompi_request_t*)sendreq); \ + } \ ptl->ptl_request_return(ptl, sendreq); \ break; \ } \ diff --git a/src/mca/pml/teg/src/pml_teg_module.c b/src/mca/pml/teg/src/pml_teg_module.c index 29bf2eb41f..5e7f398134 100644 --- a/src/mca/pml/teg/src/pml_teg_module.c +++ b/src/mca/pml/teg/src/pml_teg_module.c @@ -7,6 +7,7 @@ #include "mca/pml/pml.h" #include "mca/ptl/ptl.h" #include "mca/base/mca_base_param.h" +#include "mca/pml/base/pml_base_bsend.h" #include "mca/ptl/base/ptl_base_sendreq.h" #include "mca/ptl/base/ptl_base_recvreq.h" #include "pml_teg.h" @@ -135,7 +136,6 @@ mca_pml_t* mca_pml_teg_module_init(int* priority, bool *have_hidden_threads) { *priority = 0; - *allow_multi_user_threads = true; *have_hidden_threads = false; OBJ_CONSTRUCT(&mca_pml_teg.teg_lock, ompi_mutex_t); @@ -158,6 +158,13 @@ mca_pml_t* mca_pml_teg_module_init(int* priority, OBJ_CONSTRUCT(&mca_pml_teg.teg_request_lock, ompi_mutex_t); OBJ_CONSTRUCT(&mca_pml_teg.teg_request_cond, ompi_condition_t); mca_pml_teg.teg_request_waiting = 0; + + /* buffered send */ + if(mca_pml_base_bsend_init(allow_multi_user_threads) != OMPI_SUCCESS) { + ompi_output(0, "mca_pml_teg_module_init: mca_pml_bsend_init failed\n"); + return NULL; + } + *allow_multi_user_threads &= true; return &mca_pml_teg.super; } diff --git a/src/mca/pml/teg/src/pml_teg_recvreq.h b/src/mca/pml/teg/src/pml_teg_recvreq.h index 0e8c9129d7..7a5bab9ae9 100644 --- a/src/mca/pml/teg/src/pml_teg_recvreq.h +++ b/src/mca/pml/teg/src/pml_teg_recvreq.h @@ -42,6 +42,7 @@ */ static inline int mca_pml_teg_recv_request_start(mca_ptl_base_recv_request_t* request) { + request->super.super.req_state = OMPI_REQUEST_ACTIVE; if(request->super.req_peer == OMPI_ANY_SOURCE) { mca_ptl_base_recv_request_match_wild(request); } else { diff --git a/src/mca/pml/teg/src/pml_teg_sendreq.c b/src/mca/pml/teg/src/pml_teg_sendreq.c index 20fa729a59..eca5ed3a99 100644 --- a/src/mca/pml/teg/src/pml_teg_sendreq.c +++ b/src/mca/pml/teg/src/pml_teg_sendreq.c @@ -10,7 +10,6 @@ #include "pml_teg_sendreq.h" - /** * Schedule message delivery across potentially multiple PTLs. * @@ -100,8 +99,9 @@ void mca_pml_teg_send_request_progress( if(mca_pml_teg.teg_request_waiting) { ompi_condition_broadcast(&mca_pml_teg.teg_request_cond); } - } else if (req->super.req_free_called) + } else if (req->super.req_free_called) { MCA_PML_TEG_FREE((ompi_request_t**)&req); + } THREAD_UNLOCK(&mca_pml_teg.teg_request_lock); return; } diff --git a/src/mca/pml/teg/src/pml_teg_sendreq.h b/src/mca/pml/teg/src/pml_teg_sendreq.h index d85f3bb4ff..d869dadfe5 100644 --- a/src/mca/pml/teg/src/pml_teg_sendreq.h +++ b/src/mca/pml/teg/src/pml_teg_sendreq.h @@ -13,9 +13,6 @@ #include "mca/ptl/base/ptl_base_sendfrag.h" -void mca_pml_teg_send_request_schedule(mca_ptl_base_send_request_t* req); - - #define MCA_PML_TEG_SEND_REQUEST_ALLOC( \ comm, \ dst, \ @@ -37,6 +34,7 @@ void mca_pml_teg_send_request_schedule(mca_ptl_base_send_request_t* req); #define MCA_PML_TEG_SEND_REQUEST_RETURN(request) \ request->req_owner->ptl_request_return(request->req_owner, request); + static inline int mca_pml_teg_send_request_start( mca_ptl_base_send_request_t* req) { @@ -45,22 +43,31 @@ static inline int mca_pml_teg_send_request_start( size_t offset = req->req_offset; int flags, rc; + /* initialize request state and message sequence number */ + req->super.super.req_state = OMPI_REQUEST_ACTIVE; + req->super.req_sequence = mca_pml_ptl_comm_send_sequence( + req->super.req_comm->c_pml_comm, + req->super.req_peer); + /* start the first fragment */ if(first_fragment_size == 0 || req->req_bytes_packed <= first_fragment_size) { first_fragment_size = req->req_bytes_packed; - flags = (req->req_send_mode == MCA_PML_BASE_SEND_SYNCHRONOUS) ? - MCA_PTL_FLAGS_ACK_MATCHED : 0; + flags = (req->req_send_mode == MCA_PML_BASE_SEND_SYNCHRONOUS) ? + MCA_PTL_FLAGS_ACK_MATCHED : 0; } else { /* require match for first fragment of a multi-fragment */ flags = MCA_PTL_FLAGS_ACK_MATCHED; } - rc = ptl->ptl_put(ptl, req->req_peer, req, offset, first_fragment_size, flags); if(rc != OMPI_SUCCESS) return rc; return OMPI_SUCCESS; } + +void mca_pml_teg_send_request_schedule(mca_ptl_base_send_request_t* req); + + void mca_pml_teg_send_request_progress( struct mca_ptl_t* ptl, mca_ptl_base_send_request_t* send_request, diff --git a/src/mca/pml/teg/src/pml_teg_start.c b/src/mca/pml/teg/src/pml_teg_start.c index 2628df3054..6ca1222266 100644 --- a/src/mca/pml/teg/src/pml_teg_start.c +++ b/src/mca/pml/teg/src/pml_teg_start.c @@ -9,9 +9,79 @@ int mca_pml_teg_start(size_t count, ompi_request_t** requests) size_t i; for(i=0; ireq_persistent == false) + return OMPI_ERR_REQUEST; + /* If the persistent request is currently active - obtain the request lock + * and verify the status is incomplete. if the pml layer has not completed + * the request - mark the request as free called - so that it will be freed + * when the request completes - and create a new request. + */ + + switch(pml_request->super.req_state) { + case OMPI_REQUEST_INVALID: + return OMPI_ERR_REQUEST; + case OMPI_REQUEST_INACTIVE: + break; + case OMPI_REQUEST_ACTIVE: { + + ompi_request_t *request; + THREAD_LOCK(&mca_pml_teg.teg_request_lock); + if (pml_request->req_pml_done == false) { + /* free request after it completes */ + pml_request->req_free_called = true; + } else { + /* can reuse the existing request */ + THREAD_UNLOCK(&mca_pml_teg.teg_request_lock); + break; + } + THREAD_UNLOCK(&mca_pml_teg.teg_request_lock); + + /* allocate a new request */ + switch(pml_request->req_type) { + case MCA_PML_REQUEST_SEND: { + mca_pml_base_send_mode_t sendmode = + ((mca_ptl_base_send_request_t*)pml_request)->req_send_mode; + rc = mca_pml_teg_isend_init( + pml_request->req_addr, + pml_request->req_count, + pml_request->req_datatype, + pml_request->req_peer, + pml_request->req_tag, + sendmode, + pml_request->req_comm, + &request); + if (sendmode == MCA_PML_BASE_SEND_BUFFERED) { + mca_pml_base_bsend_request_init(request, true); + } + break; + } + case MCA_PML_REQUEST_RECV: + rc = mca_pml_teg_irecv_init( + pml_request->req_addr, + pml_request->req_count, + pml_request->req_datatype, + pml_request->req_peer, + pml_request->req_tag, + pml_request->req_comm, + &request); + break; + default: + rc = OMPI_ERR_REQUEST; + break; + } + if(OMPI_SUCCESS != rc) + return rc; + pml_request = (mca_pml_base_request_t*)request; + requests[i] = request; + break; + } + } + + /* start the request */ switch(pml_request->req_type) { case MCA_PML_REQUEST_SEND: if((rc = mca_pml_teg_send_request_start((mca_ptl_base_send_request_t*)pml_request)) @@ -24,7 +94,7 @@ int mca_pml_teg_start(size_t count, ompi_request_t** requests) return rc; break; default: - return OMPI_ERROR; + return OMPI_ERR_REQUEST; } } return OMPI_SUCCESS; diff --git a/src/mca/pml/teg/src/pml_teg_test.c b/src/mca/pml/teg/src/pml_teg_test.c index a313c52443..a51f5685b9 100644 --- a/src/mca/pml/teg/src/pml_teg_test.c +++ b/src/mca/pml/teg/src/pml_teg_test.c @@ -9,6 +9,8 @@ int mca_pml_teg_test( ompi_status_public_t* status) { size_t i; + + ompi_atomic_mb(); for(i=0; ireq_status; - if(false == pml_request->req_persistent) - MCA_PML_TEG_FREE(requests+i); + MCA_PML_TEG_FINI(requests+i); return OMPI_SUCCESS; } } @@ -40,6 +41,8 @@ int mca_pml_teg_test_all( { size_t i; size_t num_completed; + + ompi_atomic_mb(); for(i=0; ireq_mpi_done) @@ -60,16 +63,15 @@ int mca_pml_teg_test_all( statuses[i] = mca_pml_teg.teg_request_null.req_status; } else { statuses[i] = pml_request->req_status; - if(false == pml_request->req_persistent) - MCA_PML_TEG_FREE(requests+i); + MCA_PML_TEG_FINI(requests+i); } } } else { /* free request if required */ for(i=0; ireq_persistent) - MCA_PML_TEG_FREE(requests+i); + if(NULL != pml_request) + MCA_PML_TEG_FINI(requests+i); } } return OMPI_SUCCESS; diff --git a/src/mca/pml/teg/src/pml_teg_wait.c b/src/mca/pml/teg/src/pml_teg_wait.c index 77306c4135..9d483283c4 100644 --- a/src/mca/pml/teg/src/pml_teg_wait.c +++ b/src/mca/pml/teg/src/pml_teg_wait.c @@ -22,7 +22,9 @@ int mca_pml_teg_wait( #endif #if OMPI_HAVE_THREADS + /* poll for completion */ + ompi_atomic_mb(); for(c=0; completed < 0 && c < mca_pml_teg.teg_poll_iterations; c++) { for(i=0; ireq_persistent) { - MCA_PML_TEG_FREE(request); - } + /* return status */ if (NULL != status) { *status = pml_request->req_status; } + + /* return request to pool */ + MCA_PML_TEG_FINI(request); *index = completed; return OMPI_SUCCESS; } @@ -116,17 +118,15 @@ int mca_pml_teg_wait_all( statuses[i] = mca_pml_teg.teg_request_null.req_status; } else { statuses[i] = pml_request->req_status; - if (false == pml_request->req_persistent) { - MCA_PML_TEG_FREE(&requests[i]); - } + MCA_PML_TEG_FINI(requests+i); } } } else { /* free request if required */ for(i=0; ireq_persistent) { - MCA_PML_TEG_FREE(&requests[i]); + if (NULL != pml_request) { + MCA_PML_TEG_FINI(requests+i); } } } diff --git a/src/mca/ptl/base/ptl_base_recvreq.h b/src/mca/ptl/base/ptl_base_recvreq.h index 7b4af4237f..6e037572c4 100644 --- a/src/mca/ptl/base/ptl_base_recvreq.h +++ b/src/mca/ptl/base/ptl_base_recvreq.h @@ -47,6 +47,7 @@ typedef struct mca_ptl_base_recv_request_t mca_ptl_base_recv_request_t; comm, \ persistent) \ { \ + OMPI_REQUEST_INIT(&(request)->super.super); \ (request)->req_bytes_packed = 0; \ (request)->req_bytes_received = 0; \ (request)->req_bytes_delivered = 0; \ diff --git a/src/mca/ptl/base/ptl_base_sendreq.h b/src/mca/ptl/base/ptl_base_sendreq.h index bfc7834c29..93300c5785 100644 --- a/src/mca/ptl/base/ptl_base_sendreq.h +++ b/src/mca/ptl/base/ptl_base_sendreq.h @@ -62,13 +62,13 @@ typedef struct mca_ptl_base_send_request_t mca_ptl_base_send_request_t; mode,\ persistent) \ { \ + OMPI_REQUEST_INIT(&(request)->super.super); \ request->req_offset = 0; \ request->req_bytes_sent = 0; \ request->req_send_mode = mode; \ request->req_peer_match.lval = 0; \ request->req_peer_addr.lval = 0; \ request->req_peer_size = 0; \ - request->super.req_sequence = mca_pml_ptl_comm_send_sequence(comm->c_pml_comm, peer); \ request->super.req_addr = addr; \ request->super.req_count = count; \ request->super.req_datatype = datatype; \ diff --git a/src/mca/ptl/self/src/ptl_self.c b/src/mca/ptl/self/src/ptl_self.c index 6e8ea4e176..880a7c6318 100644 --- a/src/mca/ptl/self/src/ptl_self.c +++ b/src/mca/ptl/self/src/ptl_self.c @@ -147,8 +147,13 @@ void mca_ptl_self_matched( mca_ptl_t* ptl, /* Did you have the same datatype or not ? If yes we can use an optimized version * for the copy function, if not we have to use a temporary buffer to pack/unpack + * + * Note that if this is a buffered send - the data has already been packed into + * a contigous buffer and the convertor on the send request initialized to point + * into this buffer. */ - if( sendreq->super.super.req_datatype == recvreq->super.req_datatype ) { + if( sendreq->super.super.req_datatype == recvreq->super.req_datatype && + sendreq->super.req_send_mode != MCA_PML_BASE_SEND_BUFFERED) { ompi_ddt_copy_content_same_ddt( recvreq->super.req_datatype, recvreq->super.req_count, recvreq->super.req_addr, sendreq->super.super.req_addr ); } else { diff --git a/src/mca/ptl/tcp/src/ptl_tcp_module.c b/src/mca/ptl/tcp/src/ptl_tcp_module.c index d79f74254c..1b99b6238b 100644 --- a/src/mca/ptl/tcp/src/ptl_tcp_module.c +++ b/src/mca/ptl/tcp/src/ptl_tcp_module.c @@ -174,7 +174,7 @@ int mca_ptl_tcp_module_close(void) OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_send_frags); OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_recv_frags); OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_lock); - return OMPI_SUCCESS; + return ompi_event_fini(); } diff --git a/src/mpi/c/address.c b/src/mpi/c/address.c index 4adf4cb23c..64d7bb31ee 100644 --- a/src/mpi/c/address.c +++ b/src/mpi/c/address.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Address"; +static const char FUNC_NAME[] = "MPI_Address"; int MPI_Address(void *location, MPI_Aint *address) { diff --git a/src/mpi/c/allgather.c b/src/mpi/c/allgather.c index 40baf47c62..1d3995dc96 100644 --- a/src/mpi/c/allgather.c +++ b/src/mpi/c/allgather.c @@ -18,7 +18,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Allgather"; +static const char FUNC_NAME[] = "MPI_Allgather"; int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, diff --git a/src/mpi/c/alltoall.c b/src/mpi/c/alltoall.c index 82b8047472..d4c2439586 100644 --- a/src/mpi/c/alltoall.c +++ b/src/mpi/c/alltoall.c @@ -18,7 +18,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Alltoall"; +static const char FUNC_NAME[] = "MPI_Alltoall"; int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype, diff --git a/src/mpi/c/attr_delete.c b/src/mpi/c/attr_delete.c index bd5b2786d7..c16a5db5df 100644 --- a/src/mpi/c/attr_delete.c +++ b/src/mpi/c/attr_delete.c @@ -17,7 +17,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Attr_delete"; +static const char FUNC_NAME[] = "MPI_Attr_delete"; int MPI_Attr_delete(MPI_Comm comm, int keyval) { diff --git a/src/mpi/c/attr_get.c b/src/mpi/c/attr_get.c index 74a8410943..d44f8ccfed 100644 --- a/src/mpi/c/attr_get.c +++ b/src/mpi/c/attr_get.c @@ -17,7 +17,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Attr_get"; +static const char FUNC_NAME[] = "MPI_Attr_get"; int MPI_Attr_get(MPI_Comm comm, int keyval, void *attribute_val, int *flag) { diff --git a/src/mpi/c/attr_put.c b/src/mpi/c/attr_put.c index 77bcf8c445..b429bcdf8e 100644 --- a/src/mpi/c/attr_put.c +++ b/src/mpi/c/attr_put.c @@ -17,7 +17,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Attr_put"; +static const char FUNC_NAME[] = "MPI_Attr_put"; int MPI_Attr_put(MPI_Comm comm, int keyval, void *attribute_val) { diff --git a/src/mpi/c/barrier.c b/src/mpi/c/barrier.c index 382ea1d4b9..652f041d45 100644 --- a/src/mpi/c/barrier.c +++ b/src/mpi/c/barrier.c @@ -18,7 +18,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Barrier"; +static const char FUNC_NAME[] = "MPI_Barrier"; int MPI_Barrier(MPI_Comm comm) diff --git a/src/mpi/c/bcast.c b/src/mpi/c/bcast.c index a134fe35c4..efbfc07d8f 100644 --- a/src/mpi/c/bcast.c +++ b/src/mpi/c/bcast.c @@ -17,7 +17,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Bcast"; +static const char FUNC_NAME[] = "MPI_Bcast"; int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, diff --git a/src/mpi/c/bsend.c b/src/mpi/c/bsend.c index 0330262079..1459885f02 100644 --- a/src/mpi/c/bsend.c +++ b/src/mpi/c/bsend.c @@ -8,6 +8,7 @@ #include "runtime/runtime.h" #include "mpi/c/bindings.h" #include "mca/pml/pml.h" +#include "mca/pml/base/pml_base_bsend.h" #if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES @@ -18,33 +19,54 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Bsend"; + int MPI_Bsend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm) { - int rc; + int rc, index; + ompi_request_t* request; + if (dest == MPI_PROC_NULL) { return MPI_SUCCESS; } if ( MPI_PARAM_CHECK ) { - rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + int rc = MPI_SUCCESS; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Bsend"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } - rc = mca_pml.pml_send(buf, count, type, dest, tag, MCA_PML_BASE_SEND_BUFFERED, comm); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Bsend"); + rc = mca_pml.pml_isend_init(buf, count, type, dest, tag, MCA_PML_BASE_SEND_BUFFERED, comm, &request); + if(OMPI_SUCCESS != rc) + goto error_return; + + rc = mca_pml_base_bsend_request_init(request, false); + if(OMPI_SUCCESS != rc) + goto error_return; + + rc = mca_pml.pml_start(1, &request); + if(OMPI_SUCCESS != rc) + goto error_return; + + rc = mca_pml.pml_wait(1, &request, &index, NULL); + if(OMPI_SUCCESS != rc) { + mca_pml.pml_free(&request); + return rc; + } + +error_return: + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/bsend_init.c b/src/mpi/c/bsend_init.c index a209b6106c..d60ac38046 100644 --- a/src/mpi/c/bsend_init.c +++ b/src/mpi/c/bsend_init.c @@ -8,6 +8,7 @@ #include "runtime/runtime.h" #include "mpi/c/bindings.h" #include "mca/pml/pml.h" +#include "mca/pml/base/pml_base_bsend.h" #if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_Bsend_init = PMPI_Bsend_init @@ -17,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Bsend_init"; + + int MPI_Bsend_init(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm, MPI_Request *request) { @@ -27,25 +31,32 @@ int MPI_Bsend_init(void *buf, int count, MPI_Datatype type, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } else if (request == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Bsend_init"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_isend_init(buf,count,type,dest,tag,MCA_PML_BASE_SEND_BUFFERED,comm,request); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Bsend_init"); + if(OMPI_SUCCESS != rc) + goto error_return; + + rc = mca_pml_base_bsend_request_init(*request, true); + if(OMPI_SUCCESS != rc) + goto error_return; + +error_return: + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/buffer_attach.c b/src/mpi/c/buffer_attach.c index 698159b198..4bd50f5f9d 100644 --- a/src/mpi/c/buffer_attach.c +++ b/src/mpi/c/buffer_attach.c @@ -6,6 +6,10 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "runtime/runtime.h" +#include "mca/pml/pml.h" +#include "mca/pml/base/pml_base_bsend.h" + #if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_Buffer_attach = PMPI_Buffer_attach @@ -16,6 +20,8 @@ #endif -int MPI_Buffer_attach(void *buffer, int size) { - return MPI_SUCCESS; +int MPI_Buffer_attach(void *buffer, int size) +{ + return mca_pml_base_bsend_attach(buffer, size); } + diff --git a/src/mpi/c/buffer_detach.c b/src/mpi/c/buffer_detach.c index 88524d9372..9577cbecbd 100644 --- a/src/mpi/c/buffer_detach.c +++ b/src/mpi/c/buffer_detach.c @@ -6,6 +6,9 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "runtime/runtime.h" +#include "mca/pml/pml.h" +#include "mca/pml/base/pml_base_bsend.h" #if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_Buffer_detach = PMPI_Buffer_detach @@ -15,6 +18,7 @@ #include "mpi/c/profile/defines.h" #endif -int MPI_Buffer_detach(void *buffer, int *size) { - return MPI_SUCCESS; +int MPI_Buffer_detach(void *buffer, int *size) +{ + return mca_pml_base_bsend_detach(buffer, size); } diff --git a/src/mpi/c/comm_create_keyval.c b/src/mpi/c/comm_create_keyval.c index 9afe32d079..57abd03419 100644 --- a/src/mpi/c/comm_create_keyval.c +++ b/src/mpi/c/comm_create_keyval.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Comm_create_keyval"; +static const char FUNC_NAME[] = "MPI_Comm_create_keyval"; int MPI_Comm_create_keyval(MPI_Comm_copy_attr_function *comm_copy_attr_fn, MPI_Comm_delete_attr_function *comm_delete_attr_fn, diff --git a/src/mpi/c/comm_delete_attr.c b/src/mpi/c/comm_delete_attr.c index 177376f73c..3b8a24038a 100644 --- a/src/mpi/c/comm_delete_attr.c +++ b/src/mpi/c/comm_delete_attr.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Comm_delete_attr"; +static const char FUNC_NAME[] = "MPI_Comm_delete_attr"; int MPI_Comm_delete_attr(MPI_Comm comm, int comm_keyval) { diff --git a/src/mpi/c/comm_free_keyval.c b/src/mpi/c/comm_free_keyval.c index 504a657b72..6ab5361702 100644 --- a/src/mpi/c/comm_free_keyval.c +++ b/src/mpi/c/comm_free_keyval.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Comm_free_keyval"; +static const char FUNC_NAME[] = "MPI_Comm_free_keyval"; int MPI_Comm_free_keyval(int *comm_keyval) { diff --git a/src/mpi/c/comm_get_attr.c b/src/mpi/c/comm_get_attr.c index f5c59a6b21..b7537280dd 100644 --- a/src/mpi/c/comm_get_attr.c +++ b/src/mpi/c/comm_get_attr.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Comm_get_attr"; +static const char FUNC_NAME[] = "MPI_Comm_get_attr"; int MPI_Comm_get_attr(MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag) diff --git a/src/mpi/c/comm_set_attr.c b/src/mpi/c/comm_set_attr.c index 6edb20c87e..e05e2c4562 100644 --- a/src/mpi/c/comm_set_attr.c +++ b/src/mpi/c/comm_set_attr.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Comm_set_attr"; +static const char FUNC_NAME[] = "MPI_Comm_set_attr"; int MPI_Comm_set_attr(MPI_Comm comm, int comm_keyval, void *attribute_val) { diff --git a/src/mpi/c/gather.c b/src/mpi/c/gather.c index 14c3f63111..80b9baa678 100644 --- a/src/mpi/c/gather.c +++ b/src/mpi/c/gather.c @@ -17,7 +17,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Gather"; +static const char FUNC_NAME[] = "MPI_Gather"; int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, diff --git a/src/mpi/c/get_address.c b/src/mpi/c/get_address.c index 7f2a4eaee8..2c589be28d 100644 --- a/src/mpi/c/get_address.c +++ b/src/mpi/c/get_address.c @@ -17,7 +17,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Get_address"; +static const char FUNC_NAME[] = "MPI_Get_address"; int MPI_Get_address(void *location, MPI_Aint *address) { diff --git a/src/mpi/c/ibsend.c b/src/mpi/c/ibsend.c index edebeeedc6..d962fa2b64 100644 --- a/src/mpi/c/ibsend.c +++ b/src/mpi/c/ibsend.c @@ -8,6 +8,7 @@ #include "runtime/runtime.h" #include "mpi/c/bindings.h" #include "mca/pml/pml.h" +#include "mca/pml/base/pml_base_bsend.h" #if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES @@ -18,6 +19,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Ibsend"; + + int MPI_Ibsend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm, MPI_Request *request) { @@ -28,25 +32,36 @@ int MPI_Ibsend(void *buf, int count, MPI_Datatype type, int dest, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } else if (request == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Ibsend"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } - rc = mca_pml.pml_isend(buf,count,type,dest,tag,MCA_PML_BASE_SEND_BUFFERED,comm,request); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Ibsend"); + rc = mca_pml.pml_isend_init(buf, count, type, dest, tag, MCA_PML_BASE_SEND_BUFFERED, comm, request); + if(OMPI_SUCCESS != rc) + goto error_return; + + rc = mca_pml_base_bsend_request_init(*request, false); + if(OMPI_SUCCESS != rc) + goto error_return; + + rc = mca_pml.pml_start(1, request); + if(OMPI_SUCCESS != rc) + goto error_return; + +error_return: + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/irecv.c b/src/mpi/c/irecv.c index 75894833f2..0a2044d450 100644 --- a/src/mpi/c/irecv.c +++ b/src/mpi/c/irecv.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Irecv"; + + int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source, int tag, MPI_Comm comm, MPI_Request *request) { @@ -28,25 +31,24 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (((tag < 0) && (tag != MPI_ANY_TAG)) || (tag > MPI_TAG_UB_VALUE)) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (source != MPI_ANY_SOURCE && source != MPI_PROC_NULL && ompi_comm_peer_invalid(comm, source)) { rc = MPI_ERR_RANK; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Irecv"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_irecv(buf,count,type,source,tag,comm,request); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Irecv"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/irsend.c b/src/mpi/c/irsend.c index fefe649b8e..f8b61081d2 100644 --- a/src/mpi/c/irsend.c +++ b/src/mpi/c/irsend.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Irsend"; + + int MPI_Irsend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm, MPI_Request *request) { @@ -28,25 +31,24 @@ int MPI_Irsend(void *buf, int count, MPI_Datatype type, int dest, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } else if (request == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Irsend"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_isend(buf,count,type,dest,tag,MCA_PML_BASE_SEND_READY,comm,request); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Irsend"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/isend.c b/src/mpi/c/isend.c index 7e86fc8a85..2bd161dc38 100644 --- a/src/mpi/c/isend.c +++ b/src/mpi/c/isend.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Isend"; + + int MPI_Isend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm, MPI_Request *request) { @@ -28,25 +31,24 @@ int MPI_Isend(void *buf, int count, MPI_Datatype type, int dest, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } else if (request == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Isend"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_isend(buf,count,type,dest,tag,MCA_PML_BASE_SEND_STANDARD,comm,request); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Isend"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/issend.c b/src/mpi/c/issend.c index e9d76553e5..f4d91da618 100644 --- a/src/mpi/c/issend.c +++ b/src/mpi/c/issend.c @@ -19,6 +19,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Issend"; + + int MPI_Issend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm, MPI_Request *request) { @@ -29,25 +32,24 @@ int MPI_Issend(void *buf, int count, MPI_Datatype type, int dest, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } else if (request == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Issend"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_isend(buf,count,type,dest,tag,MCA_PML_BASE_SEND_SYNCHRONOUS,comm,request); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Issend"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/keyval_create.c b/src/mpi/c/keyval_create.c index e677fdb3e1..b74b8534ac 100644 --- a/src/mpi/c/keyval_create.c +++ b/src/mpi/c/keyval_create.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Keyval_create"; +static const char FUNC_NAME[] = "MPI_Keyval_create"; int MPI_Keyval_create(MPI_Copy_function *copy_attr_fn, MPI_Delete_function *delete_attr_fn, diff --git a/src/mpi/c/keyval_free.c b/src/mpi/c/keyval_free.c index 00be9e1330..ffa3b0fa35 100644 --- a/src/mpi/c/keyval_free.c +++ b/src/mpi/c/keyval_free.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Keyval_free"; +static const char FUNC_NAME[] = "MPI_Keyval_free"; int MPI_Keyval_free(int *keyval) { diff --git a/src/mpi/c/pack.c b/src/mpi/c/pack.c index 320250a7d6..8f8cf90a58 100644 --- a/src/mpi/c/pack.c +++ b/src/mpi/c/pack.c @@ -22,7 +22,7 @@ /* VPS: Just for now, to be removed later */ extern ompi_convertor_t *ompi_convertor; -static char FUNC_NAME[] = "MPI_Pack"; +static const char FUNC_NAME[] = "MPI_Pack"; int MPI_Pack(void *inbuf, int incount, MPI_Datatype datatype, diff --git a/src/mpi/c/pack_size.c b/src/mpi/c/pack_size.c index e8de146750..ab0dff9ffe 100644 --- a/src/mpi/c/pack_size.c +++ b/src/mpi/c/pack_size.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Pack_size"; +static const char FUNC_NAME[] = "MPI_Pack_size"; int MPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int *size) diff --git a/src/mpi/c/recv.c b/src/mpi/c/recv.c index 13c4392e76..5cce88d971 100644 --- a/src/mpi/c/recv.c +++ b/src/mpi/c/recv.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Recv"; + + int MPI_Recv(void *buf, int count, MPI_Datatype type, int source, int tag, MPI_Comm comm, MPI_Status *status) { @@ -34,23 +37,22 @@ int MPI_Recv(void *buf, int count, MPI_Datatype type, int source, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (((tag < 0) && (tag != MPI_ANY_TAG)) || (tag > MPI_TAG_UB_VALUE)) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (source != MPI_ANY_SOURCE && ompi_comm_peer_invalid(comm, source)) { rc = MPI_ERR_RANK; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Recv"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_recv(buf, count, type, source, tag, comm, status); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Recv"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/recv_init.c b/src/mpi/c/recv_init.c index 629591116a..6f7ad4de45 100644 --- a/src/mpi/c/recv_init.c +++ b/src/mpi/c/recv_init.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Recv_init"; + + int MPI_Recv_init(void *buf, int count, MPI_Datatype type, int source, int tag, MPI_Comm comm, MPI_Request *request) { @@ -28,25 +31,24 @@ int MPI_Recv_init(void *buf, int count, MPI_Datatype type, int source, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (((tag < 0) && (tag != MPI_ANY_TAG)) || (tag > MPI_TAG_UB_VALUE)) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (source != MPI_ANY_SOURCE && source != MPI_PROC_NULL && ompi_comm_peer_invalid(comm, source)) { rc = MPI_ERR_RANK; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Recv_init"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_irecv_init(buf,count,type,source,tag,comm,request); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Recv_init"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/request_free.c b/src/mpi/c/request_free.c index 26992a94db..08b0c92671 100644 --- a/src/mpi/c/request_free.c +++ b/src/mpi/c/request_free.c @@ -6,6 +6,8 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "errhandler/errhandler.h" +#include "mca/pml/pml.h" #if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_Request_free = PMPI_Request_free @@ -15,6 +17,22 @@ #include "mpi/c/profile/defines.h" #endif -int MPI_Request_free(MPI_Request *request) { - return MPI_SUCCESS; +static const char FUNC_NAME[] = "MPI_Request_free"; + + +int MPI_Request_free(MPI_Request *request) +{ + int rc; + if( request == NULL ) { + rc = OMPI_ERR_BAD_PARAM; + goto error_return; + } + if( *request == NULL ) { + return MPI_SUCCESS; + } + rc = mca_pml.pml_free(request); + +error_return: + OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } + diff --git a/src/mpi/c/rsend.c b/src/mpi/c/rsend.c index 8ca0669b56..d117797fb7 100644 --- a/src/mpi/c/rsend.c +++ b/src/mpi/c/rsend.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Rsend"; + + int MPI_Rsend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm) { int rc; @@ -27,23 +30,22 @@ int MPI_Rsend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Co if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Rsend"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_send(buf, count, type, dest, tag, MCA_PML_BASE_SEND_READY, comm); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Rsend"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/rsend_init.c b/src/mpi/c/rsend_init.c index 7e6f5468f9..a7542b29b0 100644 --- a/src/mpi/c/rsend_init.c +++ b/src/mpi/c/rsend_init.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Rsend_init"; + + int MPI_Rsend_init(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm, MPI_Request *request) @@ -29,25 +32,24 @@ int MPI_Rsend_init(void *buf, int count, MPI_Datatype type, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } else if (request == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Rsend_init"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_isend_init(buf,count,type,dest,tag,MCA_PML_BASE_SEND_READY,comm,request); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Rsend_init"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/send.c b/src/mpi/c/send.c index 8687d65b67..94a09b7b35 100644 --- a/src/mpi/c/send.c +++ b/src/mpi/c/send.c @@ -18,7 +18,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Send"; +static const char FUNC_NAME[] = "MPI_Send"; int MPI_Send(void *buf, int count, MPI_Datatype type, int dest, @@ -33,8 +33,7 @@ int MPI_Send(void *buf, int count, MPI_Datatype type, int dest, int rc = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, - FUNC_NAME); + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { diff --git a/src/mpi/c/send_init.c b/src/mpi/c/send_init.c index 02fc4c200e..76ff90c970 100644 --- a/src/mpi/c/send_init.c +++ b/src/mpi/c/send_init.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Send_init"; + + int MPI_Send_init(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm, MPI_Request *request) @@ -29,25 +32,24 @@ int MPI_Send_init(void *buf, int count, MPI_Datatype type, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } else if (request == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Send_init"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_isend_init(buf,count,type,dest,tag,MCA_PML_BASE_SEND_STANDARD,comm,request); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Send_init"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/sendrecv.c b/src/mpi/c/sendrecv.c index 2efef544a2..51283715ce 100644 --- a/src/mpi/c/sendrecv.c +++ b/src/mpi/c/sendrecv.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Sendrecv"; + + int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype recvtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype sendtype, int source, int recvtag, @@ -28,10 +31,9 @@ int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype recvtype, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (sendcount < 0) { rc = MPI_ERR_COUNT; } else if (sendtype == MPI_DATATYPE_NULL) { @@ -49,19 +51,19 @@ int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype recvtype, } else if (((recvtag < 0) && (recvtag != MPI_ANY_TAG)) || (recvtag > MPI_TAG_UB_VALUE)) { rc = MPI_ERR_TAG; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Sendrecv"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } if (source != MPI_PROC_NULL) { /* post recv */ rc = mca_pml.pml_irecv(recvbuf, recvcount, recvtype, source, recvtag, comm, &req); - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Sendrecv"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } if (dest != MPI_PROC_NULL) { /* send */ rc = mca_pml.pml_send(sendbuf, sendcount, sendtype, dest, sendtag, MCA_PML_BASE_SEND_STANDARD, comm); - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Sendrecv"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } if (source != MPI_PROC_NULL) { /* wait for recv */ @@ -76,5 +78,5 @@ int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype recvtype, status->_count = 0; rc = MPI_SUCCESS; } - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Sendrecv"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/ssend.c b/src/mpi/c/ssend.c index 436fbf4698..7051ee751a 100644 --- a/src/mpi/c/ssend.c +++ b/src/mpi/c/ssend.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Ssend"; + + int MPI_Ssend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm) { int rc; @@ -27,23 +30,22 @@ int MPI_Ssend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Co if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Ssend"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_send(buf, count, type, dest, tag, MCA_PML_BASE_SEND_SYNCHRONOUS, comm); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Ssend"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/ssend_init.c b/src/mpi/c/ssend_init.c index b1a7bdcf3d..4864b388ef 100644 --- a/src/mpi/c/ssend_init.c +++ b/src/mpi/c/ssend_init.c @@ -18,6 +18,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Ssend_init"; + + int MPI_Ssend_init(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm, MPI_Request *request) @@ -29,25 +32,24 @@ int MPI_Ssend_init(void *buf, int count, MPI_Datatype type, if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (ompi_comm_invalid(comm)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } else if (count < 0) { rc = MPI_ERR_COUNT; } else if (type == MPI_DATATYPE_NULL) { rc = MPI_ERR_TYPE; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; - } else if (ompi_comm_invalid(comm)) { - rc = MPI_ERR_COMM; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } else if (request == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Ssend_init"); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } rc = mca_pml.pml_isend_init(buf,count,type,dest,tag,MCA_PML_BASE_SEND_SYNCHRONOUS,comm,request); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Ssend_init"); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/src/mpi/c/test.c b/src/mpi/c/test.c index 840f7377e6..8e19d0f2e9 100644 --- a/src/mpi/c/test.c +++ b/src/mpi/c/test.c @@ -18,22 +18,21 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Test"; + + int MPI_Test(MPI_Request *request, int *completed, MPI_Status *status) { int rc, index; if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; - } else if (request == NULL) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (request == NULL) { rc = MPI_ERR_REQUEST; } else if (completed == NULL) { rc = MPI_ERR_ARG; } - /* JMS: Tim will fix to invoke on the communicator/window/file - on the request (i.e., not COMM_WORLD), if the request is - available/valid */ - OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, "MPI_Test"); + OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } if(*request == NULL) { @@ -50,6 +49,6 @@ int MPI_Test(MPI_Request *request, int *completed, MPI_Status *status) } /* JMS: Tim will fix to invoke on the communicator/window/file on the request (i.e., not COMM_WORLD) */ - OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, "MPI_Test"); + OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } diff --git a/src/mpi/c/test_cancelled.c b/src/mpi/c/test_cancelled.c index 459f7ed509..322aa3b79e 100644 --- a/src/mpi/c/test_cancelled.c +++ b/src/mpi/c/test_cancelled.c @@ -16,5 +16,6 @@ #endif int MPI_Test_cancelled(MPI_Status *status, int *flag) { + *flag = 0; return MPI_SUCCESS; } diff --git a/src/mpi/c/testany.c b/src/mpi/c/testany.c index 937e11c28b..bdf0a607c8 100644 --- a/src/mpi/c/testany.c +++ b/src/mpi/c/testany.c @@ -17,22 +17,24 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Testany"; + + int MPI_Testany(int count, MPI_Request requests[], int *index, int *completed, MPI_Status *status) { int rc; if ( MPI_PARAM_CHECK ) { int rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; - } else if (NULL == requests) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (NULL == requests) { rc = MPI_ERR_REQUEST; } else if (NULL == index) { rc = MPI_ERR_ARG; } - OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, "MPI_Testany"); + OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } rc = mca_pml.pml_test(count, requests, index, completed, status); - OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, "MPI_Testany"); + OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } diff --git a/src/mpi/c/testsome.c b/src/mpi/c/testsome.c index e7b9eedbfa..91734ff2fb 100644 --- a/src/mpi/c/testsome.c +++ b/src/mpi/c/testsome.c @@ -17,6 +17,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Testsome"; + + int MPI_Testsome(int incount, MPI_Request requests[], int *outcount, int indices[], MPI_Status statuses[]) @@ -24,19 +27,18 @@ int MPI_Testsome(int incount, MPI_Request requests[], int rc, index, completed; if ( MPI_PARAM_CHECK ) { int rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; - } else if (NULL == requests) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (NULL == requests) { rc = MPI_ERR_REQUEST; } else if (NULL == indices) { rc = MPI_ERR_ARG; } - OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, "MPI_Testsome"); + OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } /* optimize this in the future */ rc = mca_pml.pml_test(incount, requests, &index, &completed, statuses); - OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, "MPI_Testsome"); + OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME); if(completed) { *outcount = 1; indices[0] = index; diff --git a/src/mpi/c/type_commit.c b/src/mpi/c/type_commit.c index b6390603da..11a689d721 100644 --- a/src/mpi/c/type_commit.c +++ b/src/mpi/c/type_commit.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_commit"; +static const char FUNC_NAME[] = "MPI_Type_commit"; int MPI_Type_commit(MPI_Datatype *type) diff --git a/src/mpi/c/type_contiguous.c b/src/mpi/c/type_contiguous.c index fad25b3b86..8674aef495 100644 --- a/src/mpi/c/type_contiguous.c +++ b/src/mpi/c/type_contiguous.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_contiguous"; +static const char FUNC_NAME[] = "MPI_Type_contiguous"; int MPI_Type_contiguous(int count, diff --git a/src/mpi/c/type_create_hindexed.c b/src/mpi/c/type_create_hindexed.c index 563c962294..cc9031fe3a 100644 --- a/src/mpi/c/type_create_hindexed.c +++ b/src/mpi/c/type_create_hindexed.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_create_hindexed"; +static const char FUNC_NAME[] = "MPI_Type_create_hindexed"; int MPI_Type_create_hindexed(int count, diff --git a/src/mpi/c/type_create_hvector.c b/src/mpi/c/type_create_hvector.c index 058faf64d2..65a6500f35 100644 --- a/src/mpi/c/type_create_hvector.c +++ b/src/mpi/c/type_create_hvector.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_create_hvector"; +static const char FUNC_NAME[] = "MPI_Type_create_hvector"; int MPI_Type_create_hvector(int count, diff --git a/src/mpi/c/type_create_indexed_block.c b/src/mpi/c/type_create_indexed_block.c index ae026ea9db..68820fb3ec 100644 --- a/src/mpi/c/type_create_indexed_block.c +++ b/src/mpi/c/type_create_indexed_block.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_create_indexed_block"; +static const char FUNC_NAME[] = "MPI_Type_create_indexed_block"; int MPI_Type_create_indexed_block(int count, diff --git a/src/mpi/c/type_create_keyval.c b/src/mpi/c/type_create_keyval.c index f33ca7cf75..c98ab52f44 100644 --- a/src/mpi/c/type_create_keyval.c +++ b/src/mpi/c/type_create_keyval.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_create_keyval"; +static const char FUNC_NAME[] = "MPI_Type_create_keyval"; int MPI_Type_create_keyval(MPI_Type_copy_attr_function *type_copy_attr_fn, diff --git a/src/mpi/c/type_create_resized.c b/src/mpi/c/type_create_resized.c index a9870fcf2b..7eef0407ff 100644 --- a/src/mpi/c/type_create_resized.c +++ b/src/mpi/c/type_create_resized.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_create_resized"; +static const char FUNC_NAME[] = "MPI_Type_create_resized"; int MPI_Type_create_resized(MPI_Datatype oldtype, diff --git a/src/mpi/c/type_create_struct.c b/src/mpi/c/type_create_struct.c index acc4140c49..a5449135dc 100644 --- a/src/mpi/c/type_create_struct.c +++ b/src/mpi/c/type_create_struct.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_create_struct"; +static const char FUNC_NAME[] = "MPI_Type_create_struct"; int MPI_Type_create_struct(int count, diff --git a/src/mpi/c/type_delete_attr.c b/src/mpi/c/type_delete_attr.c index ddd9aba0d2..d7b5e7181a 100644 --- a/src/mpi/c/type_delete_attr.c +++ b/src/mpi/c/type_delete_attr.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_delete_attr"; +static const char FUNC_NAME[] = "MPI_Type_delete_attr"; int MPI_Type_delete_attr (MPI_Datatype type, int type_keyval) diff --git a/src/mpi/c/type_dup.c b/src/mpi/c/type_dup.c index a97598118f..e27bb58051 100644 --- a/src/mpi/c/type_dup.c +++ b/src/mpi/c/type_dup.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_dup"; +static const char FUNC_NAME[] = "MPI_Type_dup"; int MPI_Type_dup (MPI_Datatype type, diff --git a/src/mpi/c/type_free.c b/src/mpi/c/type_free.c index c8c824272e..9b892a6695 100644 --- a/src/mpi/c/type_free.c +++ b/src/mpi/c/type_free.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_free"; +static const char FUNC_NAME[] = "MPI_Type_free"; int MPI_Type_free(MPI_Datatype *type) diff --git a/src/mpi/c/type_free_keyval.c b/src/mpi/c/type_free_keyval.c index fe5892a516..2b4e0f9d8c 100644 --- a/src/mpi/c/type_free_keyval.c +++ b/src/mpi/c/type_free_keyval.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_free_keyval"; +static const char FUNC_NAME[] = "MPI_Type_free_keyval"; int MPI_Type_free_keyval(int *type_keyval) diff --git a/src/mpi/c/type_get_attr.c b/src/mpi/c/type_get_attr.c index 43f0d2488e..daffaaa8e3 100644 --- a/src/mpi/c/type_get_attr.c +++ b/src/mpi/c/type_get_attr.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_get_attr"; +static const char FUNC_NAME[] = "MPI_Type_get_attr"; int MPI_Type_get_attr (MPI_Datatype type, diff --git a/src/mpi/c/type_get_contents.c b/src/mpi/c/type_get_contents.c index 229f1a6890..46bc78a880 100644 --- a/src/mpi/c/type_get_contents.c +++ b/src/mpi/c/type_get_contents.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_get_contents"; +static const char FUNC_NAME[] = "MPI_Type_get_contents"; int MPI_Type_get_contents(MPI_Datatype mtype, diff --git a/src/mpi/c/type_get_envelope.c b/src/mpi/c/type_get_envelope.c index d5276ebb17..c67de6f410 100644 --- a/src/mpi/c/type_get_envelope.c +++ b/src/mpi/c/type_get_envelope.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_get_envelope"; +static const char FUNC_NAME[] = "MPI_Type_get_envelope"; int MPI_Type_get_envelope(MPI_Datatype type, diff --git a/src/mpi/c/type_get_extent.c b/src/mpi/c/type_get_extent.c index 48058d0043..95fba1c6f9 100644 --- a/src/mpi/c/type_get_extent.c +++ b/src/mpi/c/type_get_extent.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_get_extent"; +static const char FUNC_NAME[] = "MPI_Type_get_extent"; int MPI_Type_get_extent(MPI_Datatype type, MPI_Aint *lb, MPI_Aint *extent) diff --git a/src/mpi/c/type_get_true_extent.c b/src/mpi/c/type_get_true_extent.c index 079994f4ce..1750926270 100644 --- a/src/mpi/c/type_get_true_extent.c +++ b/src/mpi/c/type_get_true_extent.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_get_true_extent"; +static const char FUNC_NAME[] = "MPI_Type_get_true_extent"; int MPI_Type_get_true_extent(MPI_Datatype datatype, diff --git a/src/mpi/c/type_indexed.c b/src/mpi/c/type_indexed.c index 7f50bd23b2..21079f2316 100644 --- a/src/mpi/c/type_indexed.c +++ b/src/mpi/c/type_indexed.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_indexed"; +static const char FUNC_NAME[] = "MPI_Type_indexed"; int MPI_Type_indexed(int count, diff --git a/src/mpi/c/type_match_size.c b/src/mpi/c/type_match_size.c index f06067e9a1..5dd3a0c8d9 100644 --- a/src/mpi/c/type_match_size.c +++ b/src/mpi/c/type_match_size.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_match_size"; +static const char FUNC_NAME[] = "MPI_Type_match_size"; int MPI_Type_match_size(int typeclass, int size, MPI_Datatype *type) diff --git a/src/mpi/c/type_set_attr.c b/src/mpi/c/type_set_attr.c index 65015108c5..aad02e5f44 100644 --- a/src/mpi/c/type_set_attr.c +++ b/src/mpi/c/type_set_attr.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_set_attr"; +static const char FUNC_NAME[] = "MPI_Type_set_attr"; int MPI_Type_set_attr (MPI_Datatype type, diff --git a/src/mpi/c/type_size.c b/src/mpi/c/type_size.c index b5e6129ee0..af646123bc 100644 --- a/src/mpi/c/type_size.c +++ b/src/mpi/c/type_size.c @@ -18,7 +18,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_size"; +static const char FUNC_NAME[] = "MPI_Type_size"; int MPI_Type_size(MPI_Datatype type, int *size) diff --git a/src/mpi/c/type_vector.c b/src/mpi/c/type_vector.c index 1766e82454..70382f37bf 100644 --- a/src/mpi/c/type_vector.c +++ b/src/mpi/c/type_vector.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Type_vector"; +static const char FUNC_NAME[] = "MPI_Type_vector"; int MPI_Type_vector(int count, diff --git a/src/mpi/c/unpack.c b/src/mpi/c/unpack.c index 682c21c6ea..bb9512e864 100644 --- a/src/mpi/c/unpack.c +++ b/src/mpi/c/unpack.c @@ -19,7 +19,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Unpack"; +static const char FUNC_NAME[] = "MPI_Unpack"; int MPI_Unpack(void *inbuf, int insize, int *position, diff --git a/src/mpi/c/wait.c b/src/mpi/c/wait.c index 31733bffde..24a123811b 100644 --- a/src/mpi/c/wait.c +++ b/src/mpi/c/wait.c @@ -17,20 +17,19 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Wait"; + + int MPI_Wait(MPI_Request *request, MPI_Status *status) { int index, rc; if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; - } else if (request == NULL) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (request == NULL) { rc = MPI_ERR_REQUEST; } - /* JMS: Tim will fix to invoke on the communicator/window/file - on the request (i.e., not COMM_WORLD), if the request is - available/valid */ - OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, "MPI_Wait"); + OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } if (NULL == *request) { @@ -42,9 +41,8 @@ int MPI_Wait(MPI_Request *request, MPI_Status *status) } return MPI_SUCCESS; } + rc = mca_pml.pml_wait(1, request, &index, status); - /* JMS: Tim will fix to invoke on the communicator/window/file on - the request (i.e., not COMM_WORLD) */ - OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, "MPI_Wait"); + OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } diff --git a/src/mpi/c/waitall.c b/src/mpi/c/waitall.c index 73cf65e3a6..7fa8714416 100644 --- a/src/mpi/c/waitall.c +++ b/src/mpi/c/waitall.c @@ -17,20 +17,21 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Waitall"; + int MPI_Waitall(int count, MPI_Request *requests, MPI_Status *statuses) { int rc; if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; - } else if (requests == NULL) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (requests == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, "MPI_Waitall"); + OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } rc = mca_pml.pml_wait_all(count, requests, statuses); - OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, "MPI_Waitall"); + OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } diff --git a/src/mpi/c/waitany.c b/src/mpi/c/waitany.c index c713980662..a963a6326c 100644 --- a/src/mpi/c/waitany.c +++ b/src/mpi/c/waitany.c @@ -17,19 +17,21 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Waitany"; + + int MPI_Waitany(int count, MPI_Request *requests, int *index, MPI_Status *status) { int rc; if ( MPI_PARAM_CHECK ) { rc = MPI_SUCCESS; - if ( OMPI_MPI_INVALID_STATE ) { - rc = MPI_ERR_INTERN; - } else if (requests == NULL) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (requests == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, "MPI_Waitany"); + OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } rc = mca_pml.pml_wait(count, requests, index, status); - OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, "MPI_Waitany"); + OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } diff --git a/src/mpi/c/waitsome.c b/src/mpi/c/waitsome.c index a0093d0b5f..2ea1be0ce6 100644 --- a/src/mpi/c/waitsome.c +++ b/src/mpi/c/waitsome.c @@ -18,6 +18,8 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Waitsome"; + int MPI_Waitsome(int incount, MPI_Request *requests, int *outcount, int *indices, @@ -28,17 +30,16 @@ int MPI_Waitsome(int incount, MPI_Request *requests, if ( MPI_PARAM_CHECK ) { int rc = MPI_SUCCESS; - if (ompi_mpi_finalized) { - rc = MPI_ERR_INTERN; - } else if (requests == NULL) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (requests == NULL) { rc = MPI_ERR_REQUEST; } - OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, "MPI_Waitsome"); + OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } /* optimize this in the future */ rc = mca_pml.pml_wait(incount, requests, &index, statuses); - OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, "MPI_Waitsome"); + OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME); *outcount = 1; indices[0] = index; return MPI_SUCCESS; diff --git a/src/mpi/c/win_create_keyval.c b/src/mpi/c/win_create_keyval.c index e281169383..6a3022770b 100644 --- a/src/mpi/c/win_create_keyval.c +++ b/src/mpi/c/win_create_keyval.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Win_create_keyval"; +static const char FUNC_NAME[] = "MPI_Win_create_keyval"; int MPI_Win_create_keyval(MPI_Win_copy_attr_function *win_copy_attr_fn, MPI_Win_delete_attr_function *win_delete_attr_fn, diff --git a/src/mpi/c/win_delete_attr.c b/src/mpi/c/win_delete_attr.c index 79044e2b44..0f46311272 100644 --- a/src/mpi/c/win_delete_attr.c +++ b/src/mpi/c/win_delete_attr.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Win_delete_attr"; +static const char FUNC_NAME[] = "MPI_Win_delete_attr"; int MPI_Win_delete_attr(MPI_Win win, int win_keyval) { diff --git a/src/mpi/c/win_free_keyval.c b/src/mpi/c/win_free_keyval.c index ac824ab7c3..6813897758 100644 --- a/src/mpi/c/win_free_keyval.c +++ b/src/mpi/c/win_free_keyval.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Win_free_keyval"; +static const char FUNC_NAME[] = "MPI_Win_free_keyval"; int MPI_Win_free_keyval(int *win_keyval) { diff --git a/src/mpi/c/win_get_attr.c b/src/mpi/c/win_get_attr.c index a660345a5a..99bdfab677 100644 --- a/src/mpi/c/win_get_attr.c +++ b/src/mpi/c/win_get_attr.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Win_get_attr"; +static const char FUNC_NAME[] = "MPI_Win_get_attr"; int MPI_Win_get_attr(MPI_Win win, int win_keyval, void *attribute_val, int *flag) { diff --git a/src/mpi/c/win_set_attr.c b/src/mpi/c/win_set_attr.c index cdc9060396..c07659e2a7 100644 --- a/src/mpi/c/win_set_attr.c +++ b/src/mpi/c/win_set_attr.c @@ -16,7 +16,7 @@ #include "mpi/c/profile/defines.h" #endif -static char FUNC_NAME[] = "MPI_Win_set_attr"; +static const char FUNC_NAME[] = "MPI_Win_set_attr"; int MPI_Win_set_attr(MPI_Win win, int win_keyval, void *attribute_val) { diff --git a/src/mpi/c/win_wait.c b/src/mpi/c/win_wait.c index 14f4a515f8..8bf10ee68d 100644 --- a/src/mpi/c/win_wait.c +++ b/src/mpi/c/win_wait.c @@ -15,6 +15,9 @@ #include "mpi/c/profile/defines.h" #endif +static const char FUNC_NAME[] = "MPI_Win_wait"; + + int MPI_Win_wait(MPI_Win win) { return MPI_SUCCESS; } diff --git a/src/mpi/f77/profile/Makefile.am b/src/mpi/f77/profile/Makefile.am index 81e227ff51..6dfd027a6d 100644 --- a/src/mpi/f77/profile/Makefile.am +++ b/src/mpi/f77/profile/Makefile.am @@ -26,6 +26,7 @@ endif noinst_LTLIBRARIES = $(pmpi_lib) nodist_libmpi_f77_pmpi_la_SOURCES = \ + pattr_fn_f.c \ pabort_f.c \ paccumulate_f.c \ padd_error_class_f.c \ diff --git a/src/request/request.c b/src/request/request.c index bf9ca62406..25af0f4ae3 100644 --- a/src/request/request.c +++ b/src/request/request.c @@ -7,12 +7,13 @@ static void ompi_request_construct(ompi_request_t* req) { - req->req_mode = OMPI_REQUEST_INVALID; + req->req_state = OMPI_REQUEST_INVALID; } static void ompi_request_destruct(ompi_request_t* req) { + req->req_state = OMPI_REQUEST_INVALID; } diff --git a/src/request/request.h b/src/request/request.h index 7afdfe1895..6ecd7d2bd3 100644 --- a/src/request/request.h +++ b/src/request/request.h @@ -23,22 +23,24 @@ typedef enum { OMPI_REQUEST_INACTIVE, OMPI_REQUEST_ACTIVE, OMPI_REQUEST_CANCELLED -} ompi_request_mode_t; +} ompi_request_state_t; struct ompi_request_t { ompi_list_item_t super; ompi_request_type_t req_type; - ompi_request_mode_t req_mode; + volatile int req_state; }; typedef struct ompi_request_t ompi_request_t; #define OMPI_REQUEST_INIT(request) \ do { \ + (request)->req_state = OMPI_REQUEST_INACTIVE; \ } while(0); #define OMPI_REQUEST_FINI(request) \ do { \ + (request)->req_state = OMPI_REQUEST_INVALID; \ } while(0); diff --git a/src/runtime/ompi_progress.c b/src/runtime/ompi_progress.c index 4968b2112c..f8ebb2121f 100644 --- a/src/runtime/ompi_progress.c +++ b/src/runtime/ompi_progress.c @@ -6,5 +6,6 @@ void ompi_progress(void) { ompi_event_loop(OMPI_EVLOOP_ONCE); + mca_pml.pml_progress(); }