2004-11-22 03:37:56 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2007-07-11 02:16:38 +04:00
|
|
|
* Copyright (c) 2004-2007 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2007-01-19 02:32:39 +03:00
|
|
|
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-11-22 03:37:56 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-20 05:03:09 +04:00
|
|
|
#include "ompi_config.h"
|
2005-07-04 02:45:48 +04:00
|
|
|
#include "opal/threads/mutex.h"
|
|
|
|
#include "opal/threads/condition.h"
|
- Split the datatype engine into two parts: an MPI specific part in
OMPI
and a language agnostic part in OPAL. The convertor is completely
moved into OPAL. This offers several benefits as described in RFC
http://www.open-mpi.org/community/lists/devel/2009/07/6387.php
namely:
- Fewer basic types (int* and float* types, boolean and wchar
- Fixing naming scheme to ompi-nomenclature.
- Usability outside of the ompi-layer.
- Due to the fixed nature of simple opal types, their information is
completely
known at compile time and therefore constified
- With fewer datatypes (22), the actual sizes of bit-field types may be
reduced
from 64 to 32 bits, allowing reorganizing the opal_datatype
structure, eliminating holes and keeping data required in convertor
(upon send/recv) in one cacheline...
This has implications to the convertor-datastructure and other parts
of the code.
- Several performance tests have been run, the netpipe latency does not
change with
this patch on Linux/x86-64 on the smoky cluster.
- Extensive tests have been done to verify correctness (no new
regressions) using:
1. mpi_test_suite on linux/x86-64 using clean ompi-trunk and
ompi-ddt:
a. running both trunk and ompi-ddt resulted in no differences
(except for MPI_SHORT_INT and MPI_TYPE_MIX_LB_UB do now run
correctly).
b. with --enable-memchecker and running under valgrind (one buglet
when run with static found in test-suite, commited)
2. ibm testsuite on linux/x86-64 using clean ompi-trunk and ompi-ddt:
all passed (except for the dynamic/ tests failed!! as trunk/MTT)
3. compilation and usage of HDF5 tests on Jaguar using PGI and
PathScale compilers.
4. compilation and usage on Scicortex.
- Please note, that for the heterogeneous case, (-m32 compiled
binaries/ompi), neither
ompi-trunk, nor ompi-ddt branch would successfully launch.
This commit was SVN r21641.
2009-07-13 08:56:31 +04:00
|
|
|
#include "ompi/datatype/ompi_datatype.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mca/allocator/base/base.h"
|
|
|
|
#include "ompi/mca/allocator/allocator.h"
|
|
|
|
#include "opal/mca/base/mca_base_param.h"
|
|
|
|
#include "ompi/mca/pml/pml.h"
|
|
|
|
#include "ompi/mca/pml/base/pml_base_request.h"
|
|
|
|
#include "ompi/mca/pml/base/pml_base_sendreq.h"
|
|
|
|
#include "ompi/mca/pml/base/pml_base_bsend.h"
|
|
|
|
#include "ompi/mca/mpool/mpool.h"
|
2005-06-25 01:12:38 +04:00
|
|
|
|
2008-02-11 00:49:19 +03:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif /* HAVE_UNISTD_H */
|
2005-06-25 01:12:38 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
static opal_mutex_t mca_pml_bsend_mutex; /* lock for thread safety */
|
|
|
|
static opal_condition_t mca_pml_bsend_condition; /* condition variable to block on detach */
|
2004-08-02 04:24:22 +04:00
|
|
|
static mca_allocator_base_component_t* mca_pml_bsend_allocator_component;
|
|
|
|
static mca_allocator_base_module_t* mca_pml_bsend_allocator; /* sub-allocator to manage users buffer */
|
2007-01-19 02:32:39 +03:00
|
|
|
static size_t mca_pml_bsend_usersize; /* user provided buffer size */
|
|
|
|
static unsigned char *mca_pml_bsend_userbase; /* user provided buffer base */
|
|
|
|
static unsigned char *mca_pml_bsend_base; /* adjusted base of user buffer */
|
|
|
|
static unsigned char *mca_pml_bsend_addr; /* current offset into user buffer */
|
|
|
|
static size_t mca_pml_bsend_size; /* adjusted size of user buffer */
|
2004-06-24 20:47:00 +04:00
|
|
|
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 */
|
2005-05-24 02:06:50 +04:00
|
|
|
static int32_t mca_pml_bsend_init = 0;
|
2004-06-24 20:47:00 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Routine to return pages to sub-allocator as needed
|
|
|
|
*/
|
2005-06-21 21:10:28 +04:00
|
|
|
static void* mca_pml_bsend_alloc_segment(
|
|
|
|
struct mca_mpool_base_module_t* module,
|
|
|
|
size_t* size_inout,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t** registration)
|
2004-06-24 20:47:00 +04:00
|
|
|
{
|
|
|
|
void *addr;
|
|
|
|
size_t size = *size_inout;
|
|
|
|
if(mca_pml_bsend_addr + size > mca_pml_bsend_base + mca_pml_bsend_size) {
|
2004-10-20 02:00:19 +04:00
|
|
|
return NULL;
|
2004-06-24 20:47:00 +04:00
|
|
|
}
|
2004-10-20 02:00:19 +04:00
|
|
|
/* allocate all that is left */
|
|
|
|
size = mca_pml_bsend_size - (mca_pml_bsend_addr - mca_pml_bsend_base);
|
2004-06-24 20:47:00 +04:00
|
|
|
addr = mca_pml_bsend_addr;
|
|
|
|
mca_pml_bsend_addr += size;
|
|
|
|
*size_inout = size;
|
2005-07-12 06:00:42 +04:00
|
|
|
if (NULL != registration) *registration = NULL;
|
2004-06-24 20:47:00 +04:00
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* One time initialization at startup
|
|
|
|
*/
|
2005-03-27 17:05:23 +04:00
|
|
|
int mca_pml_base_bsend_init(bool thread_safe)
|
2004-06-24 20:47:00 +04:00
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
size_t tmp;
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
if(OPAL_THREAD_ADD32(&mca_pml_bsend_init, 1) > 1)
|
2005-05-24 02:06:50 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
|
2004-06-24 20:47:00 +04:00
|
|
|
/* initialize static objects */
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_pml_bsend_mutex, opal_mutex_t);
|
|
|
|
OBJ_CONSTRUCT(&mca_pml_bsend_condition, opal_condition_t);
|
2004-06-24 20:47:00 +04:00
|
|
|
|
|
|
|
/* lookup name of the allocator to use for buffered sends */
|
2012-10-30 23:45:18 +04:00
|
|
|
(void) mca_base_param_reg_string_name ("pml", "base_bsend_allocator", NULL, false, false,
|
|
|
|
"basic", &name);
|
|
|
|
|
2004-06-24 20:47:00 +04:00
|
|
|
if(NULL == (mca_pml_bsend_allocator_component = mca_allocator_component_lookup(name))) {
|
|
|
|
free(name);
|
|
|
|
return OMPI_ERR_BUFFER;
|
|
|
|
}
|
|
|
|
free(name);
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2007-04-26 12:16:07 +04:00
|
|
|
int mca_pml_base_bsend_fini(void)
|
2004-06-24 20:47:00 +04:00
|
|
|
{
|
2005-07-04 02:45:48 +04:00
|
|
|
if(OPAL_THREAD_ADD32(&mca_pml_bsend_init,-1) > 0)
|
2005-05-24 02:06:50 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
|
2004-06-24 20:47:00 +04:00
|
|
|
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)
|
|
|
|
{
|
2007-01-19 02:32:39 +03:00
|
|
|
int align;
|
|
|
|
|
2005-04-18 23:33:50 +04:00
|
|
|
bool thread_safe = ompi_mpi_thread_multiple;
|
2004-06-24 20:47:00 +04:00
|
|
|
if(NULL == addr || size <= 0) {
|
|
|
|
return OMPI_ERR_BUFFER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for buffer already attached */
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
if(NULL != mca_pml_bsend_allocator) {
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
return OMPI_ERR_BUFFER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try to create an instance of the allocator - to determine thread safety level */
|
2005-05-31 21:06:55 +04:00
|
|
|
mca_pml_bsend_allocator = mca_pml_bsend_allocator_component->allocator_init(thread_safe, mca_pml_bsend_alloc_segment, NULL, NULL);
|
2004-06-24 20:47:00 +04:00
|
|
|
if(NULL == mca_pml_bsend_allocator) {
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
return OMPI_ERR_BUFFER;
|
|
|
|
}
|
|
|
|
|
2007-01-19 02:32:39 +03:00
|
|
|
/*
|
|
|
|
* Save away what the user handed in. This is done in case the
|
|
|
|
* base and size are modified for alignment issues.
|
|
|
|
*/
|
2007-01-24 03:50:24 +03:00
|
|
|
mca_pml_bsend_userbase = (unsigned char*)addr;
|
2007-01-19 02:32:39 +03:00
|
|
|
mca_pml_bsend_usersize = size;
|
|
|
|
/*
|
|
|
|
* Align to pointer boundaries. The bsend overhead is large enough
|
|
|
|
* to account for this. Compute any alignment that needs to be done.
|
|
|
|
*/
|
|
|
|
align = sizeof(void *) - ((size_t)addr & (sizeof(void *) - 1));
|
|
|
|
|
2004-06-24 20:47:00 +04:00
|
|
|
/* setup local variables */
|
2007-01-19 02:32:39 +03:00
|
|
|
mca_pml_bsend_base = (unsigned char *)addr + align;
|
|
|
|
mca_pml_bsend_addr = (unsigned char *)addr + align;
|
|
|
|
mca_pml_bsend_size = size - align;
|
2004-06-24 20:47:00 +04:00
|
|
|
mca_pml_bsend_count = 0;
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* User-level call to detach buffer
|
|
|
|
*/
|
|
|
|
int mca_pml_base_bsend_detach(void* addr, int* size)
|
|
|
|
{
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
|
|
|
|
/* is buffer attached */
|
|
|
|
if(NULL == mca_pml_bsend_allocator) {
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
return OMPI_ERR_BUFFER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wait on any pending requests */
|
|
|
|
while(mca_pml_bsend_count != 0)
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_condition_wait(&mca_pml_bsend_condition, &mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
|
|
|
|
/* 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)
|
2007-01-19 02:32:39 +03:00
|
|
|
*((void**)addr) = mca_pml_bsend_userbase;
|
2004-06-24 20:47:00 +04:00
|
|
|
if(NULL != size)
|
2007-01-19 02:32:39 +03:00
|
|
|
*size = (int)mca_pml_bsend_usersize;
|
2004-06-24 20:47:00 +04:00
|
|
|
|
|
|
|
/* reset local variables */
|
2007-01-19 02:32:39 +03:00
|
|
|
mca_pml_bsend_userbase = NULL;
|
|
|
|
mca_pml_bsend_usersize = 0;
|
2004-06-24 20:47:00 +04:00
|
|
|
mca_pml_bsend_base = NULL;
|
|
|
|
mca_pml_bsend_addr = NULL;
|
|
|
|
mca_pml_bsend_size = 0;
|
|
|
|
mca_pml_bsend_count = 0;
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-13 21:28:06 +04:00
|
|
|
/*
|
|
|
|
* pack send buffer into buffer
|
2004-09-19 11:12:29 +04:00
|
|
|
*/
|
|
|
|
|
2005-04-13 21:28:06 +04:00
|
|
|
int mca_pml_base_bsend_request_start(ompi_request_t* request)
|
2004-06-24 20:47:00 +04:00
|
|
|
{
|
2004-06-24 23:28:30 +04:00
|
|
|
mca_pml_base_send_request_t* sendreq = (mca_pml_base_send_request_t*)request;
|
2005-04-13 21:28:06 +04:00
|
|
|
struct iovec iov;
|
2005-06-08 23:10:15 +04:00
|
|
|
unsigned int iov_count;
|
|
|
|
size_t max_data;
|
2006-10-27 03:11:26 +04:00
|
|
|
int rc;
|
2005-04-13 21:28:06 +04:00
|
|
|
|
2006-07-06 21:58:25 +04:00
|
|
|
if(sendreq->req_bytes_packed > 0) {
|
2005-04-13 21:28:06 +04:00
|
|
|
|
|
|
|
/* has a buffer been provided */
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mca_pml_bsend_mutex);
|
2004-10-20 02:00:19 +04:00
|
|
|
if(NULL == mca_pml_bsend_addr) {
|
|
|
|
sendreq->req_addr = NULL;
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2004-10-20 02:00:19 +04:00
|
|
|
return OMPI_ERR_BUFFER;
|
|
|
|
}
|
2004-06-24 20:47:00 +04:00
|
|
|
|
2004-10-20 02:00:19 +04:00
|
|
|
/* allocate a buffer to hold packed message */
|
|
|
|
sendreq->req_addr = mca_pml_bsend_allocator->alc_alloc(
|
2005-05-31 21:06:55 +04:00
|
|
|
mca_pml_bsend_allocator, sendreq->req_bytes_packed, 0, NULL);
|
2004-10-20 02:00:19 +04:00
|
|
|
if(NULL == sendreq->req_addr) {
|
|
|
|
/* release resources when request is freed */
|
|
|
|
sendreq->req_base.req_pml_complete = true;
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2004-10-20 02:00:19 +04:00
|
|
|
return OMPI_ERR_BUFFER;
|
|
|
|
}
|
2004-06-24 20:47:00 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
|
2005-06-29 02:21:38 +04:00
|
|
|
/* The convertor is already initialized in the begining so we just have to
|
|
|
|
* pack the data in the newly allocated buffer.
|
|
|
|
*/
|
2006-08-24 20:38:08 +04:00
|
|
|
iov.iov_base = (IOVBASE_TYPE*)sendreq->req_addr;
|
2006-07-06 21:58:25 +04:00
|
|
|
iov.iov_len = sendreq->req_bytes_packed;
|
2004-10-20 02:00:19 +04:00
|
|
|
iov_count = 1;
|
|
|
|
max_data = iov.iov_len;
|
- Split the datatype engine into two parts: an MPI specific part in
OMPI
and a language agnostic part in OPAL. The convertor is completely
moved into OPAL. This offers several benefits as described in RFC
http://www.open-mpi.org/community/lists/devel/2009/07/6387.php
namely:
- Fewer basic types (int* and float* types, boolean and wchar
- Fixing naming scheme to ompi-nomenclature.
- Usability outside of the ompi-layer.
- Due to the fixed nature of simple opal types, their information is
completely
known at compile time and therefore constified
- With fewer datatypes (22), the actual sizes of bit-field types may be
reduced
from 64 to 32 bits, allowing reorganizing the opal_datatype
structure, eliminating holes and keeping data required in convertor
(upon send/recv) in one cacheline...
This has implications to the convertor-datastructure and other parts
of the code.
- Several performance tests have been run, the netpipe latency does not
change with
this patch on Linux/x86-64 on the smoky cluster.
- Extensive tests have been done to verify correctness (no new
regressions) using:
1. mpi_test_suite on linux/x86-64 using clean ompi-trunk and
ompi-ddt:
a. running both trunk and ompi-ddt resulted in no differences
(except for MPI_SHORT_INT and MPI_TYPE_MIX_LB_UB do now run
correctly).
b. with --enable-memchecker and running under valgrind (one buglet
when run with static found in test-suite, commited)
2. ibm testsuite on linux/x86-64 using clean ompi-trunk and ompi-ddt:
all passed (except for the dynamic/ tests failed!! as trunk/MTT)
3. compilation and usage of HDF5 tests on Jaguar using PGI and
PathScale compilers.
4. compilation and usage on Scicortex.
- Please note, that for the heterogeneous case, (-m32 compiled
binaries/ompi), neither
ompi-trunk, nor ompi-ddt branch would successfully launch.
This commit was SVN r21641.
2009-07-13 08:56:31 +04:00
|
|
|
if((rc = opal_convertor_pack( &sendreq->req_base.req_convertor,
|
2006-07-04 05:20:20 +04:00
|
|
|
&iov,
|
|
|
|
&iov_count,
|
2006-10-27 03:11:26 +04:00
|
|
|
&max_data )) < 0) {
|
2004-10-20 02:00:19 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
2005-06-29 02:21:38 +04:00
|
|
|
/* setup convertor to point to packed buffer (at position zero) */
|
- Split the datatype engine into two parts: an MPI specific part in
OMPI
and a language agnostic part in OPAL. The convertor is completely
moved into OPAL. This offers several benefits as described in RFC
http://www.open-mpi.org/community/lists/devel/2009/07/6387.php
namely:
- Fewer basic types (int* and float* types, boolean and wchar
- Fixing naming scheme to ompi-nomenclature.
- Usability outside of the ompi-layer.
- Due to the fixed nature of simple opal types, their information is
completely
known at compile time and therefore constified
- With fewer datatypes (22), the actual sizes of bit-field types may be
reduced
from 64 to 32 bits, allowing reorganizing the opal_datatype
structure, eliminating holes and keeping data required in convertor
(upon send/recv) in one cacheline...
This has implications to the convertor-datastructure and other parts
of the code.
- Several performance tests have been run, the netpipe latency does not
change with
this patch on Linux/x86-64 on the smoky cluster.
- Extensive tests have been done to verify correctness (no new
regressions) using:
1. mpi_test_suite on linux/x86-64 using clean ompi-trunk and
ompi-ddt:
a. running both trunk and ompi-ddt resulted in no differences
(except for MPI_SHORT_INT and MPI_TYPE_MIX_LB_UB do now run
correctly).
b. with --enable-memchecker and running under valgrind (one buglet
when run with static found in test-suite, commited)
2. ibm testsuite on linux/x86-64 using clean ompi-trunk and ompi-ddt:
all passed (except for the dynamic/ tests failed!! as trunk/MTT)
3. compilation and usage of HDF5 tests on Jaguar using PGI and
PathScale compilers.
4. compilation and usage on Scicortex.
- Please note, that for the heterogeneous case, (-m32 compiled
binaries/ompi), neither
ompi-trunk, nor ompi-ddt branch would successfully launch.
This commit was SVN r21641.
2009-07-13 08:56:31 +04:00
|
|
|
opal_convertor_prepare_for_send( &sendreq->req_base.req_convertor, &(ompi_mpi_packed.dt.super),
|
2005-06-08 23:10:15 +04:00
|
|
|
max_data, sendreq->req_addr );
|
2006-07-06 21:58:25 +04:00
|
|
|
/* increment count of pending requests */
|
|
|
|
mca_pml_bsend_count++;
|
2004-10-20 02:00:19 +04:00
|
|
|
}
|
2006-07-11 02:27:32 +04:00
|
|
|
|
2005-06-29 02:10:49 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-10-20 02:00:19 +04:00
|
|
|
}
|
|
|
|
|
2004-06-24 20:47:00 +04:00
|
|
|
|
2005-09-14 21:08:08 +04:00
|
|
|
/*
|
|
|
|
* allocate buffer
|
|
|
|
*/
|
|
|
|
|
|
|
|
int mca_pml_base_bsend_request_alloc(ompi_request_t* request)
|
|
|
|
{
|
|
|
|
mca_pml_base_send_request_t* sendreq = (mca_pml_base_send_request_t*)request;
|
|
|
|
|
2006-07-06 21:58:25 +04:00
|
|
|
assert( sendreq->req_bytes_packed > 0 );
|
2006-07-04 05:20:20 +04:00
|
|
|
|
2005-09-14 21:08:08 +04:00
|
|
|
/* has a buffer been provided */
|
|
|
|
OPAL_THREAD_LOCK(&mca_pml_bsend_mutex);
|
|
|
|
if(NULL == mca_pml_bsend_addr) {
|
|
|
|
sendreq->req_addr = NULL;
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
|
|
|
return OMPI_ERR_BUFFER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate a buffer to hold packed message */
|
|
|
|
sendreq->req_addr = mca_pml_bsend_allocator->alc_alloc(
|
|
|
|
mca_pml_bsend_allocator, sendreq->req_bytes_packed, 0, NULL);
|
|
|
|
if(NULL == sendreq->req_addr) {
|
|
|
|
/* release resources when request is freed */
|
|
|
|
sendreq->req_base.req_pml_complete = true;
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2007-10-27 04:17:53 +04:00
|
|
|
/* progress communications, with the hope that more resources
|
|
|
|
* will be freed */
|
|
|
|
opal_progress();
|
2005-09-14 21:08:08 +04:00
|
|
|
return OMPI_ERR_BUFFER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* increment count of pending requests */
|
|
|
|
mca_pml_bsend_count++;
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-07-14 23:32:26 +04:00
|
|
|
/*
|
|
|
|
* allocate buffer
|
|
|
|
*/
|
|
|
|
|
|
|
|
void* mca_pml_base_bsend_request_alloc_buf( size_t length )
|
|
|
|
{
|
|
|
|
void* buf = NULL;
|
|
|
|
/* has a buffer been provided */
|
|
|
|
OPAL_THREAD_LOCK(&mca_pml_bsend_mutex);
|
|
|
|
if(NULL == mca_pml_bsend_addr) {
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate a buffer to hold packed message */
|
|
|
|
buf = mca_pml_bsend_allocator->alc_alloc(
|
|
|
|
mca_pml_bsend_allocator, length, 0, NULL);
|
|
|
|
if(NULL == buf) {
|
|
|
|
/* release resources when request is freed */
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2007-10-27 04:17:53 +04:00
|
|
|
/* progress communications, with the hope that more resources
|
|
|
|
* will be freed */
|
|
|
|
opal_progress();
|
2006-07-14 23:32:26 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* increment count of pending requests */
|
|
|
|
mca_pml_bsend_count++;
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Request completed - free buffer and decrement pending count
|
|
|
|
*/
|
|
|
|
int mca_pml_base_bsend_request_free(void* addr)
|
|
|
|
{
|
|
|
|
/* remove from list of pending requests */
|
|
|
|
OPAL_THREAD_LOCK(&mca_pml_bsend_mutex);
|
|
|
|
|
|
|
|
/* free buffer */
|
|
|
|
mca_pml_bsend_allocator->alc_free(mca_pml_bsend_allocator, addr);
|
|
|
|
|
|
|
|
/* decrement count of buffered requests */
|
|
|
|
if(--mca_pml_bsend_count == 0)
|
|
|
|
opal_condition_signal(&mca_pml_bsend_condition);
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-14 21:08:08 +04:00
|
|
|
|
2004-06-24 20:47:00 +04:00
|
|
|
/*
|
|
|
|
* Request completed - free buffer and decrement pending count
|
2005-03-26 21:49:16 +03:00
|
|
|
*/
|
2004-06-24 20:47:00 +04:00
|
|
|
int mca_pml_base_bsend_request_fini(ompi_request_t* request)
|
|
|
|
{
|
2004-06-24 23:28:30 +04:00
|
|
|
mca_pml_base_send_request_t* sendreq = (mca_pml_base_send_request_t*)request;
|
2006-07-06 21:58:25 +04:00
|
|
|
if(sendreq->req_bytes_packed == 0 ||
|
2005-09-15 22:47:59 +04:00
|
|
|
sendreq->req_addr == NULL ||
|
|
|
|
sendreq->req_addr == sendreq->req_base.req_addr)
|
2004-10-20 02:00:19 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-06-24 20:47:00 +04:00
|
|
|
|
|
|
|
/* remove from list of pending requests */
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
|
|
|
|
/* free buffer */
|
2004-10-20 02:00:19 +04:00
|
|
|
mca_pml_bsend_allocator->alc_free(mca_pml_bsend_allocator, sendreq->req_addr);
|
2005-09-15 22:47:59 +04:00
|
|
|
sendreq->req_addr = sendreq->req_base.req_addr;
|
2004-06-24 20:47:00 +04:00
|
|
|
|
|
|
|
/* decrement count of buffered requests */
|
|
|
|
if(--mca_pml_bsend_count == 0)
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_condition_signal(&mca_pml_bsend_condition);
|
2004-06-24 20:47:00 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
2004-06-24 20:47:00 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|