2010-10-15 02:49:09 +04:00
|
|
|
/*
|
2010-12-07 23:11:25 +03:00
|
|
|
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2010 Sandia National Laboratories. All rights reserved.
|
2010-10-15 02:49:09 +04:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <portals4.h>
|
|
|
|
|
2011-06-01 21:20:18 +04:00
|
|
|
#include "orte/util/name_fns.h"
|
|
|
|
#include "ompi/proc/proc.h"
|
2010-10-15 02:49:09 +04:00
|
|
|
#include "ompi/mca/mtl/mtl.h"
|
2010-12-07 23:11:25 +03:00
|
|
|
#include "opal/class/opal_list.h"
|
2011-05-26 02:10:27 +04:00
|
|
|
#include "ompi/runtime/ompi_module_exchange.h"
|
2010-10-15 02:49:09 +04:00
|
|
|
|
|
|
|
#include "mtl_portals4.h"
|
|
|
|
#include "mtl_portals4_endpoint.h"
|
|
|
|
#include "mtl_portals4_request.h"
|
2010-12-07 23:11:25 +03:00
|
|
|
#include "mtl_portals4_recv_short.h"
|
2010-10-15 02:49:09 +04:00
|
|
|
|
2011-05-26 02:10:27 +04:00
|
|
|
extern mca_mtl_base_component_2_0_0_t mca_mtl_portals4_component;
|
|
|
|
|
2010-10-15 02:49:09 +04:00
|
|
|
mca_mtl_portals4_module_t ompi_mtl_portals4 = {
|
|
|
|
{
|
|
|
|
8191, /* max cid - 2^13 - 1 */
|
|
|
|
(1UL << 30), /* max tag value - must allow negatives */
|
|
|
|
0, /* request reserve space */
|
|
|
|
0, /* flags */
|
|
|
|
|
|
|
|
ompi_mtl_portals4_add_procs,
|
|
|
|
ompi_mtl_portals4_del_procs,
|
|
|
|
ompi_mtl_portals4_finalize,
|
|
|
|
|
2010-12-07 23:11:25 +03:00
|
|
|
NULL, /* send */
|
2010-10-15 02:49:09 +04:00
|
|
|
ompi_mtl_portals4_isend,
|
|
|
|
ompi_mtl_portals4_irecv,
|
|
|
|
ompi_mtl_portals4_iprobe,
|
|
|
|
|
2011-07-06 22:25:49 +04:00
|
|
|
NULL, /* cancel */
|
|
|
|
NULL, /* add_comm */
|
|
|
|
NULL /* del_comm */
|
2010-10-15 02:49:09 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_mtl_portals4_add_procs(struct mca_mtl_base_module_t *mtl,
|
2010-12-07 23:11:25 +03:00
|
|
|
size_t nprocs,
|
|
|
|
struct ompi_proc_t** procs,
|
|
|
|
struct mca_mtl_base_endpoint_t **mtl_peer_data)
|
2010-10-15 02:49:09 +04:00
|
|
|
{
|
2010-12-07 23:11:25 +03:00
|
|
|
int ret;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
/* Get the list of ptl_process_id_t from the runtime and copy into structure */
|
|
|
|
for (i = 0 ; i < nprocs ; ++i) {
|
2011-05-26 02:10:27 +04:00
|
|
|
ptl_process_t *id;
|
|
|
|
size_t size;
|
|
|
|
|
2011-06-01 21:20:18 +04:00
|
|
|
if (procs[i]->proc_arch != ompi_proc_local()->proc_arch) {
|
2011-09-30 02:26:33 +04:00
|
|
|
opal_output_verbose(1, ompi_mtl_base_output,
|
|
|
|
"Portals 4 MTL does not support heterogeneous operations.");
|
|
|
|
opal_output_verbose(1, ompi_mtl_base_output,
|
|
|
|
"Proc %s architecture %x, mine %x.",
|
|
|
|
ORTE_NAME_PRINT(&procs[i]->proc_name),
|
|
|
|
procs[i]->proc_arch, ompi_proc_local()->proc_arch);
|
2011-06-13 19:18:55 +04:00
|
|
|
return OMPI_ERR_NOT_SUPPORTED;
|
2011-06-01 21:20:18 +04:00
|
|
|
}
|
|
|
|
|
2010-12-07 23:11:25 +03:00
|
|
|
mtl_peer_data[i] = malloc(sizeof(struct mca_mtl_base_endpoint_t));
|
|
|
|
if (NULL == mtl_peer_data[i]) {
|
2011-09-30 02:26:33 +04:00
|
|
|
opal_output_verbose(1, ompi_mtl_base_output,
|
|
|
|
"%s:%d: malloc failed: %d\n",
|
|
|
|
__FILE__, __LINE__, ret);
|
2011-06-13 19:18:55 +04:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2010-12-07 23:11:25 +03:00
|
|
|
}
|
2011-05-26 02:10:27 +04:00
|
|
|
|
|
|
|
ret = ompi_modex_recv(&mca_mtl_portals4_component.mtl_version,
|
|
|
|
procs[i], (void**) &id, &size);
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
2011-09-30 02:26:33 +04:00
|
|
|
opal_output_verbose(1, ompi_mtl_base_output,
|
|
|
|
"%s:%d: ompi_modex_recv failed: %d\n",
|
|
|
|
__FILE__, __LINE__, ret);
|
2011-05-26 02:10:27 +04:00
|
|
|
return ret;
|
|
|
|
} else if (sizeof(ptl_process_t) != size) {
|
2011-09-30 02:26:33 +04:00
|
|
|
opal_output_verbose(1, ompi_mtl_base_output,
|
|
|
|
"%s:%d: ompi_modex_recv failed: %d\n",
|
|
|
|
__FILE__, __LINE__, ret);
|
2011-06-13 19:18:55 +04:00
|
|
|
return OMPI_ERR_BAD_PARAM;
|
2011-05-26 02:10:27 +04:00
|
|
|
}
|
2011-06-01 21:20:18 +04:00
|
|
|
|
2011-05-26 02:10:27 +04:00
|
|
|
mtl_peer_data[i]->ptl_proc = *id;
|
2010-10-15 02:49:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_mtl_portals4_del_procs(struct mca_mtl_base_module_t *mtl,
|
2010-12-07 23:11:25 +03:00
|
|
|
size_t nprocs,
|
|
|
|
struct ompi_proc_t** procs,
|
|
|
|
struct mca_mtl_base_endpoint_t **mtl_peer_data)
|
2010-10-15 02:49:09 +04:00
|
|
|
{
|
2010-12-07 23:11:25 +03:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0 ; i < nprocs ; ++i) {
|
|
|
|
if (NULL != mtl_peer_data[i]) {
|
|
|
|
free(mtl_peer_data[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-15 02:49:09 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ompi_mtl_portals4_finalize(struct mca_mtl_base_module_t *mtl)
|
|
|
|
{
|
2010-12-07 23:11:25 +03:00
|
|
|
opal_progress_unregister(ompi_mtl_portals4_progress);
|
|
|
|
while (0 != ompi_mtl_portals4_progress()) { }
|
|
|
|
|
|
|
|
ompi_mtl_portals4_recv_short_fini(&ompi_mtl_portals4);
|
2011-06-13 19:18:55 +04:00
|
|
|
|
2010-12-07 23:11:25 +03:00
|
|
|
PtlMEUnlink(ompi_mtl_portals4.long_overflow_me_h);
|
|
|
|
PtlMDRelease(ompi_mtl_portals4.zero_md_h);
|
2011-06-13 19:18:55 +04:00
|
|
|
PtlPTFree(ompi_mtl_portals4.ni_h, ompi_mtl_portals4.read_idx);
|
|
|
|
PtlPTFree(ompi_mtl_portals4.ni_h, ompi_mtl_portals4.send_idx);
|
2010-12-07 23:11:25 +03:00
|
|
|
PtlEQFree(ompi_mtl_portals4.eq_h);
|
|
|
|
PtlNIFini(ompi_mtl_portals4.ni_h);
|
2010-10-15 02:49:09 +04:00
|
|
|
PtlFini();
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2010-12-07 23:11:25 +03:00
|
|
|
|
2011-01-19 23:49:28 +03:00
|
|
|
int
|
|
|
|
ompi_mtl_portals4_cancel(struct mca_mtl_base_module_t* mtl,
|
|
|
|
mca_mtl_request_t *mtl_request,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-12-07 23:11:25 +03:00
|
|
|
|
|
|
|
int
|
|
|
|
ompi_mtl_portals4_progress(void)
|
|
|
|
{
|
|
|
|
int count = 0, ret;
|
|
|
|
ptl_event_t ev;
|
2011-09-28 02:45:00 +04:00
|
|
|
ompi_mtl_portals4_base_request_t *ptl_request;
|
2010-12-07 23:11:25 +03:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
ret = PtlEQGet(ompi_mtl_portals4.eq_h, &ev);
|
|
|
|
if (PTL_OK == ret) {
|
2011-09-29 01:18:47 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((60, ompi_mtl_base_output,
|
2010-12-07 23:11:25 +03:00
|
|
|
"Found event of type %d\n", ev.type));
|
|
|
|
switch (ev.type) {
|
|
|
|
case PTL_EVENT_GET:
|
|
|
|
case PTL_EVENT_PUT:
|
|
|
|
case PTL_EVENT_PUT_OVERFLOW:
|
|
|
|
case PTL_EVENT_ATOMIC:
|
|
|
|
case PTL_EVENT_ATOMIC_OVERFLOW:
|
|
|
|
case PTL_EVENT_REPLY:
|
|
|
|
case PTL_EVENT_SEND:
|
|
|
|
case PTL_EVENT_ACK:
|
2011-09-30 02:26:33 +04:00
|
|
|
case PTL_EVENT_AUTO_FREE:
|
|
|
|
case PTL_EVENT_SEARCH:
|
2010-12-07 23:11:25 +03:00
|
|
|
if (NULL != ev.user_ptr) {
|
|
|
|
ptl_request = ev.user_ptr;
|
|
|
|
ret = ptl_request->event_callback(&ev, ptl_request);
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
opal_output(ompi_mtl_base_output,
|
2011-09-30 02:26:33 +04:00
|
|
|
"Error returned from target event callback: %d", ret);
|
2010-12-07 23:11:25 +03:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PTL_EVENT_PT_DISABLED:
|
2011-09-30 02:26:33 +04:00
|
|
|
/* BWB: FIX ME: do stuff - flow control */
|
2011-09-28 20:53:01 +04:00
|
|
|
opal_output(ompi_mtl_base_output, "Unhandled send flow control event.");
|
|
|
|
abort();
|
|
|
|
break;
|
|
|
|
case PTL_EVENT_AUTO_UNLINK:
|
2011-09-30 02:26:33 +04:00
|
|
|
opal_output_verbose(1, ompi_mtl_base_output,
|
|
|
|
"Unexpected auto unlink event");
|
2011-09-28 20:53:01 +04:00
|
|
|
break;
|
2011-09-30 02:26:33 +04:00
|
|
|
case PTL_EVENT_GET_OVERFLOW:
|
|
|
|
case PTL_EVENT_FETCH_ATOMIC:
|
|
|
|
case PTL_EVENT_FETCH_ATOMIC_OVERFLOW:
|
|
|
|
opal_output_verbose(1, ompi_mtl_base_output,
|
|
|
|
"Unexpected event of type %d", ev.type);
|
2010-12-07 23:11:25 +03:00
|
|
|
}
|
|
|
|
} else if (PTL_EQ_EMPTY == ret) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
opal_output(ompi_mtl_base_output,
|
|
|
|
"Error returned from PtlEQGet: %d", ret);
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|