2012-06-21 21:09:12 +04:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
2006-07-18 02:08:55 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
2006-08-24 20:38:08 +04:00
|
|
|
* Copyright (c) 2004-2006 The Trustees of the University of Tennessee.
|
2006-07-18 02:08:55 +04:00
|
|
|
* All rights reserved.
|
2014-11-05 19:59:12 +03:00
|
|
|
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
|
2006-07-18 02:08:55 +04:00
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2015-05-29 17:33:34 +03:00
|
|
|
* Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights
|
2014-11-05 19:59:12 +03:00
|
|
|
* reserved.
|
2011-07-13 20:38:03 +04:00
|
|
|
* Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved.
|
2014-02-25 21:36:43 +04:00
|
|
|
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
|
2015-05-08 07:53:03 +03:00
|
|
|
* Copyright (c) 2014-2015 Research Organization for Information Science
|
2014-08-04 14:35:08 +04:00
|
|
|
* and Technology (RIST). All rights reserved.
|
2006-07-18 02:08:55 +04:00
|
|
|
* $COPYRIGHT$
|
2014-11-05 19:59:12 +03:00
|
|
|
*
|
2006-07-18 02:08:55 +04:00
|
|
|
* Additional copyrights may follow
|
2014-11-05 19:59:12 +03:00
|
|
|
*
|
2006-07-18 02:08:55 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
#include "osc_pt2pt.h"
|
|
|
|
#include "osc_pt2pt_header.h"
|
|
|
|
#include "osc_pt2pt_data_move.h"
|
|
|
|
#include "osc_pt2pt_frag.h"
|
|
|
|
#include "osc_pt2pt_request.h"
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2008-04-18 00:43:56 +04:00
|
|
|
#include "opal/util/arch.h"
|
2006-07-18 02:08:55 +04:00
|
|
|
#include "opal/sys/atomic.h"
|
2010-08-24 22:10:43 +04:00
|
|
|
#include "opal/align.h"
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
|
2009-03-04 20:06:51 +03:00
|
|
|
#include "ompi/mca/pml/pml.h"
|
2014-02-25 23:14:48 +04:00
|
|
|
#include "ompi/mca/pml/base/pml_base_sendreq.h"
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
#include "opal/mca/btl/btl.h"
|
2007-07-14 00:46:12 +04:00
|
|
|
#include "ompi/mca/osc/base/osc_base_obj_convert.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"
|
2009-02-24 20:17:33 +03:00
|
|
|
#include "ompi/op/op.h"
|
2008-04-16 17:29:55 +04:00
|
|
|
#include "ompi/memchecker.h"
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* struct osc_pt2pt_accumulate_data_t:
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Data associated with an in-progress accumulation operation.
|
2014-02-25 21:36:43 +04:00
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
struct osc_pt2pt_accumulate_data_t {
|
2014-03-12 18:39:03 +04:00
|
|
|
opal_list_item_t super;
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_module_t* module;
|
2014-02-25 21:36:43 +04:00
|
|
|
void *target;
|
|
|
|
void *source;
|
|
|
|
size_t source_len;
|
|
|
|
ompi_proc_t *proc;
|
|
|
|
int count;
|
2014-03-12 18:39:03 +04:00
|
|
|
int peer;
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_datatype_t *datatype;
|
|
|
|
ompi_op_t *op;
|
|
|
|
int request_count;
|
|
|
|
};
|
2014-11-05 19:59:12 +03:00
|
|
|
typedef struct osc_pt2pt_accumulate_data_t osc_pt2pt_accumulate_data_t;
|
2014-03-12 18:39:03 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static void osc_pt2pt_accumulate_data_constructor (osc_pt2pt_accumulate_data_t *acc_data)
|
2014-03-12 18:39:03 +04:00
|
|
|
{
|
|
|
|
acc_data->source = NULL;
|
|
|
|
acc_data->datatype = NULL;
|
|
|
|
acc_data->op = NULL;
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static void osc_pt2pt_accumulate_data_destructor (osc_pt2pt_accumulate_data_t *acc_data)
|
2014-03-12 18:39:03 +04:00
|
|
|
{
|
|
|
|
if (acc_data->source) {
|
|
|
|
/* the source buffer is always alloc'd */
|
|
|
|
free (acc_data->source);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (acc_data->datatype) {
|
|
|
|
OBJ_RELEASE(acc_data->datatype);
|
|
|
|
}
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2014-03-12 18:39:03 +04:00
|
|
|
if (acc_data->op) {
|
|
|
|
OBJ_RELEASE(acc_data->op);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
OBJ_CLASS_DECLARATION(osc_pt2pt_accumulate_data_t);
|
|
|
|
OBJ_CLASS_INSTANCE(osc_pt2pt_accumulate_data_t, opal_list_item_t, osc_pt2pt_accumulate_data_constructor,
|
|
|
|
osc_pt2pt_accumulate_data_destructor);
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* osc_pt2pt_pending_acc_t:
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Keep track of accumulate and cswap operations that are
|
2014-02-25 21:36:43 +04:00
|
|
|
* waiting on the accumulate lock.
|
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* Since accumulate operations may take several steps to
|
2014-02-25 21:36:43 +04:00
|
|
|
* complete we need to lock the accumulate lock until the operation
|
|
|
|
* is complete. While the lock is held it is possible that additional
|
|
|
|
* accumulate operations will arrive. This structure keep track of
|
|
|
|
* those operations.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
struct osc_pt2pt_pending_acc_t {
|
2014-02-25 21:36:43 +04:00
|
|
|
opal_list_item_t super;
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_header_t header;
|
2014-02-25 21:36:43 +04:00
|
|
|
int source;
|
|
|
|
void *data;
|
|
|
|
size_t data_len;
|
|
|
|
ompi_datatype_t *datatype;
|
|
|
|
};
|
2014-11-05 19:59:12 +03:00
|
|
|
typedef struct osc_pt2pt_pending_acc_t osc_pt2pt_pending_acc_t;
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static void osc_pt2pt_pending_acc_constructor (osc_pt2pt_pending_acc_t *pending)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
pending->data = NULL;
|
|
|
|
pending->datatype = NULL;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static void osc_pt2pt_pending_acc_destructor (osc_pt2pt_pending_acc_t *pending)
|
2007-05-24 19:41:24 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
if (NULL != pending->data) {
|
|
|
|
free (pending->data);
|
2007-05-24 19:41:24 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
if (NULL != pending->datatype) {
|
|
|
|
OBJ_RELEASE(pending->datatype);
|
2007-05-24 19:41:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
OBJ_CLASS_DECLARATION(osc_pt2pt_pending_acc_t);
|
|
|
|
OBJ_CLASS_INSTANCE(osc_pt2pt_pending_acc_t, opal_list_item_t,
|
|
|
|
osc_pt2pt_pending_acc_constructor, osc_pt2pt_pending_acc_destructor);
|
|
|
|
/* end ompi_osc_pt2pt_pending_acc_t class */
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2014-03-24 22:57:29 +04:00
|
|
|
/**
|
|
|
|
* @brief Class for large datatype descriptions
|
|
|
|
*
|
|
|
|
* This class is used to keep track of buffers for large datatype desctiotions
|
|
|
|
* (datatypes that do not fit in an eager fragment). The structure is designed
|
|
|
|
* to take advantage of the small datatype description code path.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
struct ompi_osc_pt2pt_ddt_buffer_t {
|
2014-03-24 22:57:29 +04:00
|
|
|
/** allows this class to be stored in the buffer garbage collection
|
|
|
|
* list */
|
|
|
|
opal_list_item_t super;
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
/** OSC PT2PT module */
|
|
|
|
ompi_osc_pt2pt_module_t *module;
|
2014-03-24 22:57:29 +04:00
|
|
|
/** source of this header */
|
|
|
|
int source;
|
|
|
|
/** header + datatype data */
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_header_t *header;
|
2014-03-24 22:57:29 +04:00
|
|
|
};
|
2014-11-05 19:59:12 +03:00
|
|
|
typedef struct ompi_osc_pt2pt_ddt_buffer_t ompi_osc_pt2pt_ddt_buffer_t;
|
2014-03-24 22:57:29 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static void ompi_osc_pt2pt_ddt_buffer_constructor (ompi_osc_pt2pt_ddt_buffer_t *ddt_buffer)
|
2014-03-24 22:57:29 +04:00
|
|
|
{
|
|
|
|
ddt_buffer->header = NULL;
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static void ompi_osc_pt2pt_ddt_buffer_destructor (ompi_osc_pt2pt_ddt_buffer_t *ddt_buffer)
|
2014-03-24 22:57:29 +04:00
|
|
|
{
|
|
|
|
if (ddt_buffer->header) {
|
|
|
|
free (ddt_buffer->header);
|
|
|
|
ddt_buffer->header = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
OBJ_CLASS_DECLARATION(ompi_osc_pt2pt_ddt_buffer_t);
|
|
|
|
OBJ_CLASS_INSTANCE(ompi_osc_pt2pt_ddt_buffer_t, opal_list_item_t, ompi_osc_pt2pt_ddt_buffer_constructor,
|
|
|
|
ompi_osc_pt2pt_ddt_buffer_destructor);
|
|
|
|
/* end ompi_osc_pt2pt_ddt_buffer_t class */
|
2014-03-24 22:57:29 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
|
|
|
* datatype_buffer_length:
|
2007-07-06 01:40:06 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Determine the buffer size needed to hold count elements of datatype.
|
2007-07-06 01:40:06 +04:00
|
|
|
*
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] datatype - Element type
|
|
|
|
* @param[in] count - Element count
|
|
|
|
*
|
|
|
|
* @returns buflen Buffer length needed to hold count elements of datatype
|
|
|
|
*/
|
|
|
|
static inline int datatype_buffer_length (ompi_datatype_t *datatype, int count)
|
2007-07-06 01:40:06 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_datatype_t *primitive_datatype = NULL;
|
|
|
|
uint32_t primitive_count;
|
|
|
|
size_t buflen;
|
2007-07-06 01:40:06 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_osc_base_get_primitive_type_info(datatype, &primitive_datatype, &primitive_count);
|
|
|
|
primitive_count *= count;
|
2007-07-06 01:40:06 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* figure out how big a buffer we need */
|
|
|
|
ompi_datatype_type_size(primitive_datatype, &buflen);
|
2007-07-06 01:40:06 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return buflen * primitive_count;
|
2007-07-06 01:40:06 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* ompi_osc_pt2pt_control_send:
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief send a control message as part of a fragment
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] target - Target peer's rank
|
|
|
|
* @param[in] data - Data to send
|
|
|
|
* @param[in] len - Length of data
|
|
|
|
*
|
|
|
|
* @returns error OMPI error code or OMPI_SUCCESS
|
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* "send" a control messages. Adds it to the active fragment, so the
|
2014-02-25 21:36:43 +04:00
|
|
|
* caller will still need to explicitly flush (either to everyone or
|
|
|
|
* to a target) before this is sent.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
int ompi_osc_pt2pt_control_send (ompi_osc_pt2pt_module_t *module, int target,
|
2015-05-29 17:33:34 +03:00
|
|
|
void *data, size_t len)
|
2007-07-06 01:40:06 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_frag_t *frag;
|
2014-02-25 21:36:43 +04:00
|
|
|
char *ptr;
|
|
|
|
int ret;
|
2007-07-06 01:40:06 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_frag_alloc(module, target, len, &frag, &ptr);
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OPAL_LIKELY(OMPI_SUCCESS == ret)) {
|
|
|
|
memcpy (ptr, data, len);
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_frag_finish(module, frag);
|
2007-07-06 01:40:06 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return ret;
|
2007-07-06 01:40:06 +04:00
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static int ompi_osc_pt2pt_control_send_unbuffered_cb (ompi_request_t *request)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2014-03-10 19:21:37 +04:00
|
|
|
void *ctx = request->req_complete_cb_data;
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_module_t *module;
|
2014-03-10 19:21:37 +04:00
|
|
|
|
|
|
|
/* get module pointer and data */
|
2014-11-05 19:59:12 +03:00
|
|
|
module = *(ompi_osc_pt2pt_module_t **)ctx;
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
/* mark this send as complete */
|
|
|
|
mark_outgoing_completion (module);
|
|
|
|
|
|
|
|
/* free the temporary buffer */
|
2014-03-10 19:21:37 +04:00
|
|
|
free (ctx);
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2014-03-24 22:57:29 +04:00
|
|
|
/* put this request on the garbage colletion list */
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_add_request (module, request);
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2007-05-24 19:41:24 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* ompi_osc_pt2pt_control_send_unbuffered:
|
2007-07-06 01:40:06 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Send an unbuffered control message to a peer.
|
2007-07-06 01:40:06 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] target - Target rank
|
|
|
|
* @param[in] data - Data to send
|
|
|
|
* @param[in] len - Length of data
|
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* Directly send a control message. This does not allocate a
|
2014-02-25 21:36:43 +04:00
|
|
|
* fragment, so should only be used when sending other messages would
|
|
|
|
* be erroneous (such as complete messages, when there may be queued
|
|
|
|
* transactions from an overlapping post that has already heard back
|
|
|
|
* from its peer). The buffer specified by data will be available
|
|
|
|
* when this call returns.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
int ompi_osc_pt2pt_control_send_unbuffered(ompi_osc_pt2pt_module_t *module,
|
2014-02-25 21:36:43 +04:00
|
|
|
int target, void *data, size_t len)
|
2007-07-05 07:32:32 +04:00
|
|
|
{
|
2014-03-10 19:21:37 +04:00
|
|
|
void *ctx, *data_copy;
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"osc pt2pt: sending unbuffered fragment to %d", target));
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* allocate a temporary buffer for this send */
|
2014-11-05 19:59:12 +03:00
|
|
|
ctx = malloc (sizeof(ompi_osc_pt2pt_module_t*) + len);
|
2014-03-10 19:21:37 +04:00
|
|
|
if (OPAL_UNLIKELY(NULL == ctx)) {
|
2014-02-25 21:36:43 +04:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* increment outgoing signal count. this send is not part of a passive epoch
|
|
|
|
* so there it would be erroneous to increment the epoch counters. */
|
|
|
|
ompi_osc_signal_outgoing (module, MPI_PROC_NULL, 1);
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-03-10 19:21:37 +04:00
|
|
|
/* store module pointer and data in the buffer */
|
2014-11-05 19:59:12 +03:00
|
|
|
*(ompi_osc_pt2pt_module_t**)ctx = module;
|
|
|
|
data_copy = (ompi_osc_pt2pt_module_t**)ctx + 1;
|
2014-02-25 21:36:43 +04:00
|
|
|
memcpy (data_copy, data, len);
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
return ompi_osc_pt2pt_isend_w_cb (data_copy, len, MPI_BYTE, target, OSC_PT2PT_FRAG_TAG,
|
|
|
|
module->comm, ompi_osc_pt2pt_control_send_unbuffered_cb, ctx);
|
2007-07-05 07:32:32 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
|
|
|
* datatype_create:
|
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Utility function that creates a new datatype from a packed
|
2014-02-25 21:36:43 +04:00
|
|
|
* description.
|
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] peer - Peer rank
|
|
|
|
* @param[out] datatype - New datatype. Must be released with OBJ_RELEASE.
|
|
|
|
* @param[out] proc - Optional. Proc for peer.
|
|
|
|
* @param[inout] data - Pointer to a pointer where the description is stored. This
|
|
|
|
* pointer will be updated to the location after the packed
|
|
|
|
* description.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int datatype_create (ompi_osc_pt2pt_module_t *module, int peer, ompi_proc_t **proc, ompi_datatype_t **datatype, void **data)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
|
|
|
ompi_datatype_t *new_datatype = NULL;
|
|
|
|
ompi_proc_t *peer_proc;
|
|
|
|
int ret = OMPI_SUCCESS;
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
do {
|
|
|
|
peer_proc = ompi_comm_peer_lookup(module->comm, peer);
|
|
|
|
if (OPAL_UNLIKELY(NULL == peer_proc)) {
|
|
|
|
OPAL_OUTPUT_VERBOSE((1, ompi_osc_base_framework.framework_output,
|
|
|
|
"%d: datatype_create: could not resolve proc pointer for peer %d",
|
|
|
|
ompi_comm_rank(module->comm),
|
|
|
|
peer));
|
|
|
|
ret = OMPI_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_datatype = ompi_osc_base_datatype_create(peer_proc, data);
|
|
|
|
if (OPAL_UNLIKELY(NULL == new_datatype)) {
|
|
|
|
OPAL_OUTPUT_VERBOSE((1, ompi_osc_base_framework.framework_output,
|
|
|
|
"%d: datatype_create: could not resolve datatype for peer %d",
|
|
|
|
ompi_comm_rank(module->comm), peer));
|
|
|
|
ret = OMPI_ERROR;
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
*datatype = new_datatype;
|
|
|
|
if (proc) *proc = peer_proc;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* process_put:
|
|
|
|
*
|
|
|
|
* @shoer Process a put w/ data message
|
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] source - Message source
|
|
|
|
* @param[in] put_header - Message header + data
|
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* Process a put message and copy the message data to the specified
|
2014-02-25 21:36:43 +04:00
|
|
|
* memory region. Note, this function does not handle any bounds
|
|
|
|
* checking at the moment.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_put(ompi_osc_pt2pt_module_t* module, int source,
|
|
|
|
ompi_osc_pt2pt_header_put_t* put_header)
|
2007-07-05 07:32:32 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
char *data = (char*) (put_header + 1);
|
|
|
|
ompi_proc_t *proc;
|
|
|
|
struct ompi_datatype_t *datatype;
|
|
|
|
size_t data_len;
|
2014-11-05 19:59:12 +03:00
|
|
|
void *target = (unsigned char*) module->baseptr +
|
2014-02-25 21:36:43 +04:00
|
|
|
((unsigned long) put_header->displacement * module->disp_unit);
|
|
|
|
int ret;
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"%d: process_put: received message from %d",
|
|
|
|
ompi_comm_rank(module->comm),
|
|
|
|
source));
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
ret = datatype_create (module, source, &proc, &datatype, (void **) &data);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
return ret;
|
|
|
|
}
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
data_len = put_header->len - ((uintptr_t) data - (uintptr_t) put_header);
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
osc_pt2pt_copy_on_recv (target, data, data_len, proc, put_header->count, datatype);
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OBJ_RELEASE(datatype);
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return put_header->len;
|
|
|
|
}
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_put_long(ompi_osc_pt2pt_module_t* module, int source,
|
|
|
|
ompi_osc_pt2pt_header_put_t* put_header)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
|
|
|
char *data = (char*) (put_header + 1);
|
|
|
|
struct ompi_datatype_t *datatype;
|
2014-11-05 19:59:12 +03:00
|
|
|
void *target = (unsigned char*) module->baseptr +
|
2014-02-25 21:36:43 +04:00
|
|
|
((unsigned long) put_header->displacement * module->disp_unit);
|
|
|
|
int ret;
|
2012-06-21 21:09:12 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"%d: process_put_long: received message from %d",
|
|
|
|
ompi_comm_rank(module->comm),
|
|
|
|
source));
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
ret = datatype_create (module, source, NULL, &datatype, (void **) &data);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
return ret;
|
|
|
|
}
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_component_irecv (module, target,
|
2014-02-25 21:36:43 +04:00
|
|
|
put_header->count,
|
|
|
|
datatype, source,
|
|
|
|
put_header->tag,
|
|
|
|
module->comm);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
OPAL_OUTPUT_VERBOSE((1, ompi_osc_base_framework.framework_output,
|
|
|
|
"%d: process_put_long: irecv error: %d",
|
|
|
|
ompi_comm_rank(module->comm),
|
|
|
|
ret));
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OBJ_RELEASE(datatype);
|
|
|
|
|
|
|
|
return put_header->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* osc_pt2pt_incoming_req_complete:
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Completion callback for a receive associate with an access
|
2014-02-25 21:36:43 +04:00
|
|
|
* epoch.
|
|
|
|
*
|
|
|
|
* @param[in] request - PML request with an OSC RMDA module as the callback data.
|
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* This function is called when a send or recieve associated with an
|
2014-02-25 21:36:43 +04:00
|
|
|
* access epoch completes. When fired this function will increment the
|
|
|
|
* passive or active incoming count.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static int osc_pt2pt_incoming_req_complete (ompi_request_t *request)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_module_t *module = (ompi_osc_pt2pt_module_t *) request->req_complete_cb_data;
|
2014-02-25 21:36:43 +04:00
|
|
|
int rank = MPI_PROC_NULL;
|
|
|
|
|
|
|
|
if (request->req_status.MPI_TAG & 0x01) {
|
2014-03-12 18:39:03 +04:00
|
|
|
rank = request->req_status.MPI_SOURCE;
|
2007-07-05 07:32:32 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
mark_incoming_completion (module, rank);
|
|
|
|
|
|
|
|
/* put this request on the garbage colletion list */
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_add_request (module, request);
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2007-07-05 07:32:32 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
struct osc_pt2pt_get_post_send_cb_data_t {
|
|
|
|
ompi_osc_pt2pt_module_t *module;
|
2014-03-12 21:14:11 +04:00
|
|
|
int peer;
|
|
|
|
};
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static int osc_pt2pt_get_post_send_cb (ompi_request_t *request)
|
2014-03-12 21:14:11 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
struct osc_pt2pt_get_post_send_cb_data_t *data =
|
|
|
|
(struct osc_pt2pt_get_post_send_cb_data_t *) request->req_complete_cb_data;
|
|
|
|
ompi_osc_pt2pt_module_t *module = data->module;
|
2014-03-12 21:14:11 +04:00
|
|
|
int rank = data->peer;
|
|
|
|
|
|
|
|
free (data);
|
|
|
|
|
2014-03-13 01:43:23 +04:00
|
|
|
/* mark this as a completed "incoming" request */
|
2014-03-12 21:14:11 +04:00
|
|
|
mark_incoming_completion (module, rank);
|
|
|
|
|
|
|
|
/* put this request on the garbage colletion list */
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_add_request (module, request);
|
2014-03-12 21:14:11 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Post a send to match the remote receive for a get operation.
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] source - Source buffer
|
|
|
|
* @param[in] count - Number of elements in the source buffer
|
|
|
|
* @param[in] datatype - Type of source elements.
|
|
|
|
* @param[in] peer - Remote process that has the receive posted
|
|
|
|
* @param[in] tag - Tag for the send
|
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* This function posts a send to match the receive posted as part
|
2014-02-25 21:36:43 +04:00
|
|
|
* of a get operation. When this send is complete the get is considered
|
|
|
|
* complete at the target (this process).
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static int osc_pt2pt_get_post_send (ompi_osc_pt2pt_module_t *module, void *source, int count,
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_datatype_t *datatype, int peer, int tag)
|
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
struct osc_pt2pt_get_post_send_cb_data_t *data;
|
2015-05-29 17:33:34 +03:00
|
|
|
int ret;
|
2014-03-12 21:14:11 +04:00
|
|
|
|
|
|
|
data = malloc (sizeof (*data));
|
|
|
|
if (OPAL_UNLIKELY(NULL == data)) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->module = module;
|
2014-03-13 01:43:23 +04:00
|
|
|
/* for incoming completion we need to know the peer (MPI_PROC_NULL if this is
|
2014-03-12 21:14:11 +04:00
|
|
|
* in an active target epoch) */
|
|
|
|
data->peer = (tag & 0x1) ? peer : MPI_PROC_NULL;
|
|
|
|
|
2015-05-29 17:33:34 +03:00
|
|
|
/* data will be freed by the callback */
|
|
|
|
ret = ompi_osc_pt2pt_isend_w_cb (source, count, datatype, peer, tag, module->comm,
|
2014-11-05 19:59:12 +03:00
|
|
|
osc_pt2pt_get_post_send_cb, (void *) data);
|
2015-05-29 17:33:34 +03:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
free (data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2014-02-25 21:36:43 +04:00
|
|
|
}
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
|
|
|
* process_get:
|
2006-07-18 02:08:55 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Process a get message from a remote peer
|
2006-07-18 02:08:55 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] target - Peer process
|
|
|
|
* @param[in] get_header - Incoming message header
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_get (ompi_osc_pt2pt_module_t* module, int target,
|
|
|
|
ompi_osc_pt2pt_header_get_t* get_header)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
char *data = (char *) (get_header + 1);
|
|
|
|
struct ompi_datatype_t *datatype;
|
|
|
|
void *source = (unsigned char*) module->baseptr +
|
|
|
|
((unsigned long) get_header->displacement * module->disp_unit);
|
|
|
|
int ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2013-03-28 01:17:31 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-02-25 21:36:43 +04:00
|
|
|
"%d: process_get: received message from %d",
|
|
|
|
ompi_comm_rank(module->comm),
|
|
|
|
target));
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
ret = datatype_create (module, target, NULL, &datatype, (void **) &data);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
return ret;
|
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* send get data */
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = osc_pt2pt_get_post_send (module, source, get_header->count, datatype, target, get_header->tag);
|
2007-05-24 19:41:24 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OBJ_RELEASE(datatype);
|
2011-07-01 00:05:16 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return OMPI_SUCCESS == ret ? (int) get_header->len : ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* osc_pt2pt_accumulate_buffer:
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Accumulate data into the target buffer.
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
|
|
|
* @param[in] target - Target buffer
|
|
|
|
* @param[in] source - Source buffer
|
|
|
|
* @param[in] source_len - Length of source buffer in bytes
|
|
|
|
* @param[in] proc - Source proc
|
|
|
|
* @param[in] count - Number of elements in target buffer
|
|
|
|
* @param[in] datatype - Type of elements in target buffer
|
|
|
|
* @param[in] op - Operation to be performed
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int osc_pt2pt_accumulate_buffer (void *target, void *source, size_t source_len, ompi_proc_t *proc,
|
2014-02-25 21:36:43 +04:00
|
|
|
int count, ompi_datatype_t *datatype, ompi_op_t *op)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
int ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
assert (NULL != target && NULL != source);
|
|
|
|
|
|
|
|
if (op == &ompi_mpi_op_replace.op) {
|
2014-11-05 19:59:12 +03:00
|
|
|
osc_pt2pt_copy_on_recv (target, source, source_len, proc, count, datatype);
|
2014-02-25 21:36:43 +04:00
|
|
|
return OMPI_SUCCESS;
|
2007-07-06 01:40:06 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
|
2014-08-04 14:35:08 +04:00
|
|
|
if (proc->super.proc_arch != ompi_proc_local()->super.proc_arch) {
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_datatype_t *primitive_datatype = NULL;
|
|
|
|
uint32_t primitive_count;
|
|
|
|
size_t buflen;
|
2015-05-08 07:53:03 +03:00
|
|
|
void *buffer;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_osc_base_get_primitive_type_info(datatype, &primitive_datatype, &primitive_count);
|
2014-03-04 20:57:56 +04:00
|
|
|
primitive_count *= count;
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
/* figure out how big a buffer we need */
|
|
|
|
ompi_datatype_type_size(primitive_datatype, &buflen);
|
|
|
|
buflen *= primitive_count;
|
|
|
|
|
|
|
|
buffer = malloc (buflen);
|
|
|
|
if (OPAL_UNLIKELY(NULL == buffer)) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2015-05-08 07:53:03 +03:00
|
|
|
osc_pt2pt_copy_on_recv (buffer, source, source_len, proc, primitive_count, primitive_datatype);
|
2009-01-14 23:15:15 +03:00
|
|
|
|
2015-05-08 07:53:03 +03:00
|
|
|
ret = ompi_osc_base_process_op(target, buffer, source_len, datatype,
|
|
|
|
count, op);
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
free(buffer);
|
2015-05-08 07:53:03 +03:00
|
|
|
} else
|
2014-02-25 21:36:43 +04:00
|
|
|
#endif
|
|
|
|
|
2015-05-08 07:53:03 +03:00
|
|
|
/* copy the data from the temporary buffer into the user window */
|
|
|
|
ret = ompi_osc_base_process_op(target, source, source_len, datatype,
|
|
|
|
count, op);
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Create an accumulate data object.
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - PT2PT OSC module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] target - Target for the accumulation
|
|
|
|
* @param[in] source - Source of accumulate data. Must be allocated with malloc/calloc/etc
|
|
|
|
* @param[in] source_len - Length of the source buffer in bytes
|
|
|
|
* @param[in] proc - Source proc
|
|
|
|
* @param[in] count - Number of elements to accumulate
|
|
|
|
* @param[in] datatype - Datatype to accumulate
|
|
|
|
* @oaram[in] op - Operator
|
|
|
|
* @param[in] request_count - Number of prerequisite requests
|
|
|
|
* @param[out] acc_data_out - New accumulation data
|
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* This function is used to create a copy of the data needed to perform an accumulation.
|
2014-11-05 19:59:12 +03:00
|
|
|
* This data should be provided to ompi_osc_pt2pt_isend_w_cb or ompi_osc_pt2pt_irecv_w_cb
|
2014-03-24 22:57:29 +04:00
|
|
|
* as the ctx parameter with accumulate_cb as the cb parameter.
|
2014-02-25 21:36:43 +04:00
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static int osc_pt2pt_accumulate_allocate (ompi_osc_pt2pt_module_t *module, int peer, void *target, void *source, size_t source_len,
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_proc_t *proc, int count, ompi_datatype_t *datatype, ompi_op_t *op,
|
2014-11-05 19:59:12 +03:00
|
|
|
int request_count, osc_pt2pt_accumulate_data_t **acc_data_out)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
osc_pt2pt_accumulate_data_t *acc_data;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
acc_data = OBJ_NEW(osc_pt2pt_accumulate_data_t);
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OPAL_UNLIKELY(NULL == acc_data)) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
acc_data->module = module;
|
2014-03-12 18:39:03 +04:00
|
|
|
acc_data->peer = peer;
|
2014-02-25 21:36:43 +04:00
|
|
|
acc_data->target = target;
|
|
|
|
acc_data->source = source;
|
|
|
|
acc_data->source_len = source_len;
|
|
|
|
acc_data->proc = proc;
|
|
|
|
acc_data->count = count;
|
|
|
|
acc_data->datatype = datatype;
|
|
|
|
OBJ_RETAIN(datatype);
|
|
|
|
acc_data->op = op;
|
|
|
|
OBJ_RETAIN(op);
|
|
|
|
acc_data->request_count = request_count;
|
|
|
|
|
|
|
|
*acc_data_out = acc_data;
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Execute the accumulate once the request counter reaches 0.
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
|
|
|
* @param[in] request - request
|
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* The request should be created with ompi_osc_pt2pt_isend_w_cb or ompi_osc_pt2pt_irecv_w_cb
|
|
|
|
* with ctx allocated by osc_pt2pt_accumulate_allocate. This callback will free the accumulate
|
2014-02-25 21:36:43 +04:00
|
|
|
* data once the accumulation operation is complete.
|
|
|
|
*/
|
|
|
|
static int accumulate_cb (ompi_request_t *request)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
struct osc_pt2pt_accumulate_data_t *acc_data = (struct osc_pt2pt_accumulate_data_t *) request->req_complete_cb_data;
|
|
|
|
ompi_osc_pt2pt_module_t *module = acc_data->module;
|
2014-03-12 18:39:03 +04:00
|
|
|
int rank = MPI_PROC_NULL;
|
2006-07-18 02:08:55 +04:00
|
|
|
int ret = OMPI_SUCCESS;
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"accumulate_cb, request_count = %d", acc_data->request_count));
|
|
|
|
|
2014-03-12 18:39:03 +04:00
|
|
|
if (request->req_status.MPI_TAG & 0x01) {
|
|
|
|
rank = acc_data->peer;
|
|
|
|
}
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2014-03-12 18:39:03 +04:00
|
|
|
mark_incoming_completion (module, rank);
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
if (0 == OPAL_THREAD_ADD32(&acc_data->request_count, -1)) {
|
2014-03-12 18:39:03 +04:00
|
|
|
/* no more requests needed before the buffer can be accumulated */
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-03-12 18:39:03 +04:00
|
|
|
if (acc_data->source) {
|
2015-05-08 07:53:03 +03:00
|
|
|
ompi_datatype_t *primitive_datatype = NULL;
|
|
|
|
uint32_t primitive_count;
|
|
|
|
|
|
|
|
assert (NULL != acc_data->target && NULL != acc_data->source);
|
|
|
|
|
|
|
|
ompi_osc_base_get_primitive_type_info(acc_data->datatype, &primitive_datatype, &primitive_count);
|
|
|
|
primitive_count *= acc_data->count;
|
|
|
|
|
|
|
|
if (acc_data->op == &ompi_mpi_op_replace.op) {
|
|
|
|
ret = ompi_datatype_sndrcv(acc_data->source, primitive_count, primitive_datatype, acc_data->target, acc_data->count, acc_data->datatype);
|
|
|
|
} else {
|
|
|
|
ret = ompi_osc_base_process_op(acc_data->target, acc_data->source, acc_data->source_len, acc_data->datatype, acc_data->count, acc_data->op);
|
|
|
|
}
|
2014-03-12 18:39:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* drop the accumulate lock */
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_accumulate_unlock (module);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_add_buffer (module, &acc_data->super);
|
2014-03-12 18:39:03 +04:00
|
|
|
}
|
2007-07-06 01:40:06 +04:00
|
|
|
|
2014-03-24 22:57:29 +04:00
|
|
|
/* put this request on the garbage colletion list */
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_add_request (module, request);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return ret;
|
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2007-07-06 01:40:06 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static int ompi_osc_pt2pt_acc_op_queue (ompi_osc_pt2pt_module_t *module, ompi_osc_pt2pt_header_t *header, int source,
|
2014-02-25 21:36:43 +04:00
|
|
|
char *data, size_t data_len, ompi_datatype_t *datatype)
|
|
|
|
{
|
2015-05-29 17:33:34 +03:00
|
|
|
ompi_osc_pt2pt_peer_t *peer = ompi_osc_pt2pt_peer_lookup (module, source);
|
2014-11-05 19:59:12 +03:00
|
|
|
osc_pt2pt_pending_acc_t *pending_acc;
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2014-03-26 01:00:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"%d: queuing accumulate operation", ompi_comm_size (module->comm)));
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
pending_acc = OBJ_NEW(osc_pt2pt_pending_acc_t);
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OPAL_UNLIKELY(NULL == pending_acc)) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2007-07-06 01:40:06 +04:00
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
/* NTH: ensure we don't leave wait/process_flush/etc until this
|
|
|
|
* accumulate operation is complete. */
|
|
|
|
OPAL_THREAD_ADD32(&peer->passive_incoming_frag_count, -1);
|
2014-03-26 01:00:43 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
pending_acc->source = source;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* save any inline data (eager acc, gacc only) */
|
|
|
|
pending_acc->data_len = data_len;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
if (data_len) {
|
|
|
|
pending_acc->data = malloc (data_len);
|
|
|
|
memcpy (pending_acc->data, data, data_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* save the datatype */
|
|
|
|
pending_acc->datatype = datatype;
|
|
|
|
OBJ_RETAIN(datatype);
|
|
|
|
|
|
|
|
/* save the header */
|
|
|
|
switch (header->base.type) {
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_ACC:
|
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_ACC_LONG:
|
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC:
|
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC_LONG:
|
2014-06-17 18:53:24 +04:00
|
|
|
pending_acc->header.acc = header->acc;
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_CSWAP:
|
2014-02-25 21:36:43 +04:00
|
|
|
pending_acc->header.cswap = header->cswap;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* it is a coding error if any other header types are queued this way */
|
|
|
|
assert (0);
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* add to the pending acc queue */
|
2014-11-14 01:13:10 +03:00
|
|
|
OPAL_THREAD_SCOPED_LOCK(&module->lock, opal_list_append (&module->pending_acc, &pending_acc->super));
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
static int replace_cb (ompi_request_t *request)
|
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_module_t *module = (ompi_osc_pt2pt_module_t *) request->req_complete_cb_data;
|
2014-06-17 18:53:29 +04:00
|
|
|
int rank = MPI_PROC_NULL;
|
|
|
|
|
|
|
|
if (request->req_status.MPI_TAG & 0x01) {
|
|
|
|
rank = request->req_status.MPI_SOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mark_incoming_completion (module, rank);
|
|
|
|
|
|
|
|
/* put this request on the garbage colletion list */
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_add_request (module, request);
|
2007-07-06 01:40:06 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* unlock the accumulate lock */
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_accumulate_unlock (module);
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* ompi_osc_pt2pt_acc_start:
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Start an accumulate with data operation.
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] source - Source rank
|
|
|
|
* @param[in] data - Accumulate data
|
|
|
|
* @param[in] data_len - Length of the accumulate data
|
|
|
|
* @param[in] datatype - Accumulation datatype
|
|
|
|
* @param[in] acc_header - Accumulate header
|
|
|
|
*
|
|
|
|
* The module's accumulation lock must be held before calling this
|
|
|
|
* function. It will release the lock when the operation is complete.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static int ompi_osc_pt2pt_acc_start (ompi_osc_pt2pt_module_t *module, int source, void *data, size_t data_len,
|
|
|
|
ompi_datatype_t *datatype, ompi_osc_pt2pt_header_acc_t *acc_header)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
void *target = (unsigned char*) module->baseptr +
|
2014-02-25 21:36:43 +04:00
|
|
|
((unsigned long) acc_header->displacement * module->disp_unit);
|
|
|
|
struct ompi_op_t *op = ompi_osc_base_op_create(acc_header->op);
|
|
|
|
ompi_proc_t *proc;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
proc = ompi_comm_peer_lookup(module->comm, source);
|
|
|
|
assert (NULL != proc);
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = osc_pt2pt_accumulate_buffer (target, data, data_len, proc, acc_header->count,
|
2014-02-25 21:36:43 +04:00
|
|
|
datatype, op);
|
|
|
|
|
|
|
|
OBJ_RELEASE(op);
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_accumulate_unlock (module);
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* ompi_osc_pt2pt_acc_start:
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Start a long accumulate operation.
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] source - Source rank
|
|
|
|
* @param[in] datatype - Accumulation datatype
|
|
|
|
* @param[in] acc_header - Accumulate header
|
|
|
|
*
|
|
|
|
* The module's accumulation lock must be held before calling this
|
|
|
|
* function. It will release the lock when the operation is complete.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static int ompi_osc_pt2pt_acc_long_start (ompi_osc_pt2pt_module_t *module, int source, ompi_datatype_t *datatype,
|
|
|
|
ompi_osc_pt2pt_header_acc_t *acc_header) {
|
|
|
|
struct osc_pt2pt_accumulate_data_t *acc_data;
|
2014-02-25 21:36:43 +04:00
|
|
|
size_t buflen;
|
|
|
|
void *buffer;
|
|
|
|
ompi_proc_t *proc;
|
|
|
|
void *target = (unsigned char*) module->baseptr +
|
|
|
|
((unsigned long) acc_header->displacement * module->disp_unit);
|
|
|
|
struct ompi_op_t *op = ompi_osc_base_op_create(acc_header->op);
|
2014-03-25 19:28:48 +04:00
|
|
|
ompi_datatype_t *primitive_datatype;
|
2014-03-26 01:00:19 +04:00
|
|
|
uint32_t primitive_count;
|
2014-02-25 21:36:43 +04:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"ompi_osc_pt2pt_acc_long_start starting..."));
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
proc = ompi_comm_peer_lookup(module->comm, source);
|
|
|
|
assert (NULL != proc);
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (op == &ompi_mpi_op_replace.op) {
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_irecv_w_cb (target, acc_header->count, datatype, source,
|
2014-02-25 21:36:43 +04:00
|
|
|
acc_header->tag, module->comm, NULL,
|
|
|
|
replace_cb, module);
|
|
|
|
break;
|
2010-09-16 22:58:11 +04:00
|
|
|
}
|
2010-09-01 18:12:08 +04:00
|
|
|
|
2014-03-25 19:28:48 +04:00
|
|
|
ret = ompi_osc_base_get_primitive_type_info (datatype, &primitive_datatype, &primitive_count);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
primitive_count *= acc_header->count;
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
buflen = datatype_buffer_length (datatype, acc_header->count);
|
|
|
|
|
|
|
|
/* allocate a temporary buffer to receive the accumulate data */
|
|
|
|
buffer = malloc (buflen);
|
|
|
|
if (OPAL_UNLIKELY(NULL == buffer)) {
|
|
|
|
ret = OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
break;
|
2007-07-06 01:40:06 +04:00
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = osc_pt2pt_accumulate_allocate (module, source, target, buffer, buflen, proc, acc_header->count,
|
2015-05-29 17:33:34 +03:00
|
|
|
datatype, op, 1, &acc_data);
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
free (buffer);
|
|
|
|
break;
|
2007-07-06 01:40:06 +04:00
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_irecv_w_cb (buffer, primitive_count, primitive_datatype, source,
|
2015-05-29 17:33:34 +03:00
|
|
|
acc_header->tag, module->comm, NULL, accumulate_cb, acc_data);
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
2014-03-12 18:39:03 +04:00
|
|
|
OBJ_RELEASE(acc_data);
|
2007-07-06 01:40:06 +04:00
|
|
|
}
|
2014-02-25 21:36:43 +04:00
|
|
|
} while (0);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OBJ_RELEASE(op);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_accumulate_unlock (module);
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* ompi_osc_pt2pt_gacc_start:
|
2006-07-18 02:08:55 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Start a accumulate with data + get operation.
|
2006-07-18 02:08:55 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] source - Source rank
|
|
|
|
* @param[in] data - Accumulate data. Must be allocated on the heap.
|
|
|
|
* @param[in] data_len - Length of the accumulate data
|
|
|
|
* @param[in] datatype - Accumulation datatype
|
|
|
|
* @param[in] get_acc_header - Accumulate header
|
|
|
|
*
|
|
|
|
* The module's accumulation lock must be held before calling this
|
|
|
|
* function. It will release the lock when the operation is complete.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static int ompi_osc_pt2pt_gacc_start (ompi_osc_pt2pt_module_t *module, int source, void *data, size_t data_len,
|
|
|
|
ompi_datatype_t *datatype, ompi_osc_pt2pt_header_acc_t *acc_header)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
void *target = (unsigned char*) module->baseptr +
|
2014-06-17 18:53:24 +04:00
|
|
|
((unsigned long) acc_header->displacement * module->disp_unit);
|
|
|
|
struct ompi_op_t *op = ompi_osc_base_op_create(acc_header->op);
|
2014-11-05 19:59:12 +03:00
|
|
|
struct osc_pt2pt_accumulate_data_t *acc_data;
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_proc_t *proc;
|
|
|
|
int ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
proc = ompi_comm_peer_lookup(module->comm, source);
|
|
|
|
assert (NULL != proc);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
do {
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = osc_pt2pt_accumulate_allocate (module, source, target, data, data_len, proc, acc_header->count,
|
2014-02-25 21:36:43 +04:00
|
|
|
datatype, op, 1, &acc_data);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
break;
|
|
|
|
}
|
2011-07-01 00:05:16 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_isend_w_cb (target, acc_header->count, datatype, source, acc_header->tag,
|
2014-02-25 21:36:43 +04:00
|
|
|
module->comm, accumulate_cb, acc_data);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
2014-03-12 18:39:03 +04:00
|
|
|
OBJ_RELEASE(acc_data);
|
2014-02-25 21:36:43 +04:00
|
|
|
}
|
|
|
|
} while (0);
|
2011-07-01 00:05:16 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OBJ_RELEASE(op);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_accumulate_unlock (module);
|
2014-02-25 21:36:43 +04:00
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* ompi_osc_pt2pt_gacc_long_start:
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Start a long accumulate + get operation.
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] source - Source rank
|
|
|
|
* @param[in] datatype - Accumulation datatype
|
2014-06-17 18:53:24 +04:00
|
|
|
* @param[in] acc_header - Accumulate header
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
|
|
|
* The module's accumulation lock must be held before calling this
|
|
|
|
* function. It will release the lock when the operation is complete.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static int ompi_osc_gacc_long_start (ompi_osc_pt2pt_module_t *module, int source, ompi_datatype_t *datatype,
|
|
|
|
ompi_osc_pt2pt_header_acc_t *acc_header)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
void *target = (unsigned char*) module->baseptr +
|
2014-06-17 18:53:24 +04:00
|
|
|
((unsigned long) acc_header->displacement * module->disp_unit);
|
|
|
|
struct ompi_op_t *op = ompi_osc_base_op_create(acc_header->op);
|
2014-11-05 19:59:12 +03:00
|
|
|
struct osc_pt2pt_accumulate_data_t *acc_data;
|
2014-03-25 19:28:48 +04:00
|
|
|
ompi_datatype_t *primitive_datatype;
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_request_t *recv_request;
|
2014-03-26 01:00:19 +04:00
|
|
|
uint32_t primitive_count;
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_proc_t *proc;
|
|
|
|
size_t buflen;
|
|
|
|
void *buffer;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
proc = ompi_comm_peer_lookup(module->comm, source);
|
|
|
|
assert (NULL != proc);
|
|
|
|
|
|
|
|
/* allocate a temporary buffer to receive the accumulate data */
|
2014-06-17 18:53:24 +04:00
|
|
|
buflen = datatype_buffer_length (datatype, acc_header->count);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
do {
|
2014-03-25 19:28:48 +04:00
|
|
|
ret = ompi_osc_base_get_primitive_type_info (datatype, &primitive_datatype, &primitive_count);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-06-17 18:53:24 +04:00
|
|
|
primitive_count *= acc_header->count;
|
2014-03-25 19:28:48 +04:00
|
|
|
|
2015-05-29 17:33:34 +03:00
|
|
|
buffer = malloc (buflen);
|
|
|
|
if (OPAL_UNLIKELY(NULL == buffer)) {
|
|
|
|
ret = OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = osc_pt2pt_accumulate_allocate (module, source, target, buffer, buflen, proc, acc_header->count,
|
2015-05-29 17:33:34 +03:00
|
|
|
datatype, op, 2, &acc_data);
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
2015-05-29 17:33:34 +03:00
|
|
|
free (buffer);
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_irecv_w_cb (buffer, acc_header->count, datatype, source, acc_header->tag,
|
2014-02-25 21:36:43 +04:00
|
|
|
module->comm, &recv_request, accumulate_cb, acc_data);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
2014-03-12 18:39:03 +04:00
|
|
|
OBJ_RELEASE(acc_data);
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_isend_w_cb (target, primitive_count, primitive_datatype, source, acc_header->tag,
|
2014-02-25 21:36:43 +04:00
|
|
|
module->comm, accumulate_cb, acc_data);
|
2014-04-09 01:54:52 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
2014-02-25 21:36:43 +04:00
|
|
|
/* cancel the receive and free the accumulate data */
|
|
|
|
ompi_request_cancel (recv_request);
|
2014-03-12 18:39:03 +04:00
|
|
|
OBJ_RELEASE(acc_data);
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
OBJ_RELEASE(op);
|
|
|
|
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_accumulate_unlock (module);
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return ret;
|
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* ompi_osc_pt2pt_cswap_start:
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Start a compare and swap operation
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
* @param[in] source - Source rank
|
|
|
|
* @param[in] data - Compare and swap data
|
|
|
|
* @param[in] data_len - Length of the compare and swap data. Must be exactly
|
|
|
|
* twice the size of the datatype.
|
|
|
|
* @param[in] datatype - Compare and swap datatype
|
|
|
|
* @param[in] cswap_header - Compare and swap header
|
|
|
|
*
|
|
|
|
* The module's accumulation lock must be held before calling this
|
|
|
|
* function. It will release the lock when the operation is complete.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static int ompi_osc_pt2pt_cswap_start (ompi_osc_pt2pt_module_t *module, int source, void *data, ompi_datatype_t *datatype,
|
|
|
|
ompi_osc_pt2pt_header_cswap_t *cswap_header)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
void *target = (unsigned char*) module->baseptr +
|
|
|
|
((unsigned long) cswap_header->displacement * module->disp_unit);
|
|
|
|
void *compare_addr, *origin_addr;
|
|
|
|
size_t datatype_size;
|
|
|
|
ompi_proc_t *proc;
|
|
|
|
int ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
proc = ompi_comm_peer_lookup(module->comm, source);
|
|
|
|
assert (NULL != proc);
|
|
|
|
|
|
|
|
datatype_size = datatype->super.size;
|
|
|
|
|
|
|
|
origin_addr = data;
|
|
|
|
compare_addr = (void *)((uintptr_t) data + datatype_size);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
do {
|
|
|
|
/* no reason to do a non-blocking send here */
|
|
|
|
ret = MCA_PML_CALL(send(target, 1, datatype, source, cswap_header->tag, MCA_PML_BASE_SEND_STANDARD,
|
|
|
|
module->comm));
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
break;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-03-13 01:43:23 +04:00
|
|
|
/* increment the incoming fragment count so it matches what is expected */
|
2014-02-25 21:36:43 +04:00
|
|
|
mark_incoming_completion (module, (cswap_header->tag & 0x1) ? source : MPI_PROC_NULL);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
if (0 == memcmp (target, compare_addr, datatype_size)) {
|
2014-11-05 19:59:12 +03:00
|
|
|
osc_pt2pt_copy_on_recv (target, origin_addr, datatype_size, proc, 1, datatype);
|
2014-02-25 21:36:43 +04:00
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_accumulate_unlock (module);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-05 19:59:12 +03:00
|
|
|
* ompi_osc_pt2pt_progress_pending_acc:
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* @brief Progress one pending accumulation or compare and swap operation.
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-02-25 21:36:43 +04:00
|
|
|
*
|
2014-03-24 22:57:29 +04:00
|
|
|
* If the accumulation lock can be aquired progress one pending
|
|
|
|
* accumulate or compare and swap operation.
|
2014-02-25 21:36:43 +04:00
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
int ompi_osc_pt2pt_progress_pending_acc (ompi_osc_pt2pt_module_t *module)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
osc_pt2pt_pending_acc_t *pending_acc;
|
2014-02-25 21:36:43 +04:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* try to aquire the lock. it will be unlocked when the accumulate or cswap
|
|
|
|
* operation completes */
|
2014-11-05 19:59:12 +03:00
|
|
|
if (ompi_osc_pt2pt_accumulate_trylock (module)) {
|
2014-02-25 21:36:43 +04:00
|
|
|
return OMPI_SUCCESS;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
pending_acc = (osc_pt2pt_pending_acc_t *) opal_list_remove_first (&module->pending_acc);
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OPAL_UNLIKELY(NULL == pending_acc)) {
|
|
|
|
/* called without any pending accumulation operations */
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_accumulate_unlock (module);
|
2014-02-25 21:36:43 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
switch (pending_acc->header.base.type) {
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_ACC:
|
|
|
|
ret = ompi_osc_pt2pt_acc_start (module, pending_acc->source, pending_acc->data, pending_acc->data_len,
|
2014-02-25 21:36:43 +04:00
|
|
|
pending_acc->datatype, &pending_acc->header.acc);
|
|
|
|
free (pending_acc->data);
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_ACC_LONG:
|
|
|
|
ret = ompi_osc_pt2pt_acc_long_start (module, pending_acc->source, pending_acc->datatype,
|
2014-02-25 21:36:43 +04:00
|
|
|
&pending_acc->header.acc);
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC:
|
|
|
|
ret = ompi_osc_pt2pt_gacc_start (module, pending_acc->source, pending_acc->data,
|
2014-02-25 21:36:43 +04:00
|
|
|
pending_acc->data_len, pending_acc->datatype,
|
2014-06-17 18:53:24 +04:00
|
|
|
&pending_acc->header.acc);
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC_LONG:
|
2014-02-25 21:36:43 +04:00
|
|
|
ret = ompi_osc_gacc_long_start (module, pending_acc->source, pending_acc->datatype,
|
2014-06-17 18:53:24 +04:00
|
|
|
&pending_acc->header.acc);
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_CSWAP:
|
|
|
|
ret = ompi_osc_pt2pt_cswap_start (module, pending_acc->source, pending_acc->data,
|
2014-02-25 21:36:43 +04:00
|
|
|
pending_acc->datatype, &pending_acc->header.cswap);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = OMPI_ERROR;
|
|
|
|
/* it is a coding error if this point is reached */
|
|
|
|
assert (0);
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
2014-03-26 01:00:43 +04:00
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
/* signal that an operation is complete */
|
|
|
|
mark_incoming_completion (module, pending_acc->source);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
pending_acc->data = NULL;
|
|
|
|
OBJ_RELEASE(pending_acc);
|
|
|
|
|
2006-07-18 02:08:55 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_acc (ompi_osc_pt2pt_module_t *module, int source,
|
|
|
|
ompi_osc_pt2pt_header_acc_t *acc_header)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
char *data = (char *) (acc_header + 1);
|
|
|
|
struct ompi_datatype_t *datatype;
|
|
|
|
uint64_t data_len;
|
|
|
|
int ret;
|
2011-07-01 00:05:16 +04:00
|
|
|
|
2013-03-28 01:17:31 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-02-25 21:36:43 +04:00
|
|
|
"%d: process_acc: received message from %d",
|
|
|
|
ompi_comm_rank(module->comm),
|
|
|
|
source));
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
ret = datatype_create (module, source, NULL, &datatype, (void **) &data);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
return ret;
|
|
|
|
}
|
2011-07-01 00:05:16 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
data_len = acc_header->len - ((char*) data - (char*) acc_header);
|
2011-07-01 00:05:16 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* try to aquire the accumulate lock */
|
2014-11-05 19:59:12 +03:00
|
|
|
if (0 == ompi_osc_pt2pt_accumulate_trylock (module)) {
|
|
|
|
ret = ompi_osc_pt2pt_acc_start (module, source, data, data_len, datatype,
|
2014-02-25 21:36:43 +04:00
|
|
|
acc_header);
|
|
|
|
} else {
|
|
|
|
/* couldn't aquire the accumulate lock so queue up the accumulate operation */
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_acc_op_queue (module, (ompi_osc_pt2pt_header_t *) acc_header,
|
2014-02-25 21:36:43 +04:00
|
|
|
source, data, data_len, datatype);
|
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* Release datatype & op */
|
|
|
|
OBJ_RELEASE(datatype);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return (OMPI_SUCCESS == ret) ? (int) acc_header->len : ret;
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_acc_long (ompi_osc_pt2pt_module_t* module, int source,
|
|
|
|
ompi_osc_pt2pt_header_acc_t* acc_header)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
char *data = (char *) (acc_header + 1);
|
|
|
|
struct ompi_datatype_t *datatype;
|
|
|
|
int ret;
|
2007-05-31 00:32:02 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"%d: process_acc_long: received message from %d",
|
|
|
|
ompi_comm_rank(module->comm),
|
|
|
|
source));
|
2007-07-06 01:40:06 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
ret = datatype_create (module, source, NULL, &datatype, (void **) &data);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
return ret;
|
|
|
|
}
|
2007-07-06 01:40:06 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
if (0 == ompi_osc_pt2pt_accumulate_trylock (module)) {
|
|
|
|
ret = ompi_osc_pt2pt_acc_long_start (module, source, datatype, acc_header);
|
2006-07-18 02:08:55 +04:00
|
|
|
} else {
|
2014-02-25 21:36:43 +04:00
|
|
|
/* queue the operation */
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_acc_op_queue (module, (ompi_osc_pt2pt_header_t *) acc_header, source,
|
2014-02-25 21:36:43 +04:00
|
|
|
NULL, 0, datatype);
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* Release datatype & op */
|
|
|
|
OBJ_RELEASE(datatype);
|
|
|
|
|
|
|
|
return (OMPI_SUCCESS == ret) ? (int) acc_header->len : ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_get_acc(ompi_osc_pt2pt_module_t *module, int source,
|
|
|
|
ompi_osc_pt2pt_header_acc_t *acc_header)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2014-06-17 18:53:24 +04:00
|
|
|
char *data = (char *) (acc_header + 1);
|
2014-02-25 21:36:43 +04:00
|
|
|
struct ompi_datatype_t *datatype;
|
|
|
|
void *buffer = NULL;
|
|
|
|
uint64_t data_len;
|
2015-05-08 07:53:03 +03:00
|
|
|
ompi_proc_t * proc;
|
2014-02-25 21:36:43 +04:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"%d: process_get_acc: received message from %d",
|
|
|
|
ompi_comm_rank(module->comm),
|
|
|
|
source));
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2015-05-08 07:53:03 +03:00
|
|
|
ret = datatype_create (module, source, &proc, &datatype, (void **) &data);
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
return ret;
|
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-06-17 18:53:24 +04:00
|
|
|
data_len = acc_header->len - ((char*) data - (char*) acc_header);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
if (0 == ompi_osc_pt2pt_accumulate_trylock (module)) {
|
2014-02-25 21:36:43 +04:00
|
|
|
/* make a copy of the data since the buffer needs to be returned */
|
|
|
|
if (data_len) {
|
2015-05-08 07:53:03 +03:00
|
|
|
ompi_datatype_t *primitive_datatype = NULL;
|
|
|
|
uint32_t primitive_count;
|
2014-02-25 21:36:43 +04:00
|
|
|
buffer = malloc (data_len);
|
|
|
|
if (OPAL_UNLIKELY(NULL == buffer)) {
|
|
|
|
OBJ_RELEASE(datatype);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2007-07-14 00:46:12 +04:00
|
|
|
|
2015-05-08 07:53:03 +03:00
|
|
|
ompi_osc_base_get_primitive_type_info(datatype, &primitive_datatype, &primitive_count);
|
|
|
|
primitive_count *= acc_header->count;
|
|
|
|
|
|
|
|
osc_pt2pt_copy_on_recv (buffer, data, data_len, proc, primitive_count, primitive_datatype);
|
2014-02-25 21:36:43 +04:00
|
|
|
}
|
2007-07-14 00:46:12 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_gacc_start (module, source, buffer, data_len, datatype,
|
2014-06-17 18:53:24 +04:00
|
|
|
acc_header);
|
2007-07-14 00:46:12 +04:00
|
|
|
} else {
|
2014-02-25 21:36:43 +04:00
|
|
|
/* queue the operation */
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_acc_op_queue (module, (ompi_osc_pt2pt_header_t *) acc_header,
|
2014-02-25 21:36:43 +04:00
|
|
|
source, data, data_len, datatype);
|
2007-07-14 00:46:12 +04:00
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* Release datatype & op */
|
|
|
|
OBJ_RELEASE(datatype);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-06-17 18:53:24 +04:00
|
|
|
return (OMPI_SUCCESS == ret) ? (int) acc_header->len : ret;
|
2014-02-25 21:36:43 +04:00
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_get_acc_long(ompi_osc_pt2pt_module_t *module, int source,
|
|
|
|
ompi_osc_pt2pt_header_acc_t *acc_header)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2014-06-17 18:53:24 +04:00
|
|
|
char *data = (char *) (acc_header + 1);
|
2014-02-25 21:36:43 +04:00
|
|
|
struct ompi_datatype_t *datatype;
|
|
|
|
int ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"%d: process_acc: received message from %d",
|
|
|
|
ompi_comm_rank(module->comm),
|
|
|
|
source));
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
ret = datatype_create (module, source, NULL, &datatype, (void **) &data);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
return ret;
|
|
|
|
}
|
2011-07-01 00:05:16 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
if (0 == ompi_osc_pt2pt_accumulate_trylock (module)) {
|
2014-06-17 18:53:24 +04:00
|
|
|
ret = ompi_osc_gacc_long_start (module, source, datatype, acc_header);
|
2014-02-25 21:36:43 +04:00
|
|
|
} else {
|
|
|
|
/* queue the operation */
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_acc_op_queue (module, (ompi_osc_pt2pt_header_t *) acc_header,
|
2014-02-25 21:36:43 +04:00
|
|
|
source, NULL, 0, datatype);
|
|
|
|
}
|
2011-07-01 00:05:16 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* Release datatype & op */
|
|
|
|
OBJ_RELEASE(datatype);
|
|
|
|
|
2014-06-17 18:53:24 +04:00
|
|
|
return OMPI_SUCCESS == ret ? (int) acc_header->len : ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_cswap (ompi_osc_pt2pt_module_t *module, int source,
|
|
|
|
ompi_osc_pt2pt_header_cswap_t *cswap_header)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-02-25 21:36:43 +04:00
|
|
|
char *data = (char*) (cswap_header + 1);
|
|
|
|
struct ompi_datatype_t *datatype;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"%d: process_cswap: received message from %d",
|
|
|
|
ompi_comm_rank(module->comm),
|
|
|
|
source));
|
|
|
|
|
|
|
|
ret = datatype_create (module, source, NULL, &datatype, (void **) &data);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
return ret;
|
2007-05-31 00:32:02 +04:00
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
if (0 == ompi_osc_pt2pt_accumulate_trylock (module)) {
|
|
|
|
ret = ompi_osc_pt2pt_cswap_start (module, source, data, datatype, cswap_header);
|
2014-02-25 21:36:43 +04:00
|
|
|
} else {
|
|
|
|
/* queue the operation */
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_acc_op_queue (module, (ompi_osc_pt2pt_header_t *) cswap_header, source,
|
2014-02-25 21:36:43 +04:00
|
|
|
data, 2 * datatype->super.size, datatype);
|
|
|
|
}
|
2007-07-14 00:46:12 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* Release datatype */
|
|
|
|
OBJ_RELEASE(datatype);
|
2007-07-14 00:46:12 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return (OMPI_SUCCESS == ret) ? (int) cswap_header->len : ret;
|
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_complete (ompi_osc_pt2pt_module_t *module, int source,
|
|
|
|
ompi_osc_pt2pt_header_complete_t *complete_header)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2014-11-20 09:22:43 +03:00
|
|
|
/* the current fragment is not part of the frag_count so we need to add it here */
|
2015-05-29 17:33:34 +03:00
|
|
|
osc_pt2pt_incoming_complete (module, source, complete_header->frag_count + 1);
|
2014-03-25 19:28:36 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return sizeof (*complete_header);
|
|
|
|
}
|
2007-07-14 00:46:12 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* flush and unlock headers cannot be processed from the request callback
|
|
|
|
* because some btls do not provide re-entrant progress functions. these
|
2014-11-05 19:59:12 +03:00
|
|
|
* fragment will be progressed by the pt2pt component's progress function */
|
|
|
|
static inline int process_flush (ompi_osc_pt2pt_module_t *module, int source,
|
|
|
|
ompi_osc_pt2pt_header_flush_t *flush_header)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2015-05-29 17:33:34 +03:00
|
|
|
ompi_osc_pt2pt_peer_t *peer = ompi_osc_pt2pt_peer_lookup (module, source);
|
2014-02-25 21:36:43 +04:00
|
|
|
int ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"process_flush header = {.frag_count = %d}", flush_header->frag_count));
|
|
|
|
|
|
|
|
/* increase signal count by incoming frags */
|
2014-11-14 01:13:10 +03:00
|
|
|
OPAL_THREAD_ADD32(&peer->passive_incoming_frag_count, -(int32_t) flush_header->frag_count);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-14 01:13:10 +03:00
|
|
|
"%d: process_flush: received message from %d. passive_incoming_frag_count = %d",
|
|
|
|
ompi_comm_rank(module->comm), source, peer->passive_incoming_frag_count));
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_process_flush (module, source, flush_header);
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OMPI_SUCCESS != ret) {
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_pending_t *pending;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
pending = OBJ_NEW(ompi_osc_pt2pt_pending_t);
|
2014-02-25 21:36:43 +04:00
|
|
|
pending->module = module;
|
|
|
|
pending->source = source;
|
|
|
|
pending->header.flush = *flush_header;
|
2007-07-06 01:40:06 +04:00
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_add_pending (pending);
|
2014-11-20 09:22:43 +03:00
|
|
|
}
|
2014-11-14 01:13:10 +03:00
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
/* signal incomming will increment this counter */
|
|
|
|
OPAL_THREAD_ADD32(&peer->passive_incoming_frag_count, -1);
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return sizeof (*flush_header);
|
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_unlock (ompi_osc_pt2pt_module_t *module, int source,
|
|
|
|
ompi_osc_pt2pt_header_unlock_t *unlock_header)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2015-05-29 17:33:34 +03:00
|
|
|
ompi_osc_pt2pt_peer_t *peer = ompi_osc_pt2pt_peer_lookup (module, source);
|
2014-02-25 21:36:43 +04:00
|
|
|
int ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"process_unlock header = {.frag_count = %d}", unlock_header->frag_count));
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* increase signal count by incoming frags */
|
2014-11-14 01:13:10 +03:00
|
|
|
OPAL_THREAD_ADD32(&peer->passive_incoming_frag_count, -(int32_t) unlock_header->frag_count);
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((25, ompi_osc_base_framework.framework_output,
|
2014-11-14 01:13:10 +03:00
|
|
|
"osc pt2pt: processing unlock request from %d. frag count = %d, processed_count = %d",
|
|
|
|
source, unlock_header->frag_count, (int) peer->passive_incoming_frag_count));
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_process_unlock (module, source, unlock_header);
|
2014-02-25 21:36:43 +04:00
|
|
|
if (OMPI_SUCCESS != ret) {
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_pending_t *pending;
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
pending = OBJ_NEW(ompi_osc_pt2pt_pending_t);
|
2014-02-25 21:36:43 +04:00
|
|
|
pending->module = module;
|
|
|
|
pending->source = source;
|
|
|
|
pending->header.unlock = *unlock_header;
|
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_add_pending (pending);
|
2014-11-20 09:22:43 +03:00
|
|
|
}
|
2014-11-14 01:13:10 +03:00
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
/* signal incomming will increment this counter */
|
|
|
|
OPAL_THREAD_ADD32(&peer->passive_incoming_frag_count, -1);
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return sizeof (*unlock_header);
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-03-24 22:57:29 +04:00
|
|
|
static int process_large_datatype_request_cb (ompi_request_t *request)
|
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_ddt_buffer_t *ddt_buffer = (ompi_osc_pt2pt_ddt_buffer_t *) request->req_complete_cb_data;
|
|
|
|
ompi_osc_pt2pt_module_t *module = ddt_buffer->module;
|
|
|
|
ompi_osc_pt2pt_header_t *header = ddt_buffer->header;
|
2014-03-24 22:57:29 +04:00
|
|
|
int source = ddt_buffer->source;
|
|
|
|
|
|
|
|
/* process the request */
|
|
|
|
switch (header->base.type) {
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_PUT_LONG:
|
2014-03-24 22:57:29 +04:00
|
|
|
(void) process_put_long (module, source, &header->put);
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET:
|
2014-03-24 22:57:29 +04:00
|
|
|
(void) process_get (module, source, &header->get);
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_ACC_LONG:
|
2014-03-24 22:57:29 +04:00
|
|
|
(void) process_acc_long (module, source, &header->acc);
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC_LONG:
|
2014-06-17 18:53:24 +04:00
|
|
|
(void) process_get_acc_long (module, source, &header->acc);
|
2014-03-24 22:57:29 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* developer error */
|
|
|
|
assert (0);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put this request on the garbage colletion list */
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_add_request (module, request);
|
2014-03-24 22:57:29 +04:00
|
|
|
|
|
|
|
/* free the datatype buffer */
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_add_buffer (module, &ddt_buffer->super);
|
2014-03-24 22:57:29 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @short process a request with a large datatype
|
|
|
|
*
|
2014-11-05 19:59:12 +03:00
|
|
|
* @param[in] module - OSC PT2PT module
|
2014-03-24 22:57:29 +04:00
|
|
|
* @param[in] source - header source
|
|
|
|
* @param[in] header - header to process
|
|
|
|
*
|
|
|
|
* It is possible to construct datatypes whos description is too large
|
2014-11-05 19:59:12 +03:00
|
|
|
* to fit in an OSC PT2PT fragment. In this case the remote side posts
|
2014-03-24 22:57:29 +04:00
|
|
|
* a send of the datatype description. This function posts the matching
|
|
|
|
* receive and processes the header on completion.
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static int process_large_datatype_request (ompi_osc_pt2pt_module_t *module, int source, ompi_osc_pt2pt_header_t *header)
|
2014-03-24 22:57:29 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_ddt_buffer_t *ddt_buffer;
|
2014-03-24 22:57:29 +04:00
|
|
|
int header_len, tag, ret;
|
|
|
|
uint64_t ddt_len;
|
|
|
|
|
|
|
|
/* determine the header size and receive tag */
|
|
|
|
switch (header->base.type) {
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_PUT_LONG:
|
2014-03-24 22:57:29 +04:00
|
|
|
header_len = sizeof (header->put);
|
|
|
|
tag = header->put.tag;
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET:
|
2014-03-24 22:57:29 +04:00
|
|
|
header_len = sizeof (header->get);
|
|
|
|
tag = header->get.tag;
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_ACC_LONG:
|
2014-03-24 22:57:29 +04:00
|
|
|
header_len = sizeof (header->acc);
|
|
|
|
tag = header->acc.tag;
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC_LONG:
|
2014-06-17 18:53:24 +04:00
|
|
|
header_len = sizeof (header->acc);
|
|
|
|
tag = header->acc.tag;
|
2014-03-24 22:57:29 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* developer error */
|
|
|
|
opal_output (0, "Unsupported header/flag combination");
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ddt_len = *((uint64_t *)((uintptr_t) header + header_len));
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((25, ompi_osc_base_framework.framework_output,
|
|
|
|
"process_large_datatype_request: processing fragment with type %d. ddt_len %lu",
|
|
|
|
header->base.type, (unsigned long) ddt_len));
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ddt_buffer = OBJ_NEW(ompi_osc_pt2pt_ddt_buffer_t);
|
2014-03-24 22:57:29 +04:00
|
|
|
if (OPAL_UNLIKELY(NULL == ddt_buffer)) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ddt_buffer->module = module;
|
|
|
|
ddt_buffer->source = source;
|
|
|
|
|
|
|
|
ddt_buffer->header = malloc (ddt_len + header_len);
|
|
|
|
if (OPAL_UNLIKELY(NULL == ddt_buffer->header)) {
|
|
|
|
OBJ_RELEASE(ddt_buffer);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (ddt_buffer->header, header, header_len);
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
ret = ompi_osc_pt2pt_irecv_w_cb ((void *)((uintptr_t) ddt_buffer->header + header_len),
|
2014-03-24 22:57:29 +04:00
|
|
|
ddt_len, MPI_BYTE, source, tag, module->comm, NULL,
|
|
|
|
process_large_datatype_request_cb, ddt_buffer);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
OBJ_RELEASE(ddt_buffer);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return header_len + 8;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/*
|
|
|
|
* Do all the data movement associated with a fragment
|
|
|
|
*/
|
2014-11-05 19:59:12 +03:00
|
|
|
static inline int process_frag (ompi_osc_pt2pt_module_t *module,
|
|
|
|
ompi_osc_pt2pt_frag_header_t *frag)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_header_t *header;
|
2014-02-25 21:36:43 +04:00
|
|
|
int ret;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"osc pt2pt: process_frag: from %d, ops %d",
|
2014-02-25 21:36:43 +04:00
|
|
|
(int) frag->source, (int) frag->num_ops));
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
header = (ompi_osc_pt2pt_header_t *) (frag + 1);
|
2007-05-24 19:41:24 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
for (int i = 0 ; i < frag->num_ops ; ++i) {
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"osc pt2pt: process_frag: type 0x%x. flag 0x%x. offset %u",
|
2014-03-24 22:57:29 +04:00
|
|
|
header->base.type, (unsigned) ((uintptr_t)header - (uintptr_t)frag),
|
|
|
|
header->base.flags));
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
if (OPAL_LIKELY(!(header->base.flags & OMPI_OSC_PT2PT_HDR_FLAG_LARGE_DATATYPE))) {
|
2015-05-08 07:53:03 +03:00
|
|
|
osc_pt2pt_ntoh(header);
|
2014-03-24 22:57:29 +04:00
|
|
|
switch (header->base.type) {
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_PUT:
|
2014-03-24 22:57:29 +04:00
|
|
|
ret = process_put(module, frag->source, &header->put);
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_PUT_LONG:
|
2014-03-24 22:57:29 +04:00
|
|
|
ret = process_put_long(module, frag->source, &header->put);
|
|
|
|
break;
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_ACC:
|
2014-03-24 22:57:29 +04:00
|
|
|
ret = process_acc(module, frag->source, &header->acc);
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_ACC_LONG:
|
2014-03-24 22:57:29 +04:00
|
|
|
ret = process_acc_long (module, frag->source, &header->acc);
|
|
|
|
break;
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_LOCK_REQ:
|
|
|
|
ret = ompi_osc_pt2pt_process_lock(module, frag->source, &header->lock);
|
2014-03-24 22:57:29 +04:00
|
|
|
if (OPAL_LIKELY(OMPI_SUCCESS == ret)) {
|
|
|
|
ret = sizeof (header->lock);
|
|
|
|
}
|
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_UNLOCK_REQ:
|
2014-03-24 22:57:29 +04:00
|
|
|
ret = process_unlock(module, frag->source, &header->unlock);
|
|
|
|
break;
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET:
|
2014-03-24 22:57:29 +04:00
|
|
|
ret = process_get (module, frag->source, &header->get);
|
|
|
|
break;
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_CSWAP:
|
2014-03-24 22:57:29 +04:00
|
|
|
ret = process_cswap (module, frag->source, &header->cswap);
|
|
|
|
break;
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC:
|
2014-06-17 18:53:24 +04:00
|
|
|
ret = process_get_acc (module, frag->source, &header->acc);
|
2014-03-24 22:57:29 +04:00
|
|
|
break;
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC_LONG:
|
2014-06-17 18:53:24 +04:00
|
|
|
ret = process_get_acc_long (module, frag->source, &header->acc);
|
2014-03-24 22:57:29 +04:00
|
|
|
break;
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_FLUSH_REQ:
|
2014-03-24 22:57:29 +04:00
|
|
|
ret = process_flush (module, frag->source, &header->flush);
|
|
|
|
break;
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_COMPLETE:
|
2014-03-24 22:57:29 +04:00
|
|
|
ret = process_complete (module, frag->source, &header->complete);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
opal_output(0, "Unsupported fragment type 0x%x\n", header->base.type);
|
|
|
|
abort(); /* FIX ME */
|
2014-02-25 21:36:43 +04:00
|
|
|
}
|
2014-03-24 22:57:29 +04:00
|
|
|
} else {
|
|
|
|
ret = process_large_datatype_request (module, frag->source, header);
|
2014-02-25 21:36:43 +04:00
|
|
|
}
|
2014-03-24 22:57:29 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
if (ret <= 0) {
|
|
|
|
opal_output(0, "Error processing fragment: %d", ret);
|
|
|
|
abort(); /* FIX ME */
|
|
|
|
}
|
2011-07-01 00:05:16 +04:00
|
|
|
|
2014-03-10 22:11:22 +04:00
|
|
|
/* the next header will start on an 8-byte boundary. this is done to ensure
|
2014-03-10 22:57:20 +04:00
|
|
|
* that the next header and the packed datatype is properly aligned */
|
2014-11-05 19:59:12 +03:00
|
|
|
header = (ompi_osc_pt2pt_header_t *) OPAL_ALIGN(((uintptr_t) header + ret), 8, uintptr_t);
|
2014-02-25 21:36:43 +04:00
|
|
|
}
|
2011-07-01 00:05:16 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* dispatch for callback on message completion */
|
2014-11-05 19:59:12 +03:00
|
|
|
static int ompi_osc_pt2pt_callback (ompi_request_t *request)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_module_t *module = (ompi_osc_pt2pt_module_t *) request->req_complete_cb_data;
|
2015-05-08 07:53:03 +03:00
|
|
|
ompi_osc_pt2pt_header_t *base_header =
|
|
|
|
(ompi_osc_pt2pt_header_t *) module->incoming_buffer;
|
2014-03-13 01:43:23 +04:00
|
|
|
size_t incoming_length = request->req_status._ucount;
|
2014-02-25 21:36:43 +04:00
|
|
|
int source = request->req_status.MPI_SOURCE;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
assert(incoming_length >= sizeof(ompi_osc_pt2pt_header_base_t));
|
2014-02-25 21:36:43 +04:00
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"received pt2pt callback for fragment. source = %d, count = %u, type = 0x%x",
|
2015-05-08 07:53:03 +03:00
|
|
|
source, (unsigned) incoming_length, base_header->base.type));
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2015-05-08 07:53:03 +03:00
|
|
|
osc_pt2pt_ntoh(base_header);
|
|
|
|
switch (base_header->base.type) {
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_FRAG:
|
|
|
|
process_frag(module, (ompi_osc_pt2pt_frag_header_t *) base_header);
|
2015-04-23 22:07:54 +03:00
|
|
|
|
|
|
|
/* only data fragments should be included in the completion counters */
|
2015-05-29 17:33:34 +03:00
|
|
|
mark_incoming_completion (module, (base_header->base.flags & OMPI_OSC_PT2PT_HDR_FLAG_PASSIVE_TARGET) ?
|
|
|
|
source : MPI_PROC_NULL);
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_POST:
|
2015-05-29 17:33:34 +03:00
|
|
|
osc_pt2pt_incoming_post (module, source);
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_LOCK_ACK:
|
|
|
|
ompi_osc_pt2pt_process_lock_ack(module, (ompi_osc_pt2pt_header_lock_ack_t *) base_header);
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_FLUSH_ACK:
|
|
|
|
ompi_osc_pt2pt_process_flush_ack (module, source, (ompi_osc_pt2pt_header_flush_ack_t *) base_header);
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
2014-11-05 19:59:12 +03:00
|
|
|
case OMPI_OSC_PT2PT_HDR_TYPE_UNLOCK_ACK:
|
|
|
|
ompi_osc_pt2pt_process_unlock_ack (module, source, (ompi_osc_pt2pt_header_unlock_ack_t *) base_header);
|
2014-02-25 21:36:43 +04:00
|
|
|
break;
|
|
|
|
default:
|
2014-11-05 19:59:12 +03:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-02-25 21:36:43 +04:00
|
|
|
"received unexpected message of type %x",
|
2015-05-08 07:53:03 +03:00
|
|
|
(int) base_header->base.type));
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-03-13 01:43:23 +04:00
|
|
|
"finished processing incoming messages"));
|
2014-02-25 21:36:43 +04:00
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_clean (module);
|
2014-03-12 18:39:03 +04:00
|
|
|
|
2014-03-24 22:57:29 +04:00
|
|
|
/* put this request on the garbage colletion list */
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_add_request (module, request);
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_frag_start_receive (module);
|
2014-11-20 09:22:43 +03:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"finished posting receive request"));
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
int ompi_osc_pt2pt_frag_start_receive (ompi_osc_pt2pt_module_t *module)
|
2014-02-25 21:36:43 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
return ompi_osc_pt2pt_irecv_w_cb (module->incoming_buffer, mca_osc_pt2pt_component.buffer_size + sizeof (ompi_osc_pt2pt_frag_header_t),
|
|
|
|
MPI_BYTE, OMPI_ANY_SOURCE, OSC_PT2PT_FRAG_TAG, module->comm, &module->frag_request,
|
|
|
|
ompi_osc_pt2pt_callback, module);
|
2014-02-25 21:36:43 +04:00
|
|
|
}
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
int ompi_osc_pt2pt_component_irecv (ompi_osc_pt2pt_module_t *module, void *buf,
|
2014-02-25 21:36:43 +04:00
|
|
|
size_t count, struct ompi_datatype_t *datatype,
|
|
|
|
int src, int tag, struct ompi_communicator_t *comm)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
return ompi_osc_pt2pt_irecv_w_cb (buf, count, datatype, src, tag, comm, NULL,
|
|
|
|
osc_pt2pt_incoming_req_complete, module);
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
static int
|
|
|
|
isend_completion_cb(ompi_request_t *request)
|
2006-07-18 02:08:55 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_module_t *module =
|
|
|
|
(ompi_osc_pt2pt_module_t*) request->req_complete_cb_data;
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((10, ompi_osc_base_framework.framework_output,
|
|
|
|
"isend_completion_cb called"));
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
mark_outgoing_completion(module);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
/* put this request on the garbage colletion list */
|
2014-11-14 01:13:10 +03:00
|
|
|
osc_pt2pt_gc_add_request (module, request);
|
2006-07-18 02:08:55 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
return OMPI_SUCCESS;
|
2006-07-18 02:08:55 +04:00
|
|
|
}
|
2007-07-05 07:32:32 +04:00
|
|
|
|
|
|
|
|
2015-08-28 05:12:41 +03:00
|
|
|
int ompi_osc_pt2pt_component_isend (ompi_osc_pt2pt_module_t *module, const void *buf,
|
2014-11-14 01:13:10 +03:00
|
|
|
size_t count, struct ompi_datatype_t *datatype,
|
|
|
|
int dest, int tag, struct ompi_communicator_t *comm)
|
2007-07-05 07:32:32 +04:00
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
return ompi_osc_pt2pt_isend_w_cb (buf, count, datatype, dest, tag, comm,
|
2014-02-25 21:36:43 +04:00
|
|
|
isend_completion_cb, module);
|
|
|
|
}
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2015-08-28 05:12:41 +03:00
|
|
|
int ompi_osc_pt2pt_isend_w_cb (const void *ptr, int count, ompi_datatype_t *datatype, int target, int tag,
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_communicator_t *comm, ompi_request_complete_fn_t cb, void *ctx)
|
|
|
|
{
|
|
|
|
ompi_request_t *request;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"osc pt2pt: ompi_osc_pt2pt_isend_w_cb sending %d bytes to %d with tag %d",
|
2014-02-25 21:36:43 +04:00
|
|
|
count, target, tag));
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2015-08-28 05:12:41 +03:00
|
|
|
ret = MCA_PML_CALL(isend_init((void *)ptr, count, datatype, target, tag,
|
2014-02-25 21:36:43 +04:00
|
|
|
MCA_PML_BASE_SEND_STANDARD, comm, &request));
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"error sending fragment. ret = %d", ret));
|
|
|
|
return ret;
|
2007-07-05 07:32:32 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
request->req_complete_cb = cb;
|
|
|
|
request->req_complete_cb_data = ctx;
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
ret = MCA_PML_CALL(start(1, &request));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
int ompi_osc_pt2pt_irecv_w_cb (void *ptr, int count, ompi_datatype_t *datatype, int target, int tag,
|
2014-02-25 21:36:43 +04:00
|
|
|
ompi_communicator_t *comm, ompi_request_t **request_out,
|
|
|
|
ompi_request_complete_fn_t cb, void *ctx)
|
|
|
|
{
|
|
|
|
ompi_request_t *request;
|
|
|
|
int ret;
|
2007-07-05 07:32:32 +04:00
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"osc pt2pt: ompi_osc_pt2pt_irecv_w_cb receiving %d bytes from %d with tag %d",
|
2014-02-25 21:36:43 +04:00
|
|
|
count, target, tag));
|
|
|
|
|
|
|
|
ret = MCA_PML_CALL(irecv_init(ptr, count, datatype, target, tag, comm, &request));
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
|
|
|
"error posting receive. ret = %d", ret));
|
|
|
|
return ret;
|
2007-07-05 07:32:32 +04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:36:43 +04:00
|
|
|
request->req_complete_cb = cb;
|
|
|
|
request->req_complete_cb_data = ctx;
|
|
|
|
if (request_out) {
|
|
|
|
*request_out = request;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = MCA_PML_CALL(start(1, &request));
|
|
|
|
|
2007-07-05 07:32:32 +04:00
|
|
|
return ret;
|
|
|
|
}
|