2014-11-20 09:22:43 +03:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
|
2015-02-19 23:41:41 +03:00
|
|
|
* Copyright (c) 2014-2015 Los Alamos National Security, LLC. All rights
|
2014-11-20 09:22:43 +03:00
|
|
|
* reserved.
|
2015-01-22 07:43:44 +03:00
|
|
|
* Copyright (c) 2015 Research Organization for Information Science
|
|
|
|
* and Technology (RIST). All rights reserved.
|
2014-11-20 09:22:43 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include "opal/class/opal_list.h"
|
|
|
|
#include "ompi/mca/osc/base/base.h"
|
|
|
|
#include "ompi/mca/pml/pml.h"
|
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
#include "osc_pt2pt.h"
|
|
|
|
#include "osc_pt2pt_frag.h"
|
|
|
|
#include "osc_pt2pt_data_move.h"
|
2014-11-20 09:22:43 +03:00
|
|
|
|
2014-11-05 19:59:12 +03:00
|
|
|
static void ompi_osc_pt2pt_frag_constructor (ompi_osc_pt2pt_frag_t *frag){
|
2014-11-14 01:13:10 +03:00
|
|
|
frag->buffer = frag->super.ptr;
|
2014-11-20 09:22:43 +03:00
|
|
|
}
|
|
|
|
|
2015-02-19 23:41:41 +03:00
|
|
|
OBJ_CLASS_INSTANCE(ompi_osc_pt2pt_frag_t, opal_free_list_item_t,
|
2014-11-14 01:13:10 +03:00
|
|
|
ompi_osc_pt2pt_frag_constructor, NULL);
|
2014-11-20 09:22:43 +03:00
|
|
|
|
|
|
|
static int frag_send_cb (ompi_request_t *request)
|
|
|
|
{
|
2014-11-05 19:59:12 +03:00
|
|
|
ompi_osc_pt2pt_frag_t *frag =
|
|
|
|
(ompi_osc_pt2pt_frag_t*) request->req_complete_cb_data;
|
|
|
|
ompi_osc_pt2pt_module_t *module = frag->module;
|
2014-11-20 09:22:43 +03:00
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"osc pt2pt: frag_send complete to %d, frag = %p, request = %p",
|
2014-11-20 09:22:43 +03:00
|
|
|
frag->target, (void *) frag, (void *) request));
|
|
|
|
|
|
|
|
mark_outgoing_completion(module);
|
2015-02-19 23:41:41 +03:00
|
|
|
opal_free_list_return (&mca_osc_pt2pt_component.frags, &frag->super);
|
2014-11-20 09:22:43 +03: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-20 09:22:43 +03:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
static int frag_send (ompi_osc_pt2pt_module_t *module, ompi_osc_pt2pt_frag_t *frag)
|
2014-11-20 09:22:43 +03:00
|
|
|
{
|
|
|
|
int count;
|
|
|
|
|
|
|
|
count = (int)((uintptr_t) frag->top - (uintptr_t) frag->buffer);
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"osc pt2pt: frag_send called to %d, frag = %p, count = %d",
|
2014-11-20 09:22:43 +03:00
|
|
|
frag->target, (void *) frag, count));
|
|
|
|
|
2015-05-08 07:53:03 +03:00
|
|
|
OSC_PT2PT_HTON(frag->header, module, frag->target);
|
2014-11-05 19:59:12 +03:00
|
|
|
return ompi_osc_pt2pt_isend_w_cb (frag->buffer, count, MPI_BYTE, frag->target, OSC_PT2PT_FRAG_TAG,
|
2014-11-20 09:22:43 +03:00
|
|
|
module->comm, frag_send_cb, frag);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
int ompi_osc_pt2pt_frag_start (ompi_osc_pt2pt_module_t *module,
|
|
|
|
ompi_osc_pt2pt_frag_t *frag)
|
2014-11-20 09:22:43 +03:00
|
|
|
{
|
2014-11-14 01:13:10 +03:00
|
|
|
ompi_osc_pt2pt_peer_t *peer = module->peers + frag->target;
|
2014-11-20 09:22:43 +03:00
|
|
|
int ret;
|
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
assert(0 == frag->pending && peer->active_frag != frag);
|
2014-11-20 09:22:43 +03:00
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
/* we need to signal now that a frag is outgoing to ensure the count sent
|
|
|
|
* with the unlock message is correct */
|
|
|
|
ompi_osc_signal_outgoing (module, frag->target, 1);
|
|
|
|
|
2014-11-20 09:22:43 +03:00
|
|
|
/* if eager sends are not active, can't send yet, so buffer and
|
|
|
|
get out... */
|
2015-03-25 00:04:08 +03:00
|
|
|
if (!(peer->eager_send_active || module->all_access_epoch) || opal_list_get_size (&peer->queued_frags)) {
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output, "queuing fragment to peer %d",
|
|
|
|
frag->target));
|
|
|
|
OPAL_THREAD_SCOPED_LOCK(&peer->lock,
|
|
|
|
opal_list_append(&peer->queued_frags, (opal_list_item_t *) frag));
|
2014-11-14 01:13:10 +03:00
|
|
|
return OMPI_SUCCESS;
|
2014-11-20 09:22:43 +03:00
|
|
|
}
|
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output, "sending fragment to peer %d",
|
|
|
|
frag->target));
|
|
|
|
|
2014-11-20 09:22:43 +03:00
|
|
|
ret = frag_send(module, frag);
|
|
|
|
|
|
|
|
opal_condition_broadcast(&module->cond);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
static int ompi_osc_pt2pt_flush_active_frag (ompi_osc_pt2pt_module_t *module, int target)
|
2014-11-20 09:22:43 +03:00
|
|
|
{
|
2015-03-25 00:04:08 +03:00
|
|
|
ompi_osc_pt2pt_frag_t *active_frag = module->peers[target].active_frag;
|
2014-11-20 09:22:43 +03:00
|
|
|
int ret = OMPI_SUCCESS;
|
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
if (NULL == active_frag) {
|
|
|
|
/* nothing to do */
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-11-20 09:22:43 +03:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2015-04-24 00:34:40 +03:00
|
|
|
"osc pt2pt: flushing active fragment to target %d. pending: %d", target,
|
2015-03-25 00:04:08 +03:00
|
|
|
active_frag->pending));
|
2014-11-20 09:22:43 +03:00
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
if (opal_atomic_cmpset (&module->peers[target].active_frag, active_frag, NULL)) {
|
|
|
|
if (0 != OPAL_THREAD_ADD32(&active_frag->pending, -1)) {
|
2014-11-14 01:13:10 +03:00
|
|
|
/* communication going on while synchronizing; this is an rma usage bug */
|
2014-11-20 09:22:43 +03:00
|
|
|
return OMPI_ERR_RMA_SYNC;
|
|
|
|
}
|
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
ompi_osc_signal_outgoing (module, target, 1);
|
|
|
|
ret = frag_send (module, active_frag);
|
2014-11-20 09:22:43 +03:00
|
|
|
}
|
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ompi_osc_pt2pt_frag_flush_target (ompi_osc_pt2pt_module_t *module, int target)
|
|
|
|
{
|
|
|
|
ompi_osc_pt2pt_peer_t *peer = module->peers + target;
|
2015-04-24 00:34:40 +03:00
|
|
|
ompi_osc_pt2pt_frag_t *frag;
|
2015-03-25 00:04:08 +03:00
|
|
|
int ret = OMPI_SUCCESS;
|
|
|
|
|
2014-11-20 09:22:43 +03:00
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2015-04-24 00:34:40 +03:00
|
|
|
"osc pt2pt: frag flush to target target %d. queue fragments: %lu",
|
|
|
|
target, (unsigned long) opal_list_get_size (&peer->queued_frags)));
|
2014-11-20 09:22:43 +03:00
|
|
|
|
|
|
|
/* walk through the pending list and send */
|
2015-03-25 00:04:08 +03:00
|
|
|
OPAL_THREAD_LOCK(&peer->lock);
|
|
|
|
while (NULL != (frag = ((ompi_osc_pt2pt_frag_t *) opal_list_remove_first (&peer->queued_frags)))) {
|
|
|
|
ret = frag_send(module, frag);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
break;
|
2014-11-20 09:22:43 +03:00
|
|
|
}
|
|
|
|
}
|
2015-03-25 00:04:08 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&peer->lock);
|
|
|
|
|
|
|
|
/* XXX -- TODO -- better error handling */
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* flush the active frag */
|
|
|
|
ret = ompi_osc_pt2pt_flush_active_frag (module, target);
|
2014-11-20 09:22:43 +03:00
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2015-03-25 00:04:08 +03:00
|
|
|
"osc pt2pt: frag flush target %d finished", target));
|
2014-11-20 09:22:43 +03:00
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
return ret;
|
2014-11-20 09:22:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
int ompi_osc_pt2pt_frag_flush_all (ompi_osc_pt2pt_module_t *module)
|
2014-11-20 09:22:43 +03:00
|
|
|
{
|
|
|
|
int ret = OMPI_SUCCESS;
|
2015-04-24 00:34:40 +03:00
|
|
|
ompi_osc_pt2pt_frag_t *frag;
|
2014-11-20 09:22:43 +03:00
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"osc pt2pt: frag flush all begin"));
|
2014-11-20 09:22:43 +03:00
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
/* try to start all the queued frags */
|
|
|
|
for (int i = 0 ; i < ompi_comm_size (module->comm) ; ++i) {
|
|
|
|
ompi_osc_pt2pt_peer_t *peer = module->peers + i;
|
2014-11-20 09:22:43 +03:00
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
while (NULL != (frag = ((ompi_osc_pt2pt_frag_t *) opal_list_remove_first (&peer->queued_frags)))) {
|
|
|
|
ret = frag_send(module, frag);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
break;
|
2014-11-14 01:13:10 +03:00
|
|
|
}
|
2015-03-25 00:04:08 +03:00
|
|
|
}
|
2014-11-20 09:22:43 +03:00
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
/* XXX -- TODO -- better error handling */
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
return ret;
|
2014-11-20 09:22:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2015-03-25 00:04:08 +03:00
|
|
|
"osc pt2pt: flushing all active fragments"));
|
2014-11-20 09:22:43 +03:00
|
|
|
|
2015-03-25 00:04:08 +03:00
|
|
|
/* flush the active frag */
|
|
|
|
for (int i = 0 ; i < ompi_comm_size(module->comm) ; ++i) {
|
|
|
|
ret = ompi_osc_pt2pt_flush_active_frag (module, i);
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
return ret;
|
2014-11-20 09:22:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
|
2014-11-05 19:59:12 +03:00
|
|
|
"osc pt2pt: frag flush all done"));
|
2014-11-20 09:22:43 +03:00
|
|
|
|
2014-11-14 01:13:10 +03:00
|
|
|
return ret;
|
2014-11-20 09:22:43 +03:00
|
|
|
}
|