Reduce the number of branches. Keep the fast path as short as possible.
Remove some useless error checking. Add OPAL_UNLIKELY directives. This commit was SVN r12477.
Этот коммит содержится в:
родитель
f3de2e1a82
Коммит
63462331c9
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "ompi_config.h"
|
#include "ompi_config.h"
|
||||||
|
|
||||||
|
#include "opal/prefetch.h"
|
||||||
|
|
||||||
#include "ompi/mca/mtl/mtl.h"
|
#include "ompi/mca/mtl/mtl.h"
|
||||||
#include "ompi/communicator/communicator.h"
|
#include "ompi/communicator/communicator.h"
|
||||||
#include "opal/class/opal_list.h"
|
#include "opal/class/opal_list.h"
|
||||||
@ -104,7 +106,7 @@ int ompi_mtl_mx_module_init(){
|
|||||||
opal_progress_register(ompi_mtl_mx_progress);
|
opal_progress_register(ompi_mtl_mx_progress);
|
||||||
|
|
||||||
|
|
||||||
return(mx_return==MX_SUCCESS ? OMPI_SUCCESS : OMPI_ERROR);
|
return OMPI_SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -178,7 +180,7 @@ int ompi_mtl_mx_progress( void ) {
|
|||||||
&mx_request,
|
&mx_request,
|
||||||
&result);
|
&result);
|
||||||
|
|
||||||
if(mx_return != MX_SUCCESS) {
|
if( OPAL_UNLIKELY(mx_return != MX_SUCCESS) ) {
|
||||||
opal_output(ompi_mtl_base_output, "Error in mx_ipeek (error %s)\n", mx_strerror(mx_return));
|
opal_output(ompi_mtl_base_output, "Error in mx_ipeek (error %s)\n", mx_strerror(mx_return));
|
||||||
}
|
}
|
||||||
if(result) {
|
if(result) {
|
||||||
@ -187,11 +189,11 @@ int ompi_mtl_mx_progress( void ) {
|
|||||||
&mx_request,
|
&mx_request,
|
||||||
&mx_status,
|
&mx_status,
|
||||||
&result);
|
&result);
|
||||||
if(mx_return != MX_SUCCESS) {
|
if( OPAL_UNLIKELY(mx_return != MX_SUCCESS) ) {
|
||||||
opal_output(ompi_mtl_base_output, "Error in mx_test (error %s)\n", mx_strerror(mx_return));
|
opal_output(ompi_mtl_base_output, "Error in mx_test (error %s)\n", mx_strerror(mx_return));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if(0 == result) {
|
if( OPAL_UNLIKELY(0 == result) ) {
|
||||||
opal_output(ompi_mtl_base_output, "Error in ompi_mtl_mx_progress, mx_ipeek returned a request, mx_test on the request resulted failure.\n");
|
opal_output(ompi_mtl_base_output, "Error in ompi_mtl_mx_progress, mx_ipeek returned a request, mx_test on the request resulted failure.\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -200,23 +202,8 @@ int ompi_mtl_mx_progress( void ) {
|
|||||||
if(mtl_mx_request->free_after) {
|
if(mtl_mx_request->free_after) {
|
||||||
free(mtl_mx_request->mx_segment[0].segment_ptr);
|
free(mtl_mx_request->mx_segment[0].segment_ptr);
|
||||||
}
|
}
|
||||||
switch (mx_status.code) {
|
} else {
|
||||||
case MX_STATUS_SUCCESS:
|
assert( OMPI_MTL_MX_IRECV == mtl_mx_request->type );
|
||||||
mtl_mx_request->super.ompi_req->req_status.MPI_ERROR =
|
|
||||||
OMPI_SUCCESS;
|
|
||||||
break;
|
|
||||||
case MX_STATUS_TRUNCATED:
|
|
||||||
mtl_mx_request->super.ompi_req->req_status.MPI_ERROR =
|
|
||||||
MPI_ERR_TRUNCATE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
mtl_mx_request->super.ompi_req->req_status.MPI_ERROR =
|
|
||||||
MPI_ERR_INTERN;
|
|
||||||
}
|
|
||||||
mtl_mx_request->super.completion_callback(&mtl_mx_request->super);
|
|
||||||
return completed;
|
|
||||||
}
|
|
||||||
if(OMPI_MTL_MX_IRECV == mtl_mx_request->type) {
|
|
||||||
|
|
||||||
ompi_mtl_datatype_unpack(mtl_mx_request->convertor,
|
ompi_mtl_datatype_unpack(mtl_mx_request->convertor,
|
||||||
mtl_mx_request->mx_segment[0].segment_ptr,
|
mtl_mx_request->mx_segment[0].segment_ptr,
|
||||||
@ -228,24 +215,19 @@ int ompi_mtl_mx_progress( void ) {
|
|||||||
mtl_mx_request->super.ompi_req->req_status.MPI_TAG);
|
mtl_mx_request->super.ompi_req->req_status.MPI_TAG);
|
||||||
mtl_mx_request->super.ompi_req->req_status._count =
|
mtl_mx_request->super.ompi_req->req_status._count =
|
||||||
mx_status.xfer_length;
|
mx_status.xfer_length;
|
||||||
|
}
|
||||||
switch (mx_status.code) {
|
/* suppose everything went just fine ... */
|
||||||
case MX_STATUS_SUCCESS:
|
mtl_mx_request->super.ompi_req->req_status.MPI_ERROR = OMPI_SUCCESS;
|
||||||
mtl_mx_request->super.ompi_req->req_status.MPI_ERROR =
|
if( OPAL_UNLIKELY(MX_STATUS_SUCCESS != mx_status.code) ) {
|
||||||
OMPI_SUCCESS;
|
if( MX_STATUS_TRUNCATED == mx_status.code ) {
|
||||||
break;
|
mtl_mx_request->super.ompi_req->req_status.MPI_ERROR = MPI_ERR_TRUNCATE;
|
||||||
case MX_STATUS_TRUNCATED:
|
} else {
|
||||||
mtl_mx_request->super.ompi_req->req_status.MPI_ERROR =
|
mtl_mx_request->super.ompi_req->req_status.MPI_ERROR = MPI_ERR_INTERN;
|
||||||
MPI_ERR_TRUNCATE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
mtl_mx_request->super.ompi_req->req_status.MPI_ERROR =
|
|
||||||
MPI_ERR_INTERN;
|
|
||||||
}
|
}
|
||||||
mtl_mx_request->super.completion_callback(&mtl_mx_request->super);
|
|
||||||
return completed;
|
return completed;
|
||||||
}
|
}
|
||||||
|
mtl_mx_request->super.completion_callback(&mtl_mx_request->super);
|
||||||
|
return completed;
|
||||||
} else {
|
} else {
|
||||||
return completed;
|
return completed;
|
||||||
}
|
}
|
||||||
|
@ -72,8 +72,6 @@ ompi_mtl_mx_irecv(struct mca_mtl_base_module_t* mtl,
|
|||||||
mask_bits,
|
mask_bits,
|
||||||
mtl_mx_request,
|
mtl_mx_request,
|
||||||
&mtl_mx_request->mx_request);
|
&mtl_mx_request->mx_request);
|
||||||
|
|
||||||
|
|
||||||
if(mx_return != MX_SUCCESS) {
|
if(mx_return != MX_SUCCESS) {
|
||||||
opal_output(ompi_mtl_base_output, "Error in mx_irecv (error %s)\n", mx_strerror(mx_return));
|
opal_output(ompi_mtl_base_output, "Error in mx_irecv (error %s)\n", mx_strerror(mx_return));
|
||||||
return OMPI_ERROR;
|
return OMPI_ERROR;
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ompi_config.h"
|
#include "ompi_config.h"
|
||||||
|
|
||||||
|
#include "opal/prefetch.h"
|
||||||
|
|
||||||
#include "ompi/datatype/datatype.h"
|
#include "ompi/datatype/datatype.h"
|
||||||
#include "ompi/communicator/communicator.h"
|
#include "ompi/communicator/communicator.h"
|
||||||
#include "ompi/datatype/convertor.h"
|
#include "ompi/datatype/convertor.h"
|
||||||
@ -36,34 +39,31 @@ ompi_mtl_mx_send(struct mca_mtl_base_module_t* mtl,
|
|||||||
{
|
{
|
||||||
mx_return_t mx_return;
|
mx_return_t mx_return;
|
||||||
uint64_t match_bits;
|
uint64_t match_bits;
|
||||||
int ret;
|
|
||||||
mca_mtl_mx_request_t mtl_mx_request;
|
mca_mtl_mx_request_t mtl_mx_request;
|
||||||
size_t length;
|
size_t length;
|
||||||
mx_status_t mx_status;
|
mx_status_t mx_status;
|
||||||
uint32_t result;
|
uint32_t result;
|
||||||
ompi_proc_t* ompi_proc = ompi_comm_peer_lookup( comm, dest );
|
ompi_proc_t* ompi_proc = ompi_comm_peer_lookup( comm, dest );
|
||||||
mca_mtl_mx_endpoint_t* mx_endpoint = (mca_mtl_mx_endpoint_t*) ompi_proc->proc_pml;
|
mca_mtl_mx_endpoint_t* mx_endpoint = (mca_mtl_mx_endpoint_t*) ompi_proc->proc_pml;
|
||||||
|
char* where;
|
||||||
|
|
||||||
assert(mtl == &ompi_mtl_mx.super);
|
assert(mtl == &ompi_mtl_mx.super);
|
||||||
|
|
||||||
MX_SET_SEND_BITS(match_bits, comm->c_contextid, comm->c_my_rank, tag);
|
MX_SET_SEND_BITS(match_bits, comm->c_contextid, comm->c_my_rank, tag);
|
||||||
|
|
||||||
ret = ompi_mtl_datatype_pack(convertor,
|
ompi_mtl_datatype_pack(convertor,
|
||||||
&mtl_mx_request.mx_segment[0].segment_ptr,
|
&mtl_mx_request.mx_segment[0].segment_ptr,
|
||||||
&length,
|
&length,
|
||||||
&mtl_mx_request.free_after);
|
&mtl_mx_request.free_after);
|
||||||
|
|
||||||
mtl_mx_request.mx_segment[0].segment_length = length;
|
mtl_mx_request.mx_segment[0].segment_length = length;
|
||||||
mtl_mx_request.convertor = convertor;
|
mtl_mx_request.convertor = convertor;
|
||||||
mtl_mx_request.type = OMPI_MTL_MX_ISEND;
|
mtl_mx_request.type = OMPI_MTL_MX_ISEND;
|
||||||
|
|
||||||
if (OMPI_SUCCESS != ret) return ret;
|
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output,
|
||||||
|
"issend bits: 0x%016llx\n", match_bits));
|
||||||
|
|
||||||
if(mode == MCA_PML_BASE_SEND_SYNCHRONOUS) {
|
if(mode == MCA_PML_BASE_SEND_SYNCHRONOUS) {
|
||||||
|
|
||||||
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output,
|
|
||||||
"issend bits: 0x%016llx\n", match_bits));
|
|
||||||
|
|
||||||
mx_return = mx_issend( ompi_mtl_mx.mx_endpoint,
|
mx_return = mx_issend( ompi_mtl_mx.mx_endpoint,
|
||||||
mtl_mx_request.mx_segment,
|
mtl_mx_request.mx_segment,
|
||||||
1,
|
1,
|
||||||
@ -72,18 +72,8 @@ ompi_mtl_mx_send(struct mca_mtl_base_module_t* mtl,
|
|||||||
&mtl_mx_request,
|
&mtl_mx_request,
|
||||||
&mtl_mx_request.mx_request
|
&mtl_mx_request.mx_request
|
||||||
);
|
);
|
||||||
if(mx_return != MX_SUCCESS ) {
|
where = "mx_issend";
|
||||||
char peer_name[MX_MAX_HOSTNAME_LEN];
|
|
||||||
if(MX_SUCCESS != mx_nic_id_to_hostname( mx_endpoint->mx_peer->nic_id, peer_name)) {
|
|
||||||
sprintf( peer_name, "unknown %lx nic_id", (long)mx_endpoint->mx_peer->nic_id );
|
|
||||||
}
|
|
||||||
opal_output(ompi_mtl_base_output, "Error in mx_issend (error %s) sending to %s\n", mx_strerror(mx_return), peer_name);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output,
|
|
||||||
"isend bits: 0x%016llx\n", match_bits));
|
|
||||||
|
|
||||||
mx_return = mx_isend( ompi_mtl_mx.mx_endpoint,
|
mx_return = mx_isend( ompi_mtl_mx.mx_endpoint,
|
||||||
mtl_mx_request.mx_segment,
|
mtl_mx_request.mx_segment,
|
||||||
1,
|
1,
|
||||||
@ -92,15 +82,16 @@ ompi_mtl_mx_send(struct mca_mtl_base_module_t* mtl,
|
|||||||
&mtl_mx_request,
|
&mtl_mx_request,
|
||||||
&mtl_mx_request.mx_request
|
&mtl_mx_request.mx_request
|
||||||
);
|
);
|
||||||
|
where = "mx_isend";
|
||||||
if(mx_return != MX_SUCCESS ) {
|
}
|
||||||
char peer_name[MX_MAX_HOSTNAME_LEN];
|
if( OPAL_UNLIKELY(mx_return != MX_SUCCESS) ) {
|
||||||
if(MX_SUCCESS != mx_nic_id_to_hostname( mx_endpoint->mx_peer->nic_id, peer_name)) {
|
char peer_name[MX_MAX_HOSTNAME_LEN];
|
||||||
sprintf( peer_name, "unknown %lx nic_id", (long)mx_endpoint->mx_peer->nic_id );
|
if(MX_SUCCESS != mx_nic_id_to_hostname( mx_endpoint->mx_peer->nic_id, peer_name)) {
|
||||||
}
|
sprintf( peer_name, "unknown %lx nic_id", (long)mx_endpoint->mx_peer->nic_id );
|
||||||
opal_output(ompi_mtl_base_output, "Error in mx_isend (error %s) sending to %s\n", mx_strerror(mx_return), peer_name);
|
|
||||||
}
|
}
|
||||||
|
opal_output(ompi_mtl_base_output, "Error in %s (error %s) sending to %s\n",
|
||||||
|
where, mx_strerror(mx_return), peer_name);
|
||||||
|
return OMPI_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -108,11 +99,11 @@ ompi_mtl_mx_send(struct mca_mtl_base_module_t* mtl,
|
|||||||
&mtl_mx_request.mx_request,
|
&mtl_mx_request.mx_request,
|
||||||
&mx_status,
|
&mx_status,
|
||||||
&result);
|
&result);
|
||||||
if(mx_return != MX_SUCCESS) {
|
if( OPAL_UNLIKELY(mx_return != MX_SUCCESS) ) {
|
||||||
opal_output(ompi_mtl_base_output, "Error in mx_wait (error %s)\n", mx_strerror(mx_return));
|
opal_output(ompi_mtl_base_output, "Error in mx_wait (error %s)\n", mx_strerror(mx_return));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if(result && mx_status.code != MX_STATUS_SUCCESS) {
|
if( OPAL_UNLIKELY(result && mx_status.code != MX_STATUS_SUCCESS) ) {
|
||||||
opal_output(ompi_mtl_base_output, "Error in ompi_mtl_mx_send, mx_wait returned something other than MX_STATUS_SUCCESS: mx_status(%d).\n",
|
opal_output(ompi_mtl_base_output, "Error in ompi_mtl_mx_send, mx_wait returned something other than MX_STATUS_SUCCESS: mx_status(%d).\n",
|
||||||
mx_status);
|
mx_status);
|
||||||
abort();
|
abort();
|
||||||
@ -134,31 +125,28 @@ ompi_mtl_mx_isend(struct mca_mtl_base_module_t* mtl,
|
|||||||
{
|
{
|
||||||
mx_return_t mx_return;
|
mx_return_t mx_return;
|
||||||
uint64_t match_bits;
|
uint64_t match_bits;
|
||||||
int ret;
|
|
||||||
mca_mtl_mx_request_t * mtl_mx_request = (mca_mtl_mx_request_t*) mtl_request;
|
mca_mtl_mx_request_t * mtl_mx_request = (mca_mtl_mx_request_t*) mtl_request;
|
||||||
size_t length;
|
size_t length;
|
||||||
ompi_proc_t* ompi_proc = ompi_comm_peer_lookup( comm, dest );
|
ompi_proc_t* ompi_proc = ompi_comm_peer_lookup( comm, dest );
|
||||||
mca_mtl_mx_endpoint_t* mx_endpoint = (mca_mtl_mx_endpoint_t*) ompi_proc->proc_pml;
|
mca_mtl_mx_endpoint_t* mx_endpoint = (mca_mtl_mx_endpoint_t*) ompi_proc->proc_pml;
|
||||||
|
char* where;
|
||||||
|
|
||||||
assert(mtl == &ompi_mtl_mx.super);
|
assert(mtl == &ompi_mtl_mx.super);
|
||||||
|
|
||||||
MX_SET_SEND_BITS(match_bits, comm->c_contextid, comm->c_my_rank, tag);
|
MX_SET_SEND_BITS(match_bits, comm->c_contextid, comm->c_my_rank, tag);
|
||||||
|
|
||||||
ret = ompi_mtl_datatype_pack(convertor,
|
ompi_mtl_datatype_pack(convertor,
|
||||||
&mtl_mx_request->mx_segment[0].segment_ptr,
|
&mtl_mx_request->mx_segment[0].segment_ptr,
|
||||||
&length,
|
&length,
|
||||||
&mtl_mx_request->free_after);
|
&mtl_mx_request->free_after);
|
||||||
mtl_mx_request->mx_segment[0].segment_length = length;
|
mtl_mx_request->mx_segment[0].segment_length = length;
|
||||||
mtl_mx_request->convertor = convertor;
|
mtl_mx_request->convertor = convertor;
|
||||||
mtl_mx_request->type = OMPI_MTL_MX_ISEND;
|
mtl_mx_request->type = OMPI_MTL_MX_ISEND;
|
||||||
|
|
||||||
if (OMPI_SUCCESS != ret) return ret;
|
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output,
|
||||||
|
"issend bits: 0x%016llx\n", match_bits));
|
||||||
|
|
||||||
if(mode == MCA_PML_BASE_SEND_SYNCHRONOUS) {
|
if(mode == MCA_PML_BASE_SEND_SYNCHRONOUS) {
|
||||||
|
|
||||||
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output,
|
|
||||||
"issend bits: 0x%016llx\n", match_bits));
|
|
||||||
|
|
||||||
mx_return = mx_issend( ompi_mtl_mx.mx_endpoint,
|
mx_return = mx_issend( ompi_mtl_mx.mx_endpoint,
|
||||||
mtl_mx_request->mx_segment,
|
mtl_mx_request->mx_segment,
|
||||||
1,
|
1,
|
||||||
@ -167,17 +155,8 @@ ompi_mtl_mx_isend(struct mca_mtl_base_module_t* mtl,
|
|||||||
mtl_mx_request,
|
mtl_mx_request,
|
||||||
&mtl_mx_request->mx_request
|
&mtl_mx_request->mx_request
|
||||||
);
|
);
|
||||||
if(mx_return != MX_SUCCESS ) {
|
where = "mx_issend";
|
||||||
char peer_name[MX_MAX_HOSTNAME_LEN];
|
|
||||||
if(MX_SUCCESS != mx_nic_id_to_hostname( mx_endpoint->mx_peer->nic_id, peer_name)) {
|
|
||||||
sprintf( peer_name, "unknown %lx nic_id", (long)mx_endpoint->mx_peer->nic_id );
|
|
||||||
}
|
|
||||||
opal_output(ompi_mtl_base_output, "Error in mx_issend (error %s) sending to %s\n", mx_strerror(mx_return), peer_name);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
OPAL_OUTPUT_VERBOSE((50, ompi_mtl_base_output,
|
|
||||||
"isend bits: 0x%016llx\n", match_bits));
|
|
||||||
|
|
||||||
mx_return = mx_isend( ompi_mtl_mx.mx_endpoint,
|
mx_return = mx_isend( ompi_mtl_mx.mx_endpoint,
|
||||||
mtl_mx_request->mx_segment,
|
mtl_mx_request->mx_segment,
|
||||||
1,
|
1,
|
||||||
@ -186,16 +165,16 @@ ompi_mtl_mx_isend(struct mca_mtl_base_module_t* mtl,
|
|||||||
mtl_mx_request,
|
mtl_mx_request,
|
||||||
&mtl_mx_request->mx_request
|
&mtl_mx_request->mx_request
|
||||||
);
|
);
|
||||||
|
where = "mx_isend";
|
||||||
if(mx_return != MX_SUCCESS ) {
|
|
||||||
char peer_name[MX_MAX_HOSTNAME_LEN];
|
|
||||||
if(MX_SUCCESS != mx_nic_id_to_hostname( mx_endpoint->mx_peer->nic_id, peer_name)) {
|
|
||||||
sprintf( peer_name, "unknown %lx nic_id", (long)mx_endpoint->mx_peer->nic_id );
|
|
||||||
}
|
|
||||||
opal_output(ompi_mtl_base_output, "Error in mx_isend (error %s) sending to %s\n", mx_strerror(mx_return), peer_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if( OPAL_UNLIKELY(mx_return != MX_SUCCESS) ) {
|
||||||
return mx_return == MX_SUCCESS ? OMPI_SUCCESS : OMPI_ERROR;
|
char peer_name[MX_MAX_HOSTNAME_LEN];
|
||||||
|
if(MX_SUCCESS != mx_nic_id_to_hostname( mx_endpoint->mx_peer->nic_id, peer_name)) {
|
||||||
|
sprintf( peer_name, "unknown %lx nic_id", (long)mx_endpoint->mx_peer->nic_id );
|
||||||
|
}
|
||||||
|
opal_output(ompi_mtl_base_output, "Error in %s (error %s) sending to %s\n",
|
||||||
|
where, mx_strerror(mx_return), peer_name);
|
||||||
|
return OMPI_ERROR;
|
||||||
|
}
|
||||||
|
return OMPI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user