* Implement mtl_send in addition to mtl_sendi
This commit was SVN r26193.
Этот коммит содержится в:
родитель
27c8f71773
Коммит
cdaf110c0f
@ -45,7 +45,7 @@ mca_mtl_portals4_module_t ompi_mtl_portals4 = {
|
||||
ompi_mtl_portals4_del_procs,
|
||||
ompi_mtl_portals4_finalize,
|
||||
|
||||
NULL, /* send */
|
||||
ompi_mtl_portals4_send,
|
||||
ompi_mtl_portals4_isend,
|
||||
ompi_mtl_portals4_irecv,
|
||||
ompi_mtl_portals4_iprobe,
|
||||
|
@ -231,6 +231,13 @@ extern int ompi_mtl_portals4_del_procs(struct mca_mtl_base_module_t* mtl,
|
||||
struct ompi_proc_t** procs,
|
||||
struct mca_mtl_base_endpoint_t **mtl_peer_data);
|
||||
|
||||
extern int ompi_mtl_portals4_send(struct mca_mtl_base_module_t* mtl,
|
||||
struct ompi_communicator_t* comm,
|
||||
int dest,
|
||||
int tag,
|
||||
struct opal_convertor_t *convertor,
|
||||
mca_pml_base_send_mode_t mode);
|
||||
|
||||
extern int ompi_mtl_portals4_isend(struct mca_mtl_base_module_t* mtl,
|
||||
struct ompi_communicator_t* comm,
|
||||
int dest,
|
||||
|
@ -32,7 +32,7 @@ struct ompi_mtl_portals4_base_request_t {
|
||||
typedef struct ompi_mtl_portals4_base_request_t ompi_mtl_portals4_base_request_t;
|
||||
|
||||
|
||||
struct ompi_mtl_portals4_send_request_t {
|
||||
struct ompi_mtl_portals4_isend_request_t {
|
||||
ompi_mtl_portals4_base_request_t super;
|
||||
void *buffer_ptr;
|
||||
ptl_handle_md_t md_h;
|
||||
@ -40,6 +40,13 @@ struct ompi_mtl_portals4_send_request_t {
|
||||
volatile int event_count;
|
||||
int opcount;
|
||||
};
|
||||
typedef struct ompi_mtl_portals4_isend_request_t ompi_mtl_portals4_isend_request_t;
|
||||
|
||||
struct ompi_mtl_portals4_send_request_t {
|
||||
ompi_mtl_portals4_isend_request_t super;
|
||||
int retval;
|
||||
volatile int complete;
|
||||
};
|
||||
typedef struct ompi_mtl_portals4_send_request_t ompi_mtl_portals4_send_request_t;
|
||||
|
||||
|
||||
|
@ -36,11 +36,67 @@ ompi_mtl_portals4_send_callback(ptl_event_t *ev, struct ompi_mtl_portals4_base_r
|
||||
ompi_mtl_portals4_send_request_t* ptl_request =
|
||||
(ompi_mtl_portals4_send_request_t*) ptl_base_request;
|
||||
|
||||
if (ev->ni_fail_type != PTL_NI_OK) {
|
||||
opal_output_verbose(1, ompi_mtl_base_output,
|
||||
"%s:%d: send callback ni_fail_type: %d",
|
||||
__FILE__, __LINE__, ev->ni_fail_type);
|
||||
ptl_request->retval = OMPI_ERROR;
|
||||
opal_atomic_wmb();
|
||||
ptl_request->complete = true;
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output,
|
||||
"send %d got event of type %d",
|
||||
ptl_request->super.opcount, ev->type));
|
||||
|
||||
/* we only receive an ack if the message was received into an
|
||||
expected message. Otherwise, we don't get an ack, but mark
|
||||
completion when the message was pulled (long message). A short
|
||||
message starts at count 1, so the send event completes it. */
|
||||
if ( ++(ptl_request->super.event_count) == 2 ) {
|
||||
if (NULL != ptl_request->super.buffer_ptr) {
|
||||
free(ptl_request->super.buffer_ptr);
|
||||
}
|
||||
ret = PtlMDRelease(ptl_request->super.md_h);
|
||||
if (PTL_OK != ret) {
|
||||
opal_output_verbose(1, ompi_mtl_base_output,
|
||||
"%s:%d: send callback PtlMDRelease returned %d",
|
||||
__FILE__, __LINE__, ret);
|
||||
ptl_request->retval = OMPI_ERROR;
|
||||
}
|
||||
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output, "send %d completed",
|
||||
ptl_request->super.opcount));
|
||||
opal_atomic_wmb();
|
||||
ptl_request->complete = true;
|
||||
}
|
||||
|
||||
/* received an ack - unlink the me */
|
||||
if (ev->type == PTL_EVENT_ACK) {
|
||||
ret = PtlMEUnlink(ptl_request->super.me_h);
|
||||
if (PTL_OK != ret) {
|
||||
opal_output_verbose(1, ompi_mtl_base_output,
|
||||
"%s:%d: send callback PtlMDUnlink returned %d",
|
||||
__FILE__, __LINE__, ret);
|
||||
}
|
||||
}
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
ompi_mtl_portals4_isend_callback(ptl_event_t *ev, struct ompi_mtl_portals4_base_request_t* ptl_base_request)
|
||||
{
|
||||
int ret;
|
||||
ompi_mtl_portals4_isend_request_t* ptl_request =
|
||||
(ompi_mtl_portals4_isend_request_t*) ptl_base_request;
|
||||
|
||||
assert(NULL != ptl_request->super.super.ompi_req);
|
||||
|
||||
if (ev->ni_fail_type != PTL_NI_OK) {
|
||||
opal_output_verbose(1, ompi_mtl_base_output,
|
||||
"%s:%d: send callback ni_fail_type: %d",
|
||||
"%s:%d: isend callback ni_fail_type: %d",
|
||||
__FILE__, __LINE__, ev->ni_fail_type);
|
||||
ptl_request->super.super.ompi_req->req_status.MPI_ERROR = OMPI_ERROR;
|
||||
ptl_request->super.super.completion_callback(&ptl_request->super.super);
|
||||
@ -48,7 +104,7 @@ ompi_mtl_portals4_send_callback(ptl_event_t *ev, struct ompi_mtl_portals4_base_r
|
||||
}
|
||||
|
||||
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output,
|
||||
"Send %d got event of type %d",
|
||||
"isend %d got event of type %d",
|
||||
ptl_request->opcount, ev->type));
|
||||
|
||||
/* we only receive an ack if the message was received into an
|
||||
@ -62,11 +118,11 @@ ompi_mtl_portals4_send_callback(ptl_event_t *ev, struct ompi_mtl_portals4_base_r
|
||||
ret = PtlMDRelease(ptl_request->md_h);
|
||||
if (PTL_OK != ret) {
|
||||
opal_output_verbose(1, ompi_mtl_base_output,
|
||||
"%s:%d: send callback PtlMDRelease returned %d",
|
||||
"%s:%d: isend callback PtlMDRelease returned %d",
|
||||
__FILE__, __LINE__, ret);
|
||||
ptl_request->super.super.ompi_req->req_status.MPI_ERROR = OMPI_ERROR;
|
||||
}
|
||||
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output, "Send %d completed",
|
||||
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output, "isend %d completed",
|
||||
ptl_request->opcount));
|
||||
ptl_request->super.super.completion_callback(&ptl_request->super.super);
|
||||
}
|
||||
@ -76,7 +132,7 @@ ompi_mtl_portals4_send_callback(ptl_event_t *ev, struct ompi_mtl_portals4_base_r
|
||||
ret = PtlMEUnlink(ptl_request->me_h);
|
||||
if (PTL_OK != ret) {
|
||||
opal_output_verbose(1, ompi_mtl_base_output,
|
||||
"%s:%d: send callback PtlMDUnlink returned %d",
|
||||
"%s:%d: isend callback PtlMDUnlink returned %d",
|
||||
__FILE__, __LINE__, ret);
|
||||
}
|
||||
}
|
||||
@ -90,14 +146,13 @@ ompi_mtl_portals4_short_isend(mca_pml_base_send_mode_t mode,
|
||||
void *start, int length, int contextid, int tag,
|
||||
int localrank,
|
||||
mca_mtl_base_endpoint_t *endpoint,
|
||||
ompi_mtl_portals4_send_request_t *ptl_request)
|
||||
ompi_mtl_portals4_isend_request_t *ptl_request)
|
||||
{
|
||||
int ret;
|
||||
ptl_match_bits_t mode_bits, match_bits;
|
||||
ptl_hdr_data_t hdr_data;
|
||||
ptl_md_t md;
|
||||
|
||||
ptl_request->super.event_callback = ompi_mtl_portals4_send_callback;
|
||||
ptl_request->event_count = 1;
|
||||
|
||||
mode_bits = (MCA_PML_BASE_SEND_READY != mode) ? MTL_PORTALS4_SHORT_MSG : MTL_PORTALS4_READY_MSG;
|
||||
@ -151,7 +206,7 @@ static int
|
||||
ompi_mtl_portals4_sync_isend(void *start, int length, int contextid, int tag,
|
||||
int localrank,
|
||||
mca_mtl_base_endpoint_t *endpoint,
|
||||
ompi_mtl_portals4_send_request_t *ptl_request)
|
||||
ompi_mtl_portals4_isend_request_t *ptl_request)
|
||||
{
|
||||
int ret;
|
||||
ptl_match_bits_t match_bits;
|
||||
@ -159,8 +214,6 @@ ompi_mtl_portals4_sync_isend(void *start, int length, int contextid, int tag,
|
||||
ptl_me_t me;
|
||||
ptl_hdr_data_t hdr_data;
|
||||
|
||||
ptl_request->super.event_callback = ompi_mtl_portals4_send_callback;
|
||||
|
||||
MTL_PORTALS4_SET_SEND_BITS(match_bits, contextid, localrank, tag,
|
||||
MTL_PORTALS4_SHORT_MSG);
|
||||
|
||||
@ -242,7 +295,7 @@ static int
|
||||
ompi_mtl_portals4_long_isend(void *start, int length, int contextid, int tag,
|
||||
int localrank, int destrank,
|
||||
mca_mtl_base_endpoint_t *endpoint,
|
||||
ompi_mtl_portals4_send_request_t *ptl_request)
|
||||
ompi_mtl_portals4_isend_request_t *ptl_request)
|
||||
{
|
||||
int ret;
|
||||
ptl_match_bits_t match_bits;
|
||||
@ -250,8 +303,6 @@ ompi_mtl_portals4_long_isend(void *start, int length, int contextid, int tag,
|
||||
ptl_me_t me;
|
||||
ptl_hdr_data_t hdr_data;
|
||||
|
||||
ptl_request->super.event_callback = ompi_mtl_portals4_send_callback;
|
||||
|
||||
MTL_PORTALS4_SET_SEND_BITS(match_bits, contextid, localrank, tag, MTL_PORTALS4_LONG_MSG);
|
||||
|
||||
MTL_PORTALS4_SET_HDR_DATA(hdr_data, ptl_request->opcount, length, 0);
|
||||
@ -340,25 +391,22 @@ ompi_mtl_portals4_long_isend(void *start, int length, int contextid, int tag,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
ompi_mtl_portals4_isend(struct mca_mtl_base_module_t* mtl,
|
||||
struct ompi_communicator_t* comm,
|
||||
int dest,
|
||||
int tag,
|
||||
struct opal_convertor_t *convertor,
|
||||
mca_pml_base_send_mode_t mode,
|
||||
bool blocking,
|
||||
mca_mtl_request_t *mtl_request)
|
||||
static inline int
|
||||
ompi_mtl_portals4_start_send(struct mca_mtl_base_module_t* mtl,
|
||||
struct ompi_communicator_t* comm,
|
||||
int dest,
|
||||
int tag,
|
||||
struct opal_convertor_t *convertor,
|
||||
mca_pml_base_send_mode_t mode,
|
||||
ompi_mtl_portals4_isend_request_t* ptl_request)
|
||||
{
|
||||
int ret = OMPI_SUCCESS;
|
||||
ompi_proc_t *ompi_proc = ompi_comm_peer_lookup( comm, dest );
|
||||
mca_mtl_base_endpoint_t *endpoint = (mca_mtl_base_endpoint_t*)ompi_proc->proc_pml;
|
||||
ompi_mtl_portals4_send_request_t *ptl_request = (ompi_mtl_portals4_send_request_t*)mtl_request;
|
||||
int ret;
|
||||
void *start;
|
||||
size_t length;
|
||||
bool free_after;
|
||||
ompi_proc_t *ompi_proc = ompi_comm_peer_lookup(comm, dest);
|
||||
mca_mtl_base_endpoint_t *endpoint =
|
||||
(mca_mtl_base_endpoint_t*) ompi_proc->proc_pml;
|
||||
|
||||
ret = ompi_mtl_datatype_pack(convertor, &start, &length, &free_after);
|
||||
if (OMPI_SUCCESS != ret) return ret;
|
||||
@ -366,7 +414,6 @@ ompi_mtl_portals4_isend(struct mca_mtl_base_module_t* mtl,
|
||||
ptl_request->opcount = ++ompi_mtl_portals4.opcount;
|
||||
ptl_request->buffer_ptr = (free_after) ? start : NULL;
|
||||
ptl_request->event_count = 0;
|
||||
ptl_request->super.super.ompi_req->req_status.MPI_ERROR = OMPI_SUCCESS;
|
||||
|
||||
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output,
|
||||
"Send %d to %x,%x of length %d\n",
|
||||
@ -435,6 +482,61 @@ ompi_mtl_portals4_isend(struct mca_mtl_base_module_t* mtl,
|
||||
return OMPI_ERR_NOT_SUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
ompi_mtl_portals4_send(struct mca_mtl_base_module_t* mtl,
|
||||
struct ompi_communicator_t* comm,
|
||||
int dest,
|
||||
int tag,
|
||||
struct opal_convertor_t *convertor,
|
||||
mca_pml_base_send_mode_t mode)
|
||||
{
|
||||
int ret = OMPI_SUCCESS;
|
||||
ompi_mtl_portals4_send_request_t ptl_request;
|
||||
|
||||
ptl_request.complete = false;
|
||||
ptl_request.retval = OMPI_SUCCESS;
|
||||
ptl_request.super.super.event_callback = ompi_mtl_portals4_send_callback;
|
||||
|
||||
ret = ompi_mtl_portals4_start_send(mtl, comm, dest, tag,
|
||||
convertor, mode, &ptl_request.super);
|
||||
if (OMPI_SUCCESS != ret) goto cleanup;
|
||||
|
||||
while (false == ptl_request.complete) {
|
||||
opal_atomic_mb();
|
||||
ompi_mtl_portals4_progress();
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (NULL != ptl_request.super.buffer_ptr) {
|
||||
free(ptl_request.super.buffer_ptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
ompi_mtl_portals4_isend(struct mca_mtl_base_module_t* mtl,
|
||||
struct ompi_communicator_t* comm,
|
||||
int dest,
|
||||
int tag,
|
||||
struct opal_convertor_t *convertor,
|
||||
mca_pml_base_send_mode_t mode,
|
||||
bool blocking,
|
||||
mca_mtl_request_t *mtl_request)
|
||||
{
|
||||
int ret = OMPI_SUCCESS;
|
||||
ompi_mtl_portals4_isend_request_t *ptl_request = (ompi_mtl_portals4_isend_request_t*)mtl_request;
|
||||
|
||||
ptl_request->super.event_callback = ompi_mtl_portals4_isend_callback;
|
||||
|
||||
ret = ompi_mtl_portals4_start_send(mtl, comm, dest, tag,
|
||||
convertor, mode, ptl_request);
|
||||
|
||||
if (OMPI_SUCCESS != ret && NULL != ptl_request->buffer_ptr) {
|
||||
free(ptl_request->buffer_ptr);
|
||||
@ -442,3 +544,4 @@ ompi_mtl_portals4_isend(struct mca_mtl_base_module_t* mtl,
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user