From 0cb2396e3624ad8b605bc94ffb3a87397a38c5ae Mon Sep 17 00:00:00 2001 From: David Eberius Date: Tue, 30 Aug 2016 15:02:47 -0400 Subject: [PATCH 01/12] Added the software events driver code along with several new counters (Note: the progress switch counter is not yet functional). Made the bytes received counters more accurate. The software events code has been moved into the opal/runtime directory. Put all software events functions in macros that become noops when SOFTWARE_EVENTS_ENABLE is not defined. This still needs to be added as an MCA parameter. Made the software counters self-reliant without the PAPI component. Some of the changes have been added directly to MPI_Init and MPI_Finalize. These are temporary until a more robust method is implemented. Added some functions to the software events driver code to allow for registration with the new PAPI sde component. --- ompi/mca/bml/bml.h | 2 + ompi/mca/pml/ob1/pml_ob1.c | 5 + ompi/mca/pml/ob1/pml_ob1_isend.c | 11 + ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 24 ++ ompi/mca/pml/ob1/pml_ob1_recvreq.c | 46 +++ ompi/mca/pml/ob1/pml_ob1_sendreq.c | 161 +++++++++- ompi/mpi/c/allgather.c | 3 + ompi/mpi/c/allreduce.c | 3 + ompi/mpi/c/alltoall.c | 3 + ompi/mpi/c/bcast.c | 12 +- ompi/mpi/c/finalize.c | 60 ++++ ompi/mpi/c/gather.c | 3 + ompi/mpi/c/init.c | 3 + ompi/mpi/c/init_thread.c | 3 + ompi/mpi/c/irecv.c | 5 +- ompi/mpi/c/isend.c | 5 +- ompi/mpi/c/recv.c | 5 +- ompi/mpi/c/reduce.c | 3 + ompi/mpi/c/scatter.c | 3 + ompi/mpi/c/send.c | 5 +- opal/mca/base/mca_base_pvar.h | 2 +- opal/mca/btl/btl.h | 1 + opal/runtime/Makefile.am | 8 +- opal/runtime/ompi_software_events.c | 437 ++++++++++++++++++++++++++++ opal/runtime/ompi_software_events.h | 138 +++++++++ opal/threads/wait_sync.c | 4 +- 26 files changed, 945 insertions(+), 10 deletions(-) create mode 100644 opal/runtime/ompi_software_events.c create mode 100644 opal/runtime/ompi_software_events.h diff --git a/ompi/mca/bml/bml.h b/ompi/mca/bml/bml.h index df731a64a04..d48df9643d6 100644 --- a/ompi/mca/bml/bml.h +++ b/ompi/mca/bml/bml.h @@ -286,6 +286,7 @@ static inline int mca_bml_base_send_status( mca_bml_base_btl_t* bml_btl, mca_btl_base_module_t* btl = bml_btl->btl; des->des_context = (void*) bml_btl; + return btl->btl_send(btl, bml_btl->btl_endpoint, des, tag); } @@ -300,6 +301,7 @@ static inline int mca_bml_base_sendi( mca_bml_base_btl_t* bml_btl, mca_btl_base_descriptor_t** descriptor ) { mca_btl_base_module_t* btl = bml_btl->btl; + return btl->btl_sendi(btl, bml_btl->btl_endpoint, convertor, header, header_size, payload_size, order, flags, tag, descriptor); diff --git a/ompi/mca/pml/ob1/pml_ob1.c b/ompi/mca/pml/ob1/pml_ob1.c index 5adf19028a8..6575c95bb12 100644 --- a/ompi/mca/pml/ob1/pml_ob1.c +++ b/ompi/mca/pml/ob1/pml_ob1.c @@ -36,6 +36,7 @@ #include "opal_stdint.h" #include "opal/mca/btl/btl.h" #include "opal/mca/btl/base/base.h" +#include "opal/runtime/ompi_software_events.h" #include "ompi/mca/pml/pml.h" #include "ompi/mca/pml/base/base.h" @@ -195,6 +196,7 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) mca_pml_ob1_recv_frag_t *frag, *next_frag; mca_pml_ob1_comm_proc_t* pml_proc; mca_pml_ob1_match_hdr_t* hdr; + opal_timer_t usecs = 0; if (NULL == pml_comm) { return OMPI_ERR_OUT_OF_RESOURCE; @@ -264,6 +266,7 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) * situation as the cant_match is only checked when a new fragment is received from * the network. */ + SW_EVENT_TIMER_START(OMPI_OOS_MATCH_TIME, &usecs); if( NULL != pml_proc->frags_cant_match ) { frag = check_cantmatch_for_match(pml_proc); if( NULL != frag ) { @@ -271,6 +274,7 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) goto add_fragment_to_unexpected; } } + SW_EVENT_TIMER_STOP(OMPI_OOS_MATCH_TIME, &usecs); } else { append_frag_to_ordered_list(&pml_proc->frags_cant_match, frag, pml_proc->expected_sequence); @@ -675,6 +679,7 @@ int mca_pml_ob1_send_fin( ompi_proc_t* proc, /* queue request */ rc = mca_bml_base_send( bml_btl, fin, MCA_PML_OB1_HDR_TYPE_FIN ); + if( OPAL_LIKELY( rc >= 0 ) ) { if( OPAL_LIKELY( 1 == rc ) ) { MCA_PML_OB1_PROGRESS_PENDING(bml_btl); diff --git a/ompi/mca/pml/ob1/pml_ob1_isend.c b/ompi/mca/pml/ob1/pml_ob1_isend.c index be673382761..7b188b93108 100644 --- a/ompi/mca/pml/ob1/pml_ob1_isend.c +++ b/ompi/mca/pml/ob1/pml_ob1_isend.c @@ -28,6 +28,7 @@ #include "pml_ob1_sendreq.h" #include "pml_ob1_recvreq.h" #include "ompi/peruse/peruse-internal.h" +#include "opal/runtime/ompi_software_events.h" /** * Single usage request. As we allow recursive calls (as an @@ -119,6 +120,16 @@ static inline int mca_pml_ob1_send_inline (const void *buf, size_t count, rc = mca_bml_base_sendi (bml_btl, &convertor, &match, OMPI_PML_OB1_MATCH_HDR_LEN, size, MCA_BTL_NO_ORDER, MCA_BTL_DES_FLAGS_PRIORITY | MCA_BTL_DES_FLAGS_BTL_OWNERSHIP, MCA_PML_OB1_HDR_TYPE_MATCH, NULL); + + if(rc == OPAL_SUCCESS){ + if(tag >= 0){ + SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, size); + } + else{ + SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, size); + } + } + if (count > 0) { opal_convertor_cleanup (&convertor); } diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index eb261029ffd..47869242521 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -39,6 +39,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/peruse/peruse-internal.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #include "pml_ob1.h" #include "pml_ob1_comm.h" @@ -453,6 +454,14 @@ void mca_pml_ob1_recv_frag_callback_match(mca_btl_base_module_t* btl, &iov_count, &bytes_received ); match->req_bytes_received = bytes_received; + + if(match->req_recv.req_base.req_tag >= 0){ + SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_USER, (long long)(bytes_received)); + } + else{ + SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)(bytes_received)); + } + /* * Unpacking finished, make the user buffer unaccessable again. */ @@ -777,6 +786,9 @@ match_one(mca_btl_base_module_t *btl, mca_pml_ob1_comm_proc_t *proc, mca_pml_ob1_recv_frag_t* frag) { + opal_timer_t usecs = 0; + SW_EVENT_TIMER_START(OMPI_MATCH_TIME, &usecs); + mca_pml_ob1_recv_request_t *match; mca_pml_ob1_comm_t *comm = (mca_pml_ob1_comm_t *)comm_ptr->c_pml_comm; @@ -814,19 +826,31 @@ match_one(mca_btl_base_module_t *btl, num_segments); /* this frag is already processed, so we want to break out of the loop and not end up back on the unexpected queue. */ + SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &usecs); + /*SW_EVENT_RECORD(OMPI_MATCH_TIME, (long long)usecs);*/ + return NULL; } PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_MSG_MATCH_POSTED_REQ, &(match->req_recv.req_base), PERUSE_RECV); + SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &usecs); + /*SW_EVENT_RECORD(OMPI_MATCH_TIME, (long long)usecs);*/ + return match; } /* if no match found, place on unexpected queue */ append_frag_to_list(&proc->unexpected_frags, btl, hdr, segments, num_segments, frag); + + SW_EVENT_RECORD(OMPI_UNEXPECTED, 1); + PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_INSERT_IN_UNEX_Q, comm_ptr, hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); + SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &usecs); + /*SW_EVENT_RECORD(OMPI_MATCH_TIME, (long long)usecs);*/ + return NULL; } while(true); } diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index 9ccb27e1af4..7fb8851dcfd 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -29,6 +29,7 @@ #include "opal/mca/mpool/mpool.h" #include "opal/util/arch.h" +#include "opal/runtime/ompi_software_events.h" #include "ompi/mca/pml/pml.h" #include "ompi/mca/bml/bml.h" #include "pml_ob1_comm.h" @@ -242,6 +243,7 @@ int mca_pml_ob1_recv_request_ack_send_btl( des->des_cbfunc = mca_pml_ob1_recv_ctl_completion; rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_ACK); + if( OPAL_LIKELY( rc >= 0 ) ) { return OMPI_SUCCESS; } @@ -429,6 +431,30 @@ static int mca_pml_ob1_recv_request_put_frag (mca_pml_ob1_rdma_frag_t *frag) /* send rdma request to peer */ rc = mca_bml_base_send (bml_btl, ctl, MCA_PML_OB1_HDR_TYPE_PUT); + +#ifdef SOFTWARE_EVENTS_ENABLE + volatile int64_t bytes_sent; + unsigned int i; + if(attached_event[OMPI_BYTES_SENT_USER] == 1){ + if(recvreq->req_recv.req_base.req_tag >= 0){ + bytes_sent = 0; + for(i = 0; i < ctl->des_segment_count; i++){ + bytes_sent += ctl->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); + } + } + if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ + if(recvreq->req_recv.req_base.req_tag < 0){ + bytes_sent = 0; + for(i = 0; i < ctl->des_segment_count; i++){ + bytes_sent += ctl->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); + } + } +#endif + if (OPAL_UNLIKELY(rc < 0)) { mca_bml_base_free (bml_btl, ctl); return rc; @@ -470,6 +496,10 @@ int mca_pml_ob1_recv_request_get_frag (mca_pml_ob1_rdma_frag_t *frag) rc = mca_bml_base_get (bml_btl, frag->local_address, frag->remote_address, local_handle, (mca_btl_base_registration_handle_t *) frag->remote_handle, frag->rdma_length, 0, MCA_BTL_NO_ORDER, mca_pml_ob1_rget_completion, frag); + + /* Increment counter for bytes_get even though they probably haven't all been received yet */ + SW_EVENT_RECORD(OMPI_BYTES_GET, frag->rdma_length); + if( OPAL_UNLIKELY(OMPI_SUCCESS > rc) ) { return mca_pml_ob1_recv_request_get_frag_failed (frag, OMPI_ERR_OUT_OF_RESOURCE); } @@ -525,6 +555,14 @@ void mca_pml_ob1_recv_request_progress_frag( mca_pml_ob1_recv_request_t* recvreq ); OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); + + if(recvreq->req_recv.req_base.req_tag >= 0){ + SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_USER, (long long)bytes_received); + } + else{ + SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)bytes_received); + } + /* check completion status */ if(recv_request_pml_complete_check(recvreq) == false && recvreq->req_rdma_offset < recvreq->req_send_offset) { @@ -886,6 +924,14 @@ void mca_pml_ob1_recv_request_progress_match( mca_pml_ob1_recv_request_t* recvre * for this request. */ recvreq->req_bytes_received += bytes_received; + + if(recvreq->req_recv.req_base.req_tag >= 0){ + SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_USER, (long long)bytes_received); + } + else{ + SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)bytes_received); + } + recv_request_pml_complete(recvreq); } diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index a2aecae09ac..6b30bf6a5f0 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -29,6 +29,7 @@ #include "ompi_config.h" #include "opal/prefetch.h" #include "opal/mca/mpool/mpool.h" +#include "opal/runtime/ompi_software_events.h" #include "ompi/constants.h" #include "ompi/mca/pml/pml.h" #include "pml_ob1.h" @@ -39,7 +40,6 @@ #include "ompi/mca/bml/base/base.h" #include "ompi/memchecker.h" - OBJ_CLASS_INSTANCE(mca_pml_ob1_send_range_t, opal_free_list_item_t, NULL, NULL); @@ -350,6 +350,7 @@ mca_pml_ob1_copy_frag_completion( mca_btl_base_module_t* btl, * we just abort. In theory, a new queue could be created to hold this * fragment and then attempt to send it out on another BTL. */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_FRAG); + if(OPAL_UNLIKELY(rc < 0)) { opal_output(0, "%s:%d FATAL", __FILE__, __LINE__); ompi_rte_abort(-1, NULL); @@ -449,6 +450,30 @@ int mca_pml_ob1_send_request_start_buffered( /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RNDV); + +#ifdef SOFTWARE_EVENTS_ENABLE + volatile int64_t bytes_sent; + unsigned int i; + if(attached_event[OMPI_BYTES_SENT_USER] == 1){ + if(sendreq->req_send.req_base.req_tag >= 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); + } + } + if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ + if(sendreq->req_send.req_base.req_tag < 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); + } + } +#endif + if( OPAL_LIKELY( rc >= 0 ) ) { if( OPAL_LIKELY( 1 == rc ) ) { mca_pml_ob1_rndv_completion_request( bml_btl, sendreq, req_bytes_delivered); @@ -495,6 +520,16 @@ int mca_pml_ob1_send_request_start_copy( mca_pml_ob1_send_request_t* sendreq, MCA_BTL_DES_FLAGS_PRIORITY | MCA_BTL_DES_FLAGS_BTL_OWNERSHIP, MCA_PML_OB1_HDR_TYPE_MATCH, &des); + + if(rc == OPAL_SUCCESS){ + if(sendreq->req_send.req_base.req_tag >= 0){ + SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, size); + } + else{ + SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, size); + } + } + if( OPAL_LIKELY(OMPI_SUCCESS == rc) ) { /* signal request completion */ send_request_pml_complete(sendreq); @@ -567,6 +602,30 @@ int mca_pml_ob1_send_request_start_copy( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send_status(bml_btl, des, MCA_PML_OB1_HDR_TYPE_MATCH); + +#ifdef SOFTWARE_EVENTS_ENABLE + volatile int64_t bytes_sent; + unsigned int i; + if(attached_event[OMPI_BYTES_SENT_USER] == 1){ + if(sendreq->req_send.req_base.req_tag >= 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent - OMPI_PML_OB1_MATCH_HDR_LEN); + } + } + if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ + if(sendreq->req_send.req_base.req_tag < 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent - OMPI_PML_OB1_MATCH_HDR_LEN); + } + } +#endif + if( OPAL_LIKELY( rc >= OPAL_SUCCESS ) ) { if( OPAL_LIKELY( 1 == rc ) ) { mca_pml_ob1_match_completion_free_request( bml_btl, sendreq ); @@ -627,6 +686,30 @@ int mca_pml_ob1_send_request_start_prepare( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_MATCH); + +#ifdef SOFTWARE_EVENTS_ENABLE + volatile int64_t bytes_sent; + unsigned int i; + if(attached_event[OMPI_BYTES_SENT_USER] == 1){ + if(sendreq->req_send.req_base.req_tag >= 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); + } + } + if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ + if(sendreq->req_send.req_base.req_tag < 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); + } + } +#endif + if( OPAL_LIKELY( rc >= OPAL_SUCCESS ) ) { if( OPAL_LIKELY( 1 == rc ) ) { mca_pml_ob1_match_completion_free_request( bml_btl, sendreq ); @@ -731,6 +814,30 @@ int mca_pml_ob1_send_request_start_rdma( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RGET); + +#ifdef SOFTWARE_EVENTS_ENABLE + volatile int64_t bytes_sent; + unsigned int i; + if(attached_event[OMPI_BYTES_SENT_USER] == 1){ + if(sendreq->req_send.req_base.req_tag >= 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); + } + } + if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ + if(sendreq->req_send.req_base.req_tag < 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); + } + } +#endif + if (OPAL_UNLIKELY(rc < 0)) { mca_bml_base_free(bml_btl, des); return rc; @@ -811,6 +918,30 @@ int mca_pml_ob1_send_request_start_rndv( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RNDV); + +#ifdef SOFTWARE_EVENTS_ENABLE + volatile int64_t bytes_sent; + unsigned int i; + if(attached_event[OMPI_BYTES_SENT_USER] == 1){ + if(sendreq->req_send.req_base.req_tag >= 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); + } + } + if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ + if(sendreq->req_send.req_base.req_tag < 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); + } + } +#endif + if( OPAL_LIKELY( rc >= 0 ) ) { if( OPAL_LIKELY( 1 == rc ) ) { mca_pml_ob1_rndv_completion_request( bml_btl, sendreq, size ); @@ -1055,6 +1186,30 @@ mca_pml_ob1_send_request_schedule_once(mca_pml_ob1_send_request_t* sendreq) /* initiate send - note that this may complete before the call returns */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_FRAG); + +#ifdef SOFTWARE_EVENTS_ENABLE + volatile int64_t bytes_sent; + unsigned int i; + if(attached_event[OMPI_BYTES_SENT_USER] == 1){ + if(sendreq->req_send.req_base.req_tag >= 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); + } + } + if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ + if(sendreq->req_send.req_base.req_tag < 0){ + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); + } + } +#endif + if( OPAL_LIKELY(rc >= 0) ) { /* update state */ range->range_btls[btl_idx].length -= size; @@ -1177,6 +1332,10 @@ int mca_pml_ob1_send_request_put_frag( mca_pml_ob1_rdma_frag_t *frag ) rc = mca_bml_base_put (bml_btl, frag->local_address, frag->remote_address, local_handle, (mca_btl_base_registration_handle_t *) frag->remote_handle, frag->rdma_length, 0, MCA_BTL_NO_ORDER, mca_pml_ob1_put_completion, frag); + + /* Count the bytes put even though they probably haven't been sent yet */ + SW_EVENT_RECORD(OMPI_BYTES_PUT, frag->rdma_length); + if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) { mca_pml_ob1_send_request_put_frag_failed (frag, rc); return rc; diff --git a/ompi/mpi/c/allgather.c b/ompi/mpi/c/allgather.c index 41df7adf386..5a05e2685df 100644 --- a/ompi/mpi/c/allgather.c +++ b/ompi/mpi/c/allgather.c @@ -32,6 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int err; + SW_EVENT_RECORD(OMPI_ALLGATHER, 1); + MEMCHECKER( int rank; ptrdiff_t ext; diff --git a/ompi/mpi/c/allreduce.c b/ompi/mpi/c/allreduce.c index edfb7020c00..c38293667ff 100644 --- a/ompi/mpi/c/allreduce.c +++ b/ompi/mpi/c/allreduce.c @@ -31,6 +31,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -47,6 +48,8 @@ int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, { int err; + SW_EVENT_RECORD(OMPI_ALLREDUCE, 1); + MEMCHECKER( memchecker_datatype(datatype); memchecker_comm(comm); diff --git a/ompi/mpi/c/alltoall.c b/ompi/mpi/c/alltoall.c index c31bb724205..471b38e00e5 100644 --- a/ompi/mpi/c/alltoall.c +++ b/ompi/mpi/c/alltoall.c @@ -33,6 +33,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -51,6 +52,8 @@ int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int err; size_t recvtype_size; + SW_EVENT_RECORD(OMPI_ALLTOALL, 1); + MEMCHECKER( memchecker_comm(comm); if (MPI_IN_PLACE != sendbuf) { diff --git a/ompi/mpi/c/bcast.c b/ompi/mpi/c/bcast.c index 6715aff90de..7f4de50e561 100644 --- a/ompi/mpi/c/bcast.c +++ b/ompi/mpi/c/bcast.c @@ -26,6 +26,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -36,12 +37,13 @@ static const char FUNC_NAME[] = "MPI_Bcast"; - int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) { int err; + SW_EVENT_RECORD(OMPI_BCAST, 1); + MEMCHECKER( memchecker_datatype(datatype); memchecker_comm(comm); @@ -110,5 +112,13 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, err = comm->c_coll->coll_bcast(buffer, count, datatype, root, comm, comm->c_coll->coll_bcast_module); + + if(ompi_comm_rank(comm) == root){ + SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, count * sizeof(datatype) * ((int)ompi_comm_size(comm)-1)); + } + else{ + SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, count * sizeof(datatype)); + } + OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME); } diff --git a/ompi/mpi/c/finalize.c b/ompi/mpi/c/finalize.c index b640c6cec11..22ef9004c78 100644 --- a/ompi/mpi/c/finalize.c +++ b/ompi/mpi/c/finalize.c @@ -23,6 +23,7 @@ #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/params.h" #include "ompi/errhandler/errhandler.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -36,6 +37,65 @@ static const char FUNC_NAME[] = "MPI_Finalize"; int MPI_Finalize(void) { +#ifdef SOFTWARE_EVENTS_ENABLE + int i, j, rank, world_size, offset; + long long *recv_buffer, *send_buffer; + char *filename; + FILE *fptr; + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &world_size); + + if(rank == 0){ + send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); + recv_buffer = (long long*)malloc(world_size * OMPI_NUM_COUNTERS * sizeof(long long)); + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + send_buffer[i] = events[i].value; + } + MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); + } + else{ + send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + send_buffer[i] = events[i].value; + } + MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); + } + + if(rank == 0){ + asprintf(&filename, "sw_events_output_XXXXXX"); + filename = mktemp(filename); + fptr = fopen(filename, "w+"); + + fprintf(fptr, "%d %d\n", world_size, OMPI_NUM_COUNTERS); + + fprintf(stdout, "OMPI Software Counters:\n"); + offset = 0; + for(j = 0; j < world_size; j++){ + fprintf(stdout, "World Rank %d:\n", j); + fprintf(fptr, "%d\n", j); + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + fprintf(stdout, "%s -> %lld\n", events[i].name, recv_buffer[offset+i]); + fprintf(fptr, "%s %lld\n", events[i].name, recv_buffer[offset+i]); + } + fprintf(stdout, "\n"); + offset += OMPI_NUM_COUNTERS; + } + free(recv_buffer); + free(send_buffer); + fclose(fptr); + } + else{ + free(send_buffer); + } + + MPI_Barrier(MPI_COMM_WORLD); + + /*SW_EVENT_PRINT_ALL();*/ + + /*SW_EVENT_FINI();*/ +#endif + OPAL_CR_FINALIZE_LIBRARY(); if (MPI_PARAM_CHECK) { diff --git a/ompi/mpi/c/gather.c b/ompi/mpi/c/gather.c index 03a7bf63860..1890d13cbf8 100644 --- a/ompi/mpi/c/gather.c +++ b/ompi/mpi/c/gather.c @@ -32,6 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int err; + SW_EVENT_RECORD(OMPI_GATHER, 1); + MEMCHECKER( int rank; ptrdiff_t ext; diff --git a/ompi/mpi/c/init.c b/ompi/mpi/c/init.c index d316fb743d2..31c21b74961 100644 --- a/ompi/mpi/c/init.c +++ b/ompi/mpi/c/init.c @@ -25,6 +25,7 @@ #include #include "opal/util/show_help.h" +#include "opal/runtime/ompi_software_events.h" #include "ompi/mpi/c/bindings.h" #include "ompi/communicator/communicator.h" #include "ompi/errhandler/errhandler.h" @@ -47,6 +48,8 @@ int MPI_Init(int *argc, char ***argv) char *env; int required = MPI_THREAD_SINGLE; + SW_EVENT_INIT(); + /* check for environment overrides for required thread level. If there is, check to see that it is a valid/supported thread level. If not, default to MPI_THREAD_MULTIPLE. */ diff --git a/ompi/mpi/c/init_thread.c b/ompi/mpi/c/init_thread.c index 38c6d7b7a81..fba9d6371d0 100644 --- a/ompi/mpi/c/init_thread.c +++ b/ompi/mpi/c/init_thread.c @@ -26,6 +26,7 @@ #include "ompi_config.h" #include "opal/util/show_help.h" +#include "opal/runtime/ompi_software_events.h" #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/params.h" #include "ompi/communicator/communicator.h" @@ -48,6 +49,8 @@ int MPI_Init_thread(int *argc, char ***argv, int required, { int err; + SW_EVENT_INIT(); + ompi_hook_base_mpi_init_thread_top(argc, argv, required, provided); if ( MPI_PARAM_CHECK ) { diff --git a/ompi/mpi/c/irecv.c b/ompi/mpi/c/irecv.c index 3e66e365eb1..42f0236bb9e 100644 --- a/ompi/mpi/c/irecv.c +++ b/ompi/mpi/c/irecv.c @@ -27,6 +27,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -37,12 +38,13 @@ static const char FUNC_NAME[] = "MPI_Irecv"; - int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source, int tag, MPI_Comm comm, MPI_Request *request) { int rc = MPI_SUCCESS; + SW_EVENT_RECORD(OMPI_IRECV, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_comm(comm); @@ -78,5 +80,6 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source, memchecker_call(&opal_memchecker_base_mem_noaccess, buf, count, type); ); rc = MCA_PML_CALL(irecv(buf,count,type,source,tag,comm,request)); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/isend.c b/ompi/mpi/c/isend.c index 5e56deed67e..18ce9b241ab 100644 --- a/ompi/mpi/c/isend.c +++ b/ompi/mpi/c/isend.c @@ -31,6 +31,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -41,12 +42,13 @@ static const char FUNC_NAME[] = "MPI_Isend"; - int MPI_Isend(const void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm, MPI_Request *request) { int rc = MPI_SUCCESS; + SW_EVENT_RECORD(OMPI_ISEND, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_call(&opal_memchecker_base_isdefined, buf, count, type); @@ -91,6 +93,7 @@ int MPI_Isend(const void *buf, int count, MPI_Datatype type, int dest, rc = MCA_PML_CALL(isend(buf, count, type, dest, tag, MCA_PML_BASE_SEND_STANDARD, comm, request)); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/recv.c b/ompi/mpi/c/recv.c index 864fdd2cdbb..2c036f8b634 100644 --- a/ompi/mpi/c/recv.c +++ b/ompi/mpi/c/recv.c @@ -27,6 +27,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/memchecker.h" #include "ompi/request/request.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -37,12 +38,13 @@ static const char FUNC_NAME[] = "MPI_Recv"; - int MPI_Recv(void *buf, int count, MPI_Datatype type, int source, int tag, MPI_Comm comm, MPI_Status *status) { int rc = MPI_SUCCESS; + SW_EVENT_RECORD(OMPI_RECV, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_call(&opal_memchecker_base_isaddressable, buf, count, type); @@ -77,5 +79,6 @@ int MPI_Recv(void *buf, int count, MPI_Datatype type, int source, OPAL_CR_ENTER_LIBRARY(); rc = MCA_PML_CALL(recv(buf, count, type, source, tag, comm, status)); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/reduce.c b/ompi/mpi/c/reduce.c index 92cb8024d75..e9603a8dadf 100644 --- a/ompi/mpi/c/reduce.c +++ b/ompi/mpi/c/reduce.c @@ -31,6 +31,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -47,6 +48,8 @@ int MPI_Reduce(const void *sendbuf, void *recvbuf, int count, { int err; + SW_EVENT_RECORD(OMPI_REDUCE, 1); + MEMCHECKER( memchecker_datatype(datatype); memchecker_comm(comm); diff --git a/ompi/mpi/c/scatter.c b/ompi/mpi/c/scatter.c index 91cbf30c3dd..44a318646e4 100644 --- a/ompi/mpi/c/scatter.c +++ b/ompi/mpi/c/scatter.c @@ -32,6 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int err; + SW_EVENT_RECORD(OMPI_SCATTER, 1); + MEMCHECKER( memchecker_comm(comm); if(OMPI_COMM_IS_INTRA(comm)) { diff --git a/ompi/mpi/c/send.c b/ompi/mpi/c/send.c index d5b859aede4..7b73647dec5 100644 --- a/ompi/mpi/c/send.c +++ b/ompi/mpi/c/send.c @@ -30,6 +30,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "opal/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -40,12 +41,13 @@ static const char FUNC_NAME[] = "MPI_Send"; - int MPI_Send(const void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm) { int rc = MPI_SUCCESS; + SW_EVENT_RECORD(OMPI_SEND, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_call(&opal_memchecker_base_isdefined, buf, count, type); @@ -76,5 +78,6 @@ int MPI_Send(const void *buf, int count, MPI_Datatype type, int dest, OPAL_CR_ENTER_LIBRARY(); rc = MCA_PML_CALL(send(buf, count, type, dest, tag, MCA_PML_BASE_SEND_STANDARD, comm)); + OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/opal/mca/base/mca_base_pvar.h b/opal/mca/base/mca_base_pvar.h index 44f23b3dfc1..e305cbcbfd6 100644 --- a/opal/mca/base/mca_base_pvar.h +++ b/opal/mca/base/mca_base_pvar.h @@ -319,7 +319,7 @@ OPAL_DECLSPEC int mca_base_pvar_register (const char *project, const char *frame * associated with a component. * * While quite similar to mca_base_pvar_register(), there is one key - * difference: pvars registered this this function will automatically + * difference: pvars registered with this function will automatically * be unregistered / made unavailable when that component is closed by * its framework. */ diff --git a/opal/mca/btl/btl.h b/opal/mca/btl/btl.h index 5f0e73b30c7..2c4a972f6dc 100644 --- a/opal/mca/btl/btl.h +++ b/opal/mca/btl/btl.h @@ -450,6 +450,7 @@ typedef struct mca_btl_base_segment_t mca_btl_base_segment_t; * des_segments */ + struct mca_btl_base_descriptor_t { opal_free_list_item_t super; mca_btl_base_segment_t *des_segments; /**< local segments */ diff --git a/opal/runtime/Makefile.am b/opal/runtime/Makefile.am index fab8ead6104..6ecb583e64f 100644 --- a/opal/runtime/Makefile.am +++ b/opal/runtime/Makefile.am @@ -36,7 +36,9 @@ headers += \ runtime/opal_cr.h \ runtime/opal_info_support.h \ runtime/opal_params.h \ - runtime/opal_progress_threads.h + runtime/opal_progress_threads.h \ + runtime/ompi_software_events.h \ + runtime/papi_sde_interface.h lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \ runtime/opal_progress.c \ @@ -45,4 +47,6 @@ lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \ runtime/opal_params.c \ runtime/opal_cr.c \ runtime/opal_info_support.c \ - runtime/opal_progress_threads.c + runtime/opal_progress_threads.c \ + runtime/ompi_software_events.c \ + runtime/papi_sde_interface.c diff --git a/opal/runtime/ompi_software_events.c b/opal/runtime/ompi_software_events.c new file mode 100644 index 00000000000..6289f9e21e7 --- /dev/null +++ b/opal/runtime/ompi_software_events.c @@ -0,0 +1,437 @@ +#include "ompi_software_events.h" + +OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { + "OMPI_SEND", + "OMPI_RECV", + "OMPI_ISEND", + "OMPI_IRECV", + "OMPI_BCAST", + "OMPI_REDUCE", + "OMPI_ALLREDUCE", + "OMPI_SCATTER", + "OMPI_GATHER", + "OMPI_ALLTOALL", + "OMPI_ALLGATHER", + "OMPI_BYTES_RECEIVED_USER", + "OMPI_BYTES_RECEIVED_MPI", + "OMPI_BYTES_SENT_USER", + "OMPI_BYTES_SENT_MPI", + "OMPI_BYTES_PUT", + "OMPI_BYTES_GET", + "OMPI_UNEXPECTED", + "OMPI_OUT_OF_SEQUENCE", + "OMPI_MATCH_TIME", + "OMPI_OOS_MATCH_TIME", + "OMPI_PROGRESS_SWITCH" +}; + +OMPI_DECLSPEC const char *counter_descriptions[OMPI_NUM_COUNTERS] = { + "The number of times MPI_Send was called.", + "The number of times MPI_Recv was called.", + "The number of times MPI_Isend was called.", + "The number of times MPI_Irecv was called.", + "The number of times MPI_Bcast was called.", + "The number of times MPI_Reduce was called.", + "The number of times MPI_Allreduce was called.", + "The number of times MPI_Scatter was called.", + "The number of times MPI_Gather was called.", + "The number of times MPI_Alltoall was called.", + "The number of times MPI_Allgather was called.", + "The number of bytes received by the user through point-to-point communications. Note: Excludes RDMA operations.", + "The number of bytes received by MPI through collective, control, or other internal communications.", + "The number of bytes sent by the user through point-to-point communications. Note: Excludes RDMA operations.", + "The number of bytes sent by MPI through collective, control, or other internal communications.", + "The number of bytes sent/received using RDMA Put operations.", + "The number of bytes sent/received using RDMA Get operations.", + "The number of messages that arrived as unexpected messages.", + "The number of messages that arrived out of the proper sequence.", + "The number of microseconds spent matching unexpected messages.", + "The number of microseconds spent matching out of sequence messages.", + "The number of times the progress thread changed." +}; + +/* An array of integer values to denote whether an event is activated (1) or not (0) */ +OMPI_DECLSPEC unsigned int attached_event[OMPI_NUM_COUNTERS] = { 0 }; +/* An array of event structures to store the event data (name and value) */ +OMPI_DECLSPEC ompi_event_t *events = NULL; + +/* ############################################################## + * ################# Begin MPI_T Functions ###################### + * ############################################################## + */ + +static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count) +{ + (void)obj_handle; + if(MCA_BASE_PVAR_HANDLE_BIND == event) + *count = 1; + + return OPAL_SUCCESS; +} + +inline long long ompi_sw_event_get_counter(int counter_id) +{ + if(events != NULL) + return events[counter_id].value; + else + return 0; /* -1 would be preferred to indicate lack of initialization, but the type needs to be unsigned */ +} + +static int ompi_sw_event_get_send(const struct mca_base_pvar_t *pvar, void *value, void *obj_handle) +{ + (void) obj_handle; + long long *counter_value = (long long*)value; + *counter_value = ompi_sw_event_get_counter(OMPI_SEND); + + return OPAL_SUCCESS; +} + +/* ############################################################## + * ############ Begin PAPI software_events Code ################# + * ############################################################## + */ + +/* Allocates and initializes the events data structure */ +int iter_start() +{ + int i; + + if(events == NULL){ + events = (ompi_event_t*)malloc(OMPI_NUM_COUNTERS * sizeof(ompi_event_t)); + } + else{ + fprintf(stderr, "The events data structure has already been allocated.\n"); + } + + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + events[i].name = counter_names[i]; + events[i].value = 0; + } + return 0; +} + +/* Returns the name of the next event in the data structure */ +char* iter_next() +{ + static int i = 0; + + if(i < OMPI_NUM_COUNTERS){ + i++; + return events[i-1].name; + } + else{ + /* Finished iterating through the list. Return NULL and reset i */ + i = 0; + return NULL; + } +} + +/* Frees the events data structure */ +int iter_release() +{ + free(events); + return 0; +} + +/* If an event named 'event_name' exists, attach the corresponding event's value + * to the supplied long long pointer. + */ +int attach_event(char *event_name, long long **value) +{ + int i; + + if(events == NULL){ + fprintf(stderr, "Error: The iterator hasn't been started. The event cannot be attached.\n"); + return -1; + } + + if(event_name == NULL){ + fprintf(stderr, "Error: No event name specified for attach_event.\n"); + return -1; + } + + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + if(strcmp(event_name, events[i].name) == 0){ + break; + } + } + + if(i < OMPI_NUM_COUNTERS){ + *value = &events[i].value; + attached_event[i] = 1; + + return 0; + } + else{ + fprintf(stderr, "Error: Could not find an event by that name. The event cannot be attached.\n"); + return -1; + } +} + +/* If an event with the name 'event_name' exists, reset its value to 0 + * and set the corresponding value in attached_event to 0. + */ +int detach_event(char *event_name) +{ + int i; + + if(events == NULL){ + fprintf(stderr, "Error: The iterator hasn't been started. The event cannot be detached.\n"); + return -1; + } + + if(event_name == NULL){ + fprintf(stderr, "Error: No event name specified for detach_event.\n"); + return -1; + } + + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + if(strcmp(event_name, events[i].name) == 0){ + break; + } + } + + if(i < OMPI_NUM_COUNTERS){ + attached_event[i] = 0; + events[i].value = 0; + + return 0; + } + else{ + fprintf(stderr, "Error: Could not find an event by that name. The event cannot be detached.\n"); + return -1; + } +} + +/* A structure to expose to the PAPI software_events component to use these events */ +struct PAPI_SOFTWARE_EVENT_S papi_software_events = {"ompi", {0, 0, 0}, iter_start, iter_next, iter_release, attach_event, detach_event}; + +/* ############################################################## + * ############ End of PAPI software_events Code ################ + * ############################################################## + */ + +/* ############################################################## + * ############### Begin PAPI sde Code ########################## + * ############################################################## + */ + +/* An initialization function for the PAPI sde component. + * This creates an sde handle with the name OMPI and registers all events and + * event descriptions with the sde component. + */ +void ompi_sde_init() { + int i, event_count = OMPI_NUM_COUNTERS; + void *sde_handle = (void *)papi_sde_init("OMPI", &event_count); + + /* Required registration of counters and optional counter descriptions */ + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + printf("Registering: %s (%d of %d)\n", counter_names[i], i, OMPI_NUM_COUNTERS); + papi_sde_register_counter(sde_handle, counter_names[i], &(events[i].value) ); + papi_sde_describe_counter(sde_handle, counter_names[i], counter_descriptions[i]); + } +} + +/* Define PAPI_DYNAMIC_SDE since we are assuming PAPI is linked dynamically. + * Note: In the future we should support both dynamic and static linking of PAPI. + */ +#define PAPI_DYNAMIC_SDE +/* This function will be called from papi_native_avail to list all of the OMPI + * events with their names and descriptions. In order for the dynamic version + * to work, the environment variable PAPI_SHARED_LIB must contain the full path + * to the PAPI shared library like the following: + * /path/to/papi/install/lib/libpapi.so + * + * This function will use dlsym to get the appropriate functions for initializing + * the PAPI sde component's environment and register all of the events. + */ +void* papi_sde_hook_list_events(void) +{ + int i, event_count = OMPI_NUM_COUNTERS; + char *error; + void *papi_handle; + void* (*sym_init)(char *name_of_library, int *event_count); + void (*sym_reg)( void *handle, char *event_name, long long *counter); + void (*sym_desc)(void *handle, char *event_name, char *event_description); + void *sde_handle = NULL; + + printf("papi_sde_hook_list_events\n"); + +#ifdef PAPI_DYNAMIC_SDE + printf("PAPI_DYNAMIC_SDE defined\n"); + fflush(stdout); + + char *path_to_papi = getenv("PAPI_SHARED_LIB"); + if(path_to_papi == NULL) + return NULL; + + printf("path_to_papi = %s\n", path_to_papi); + + papi_handle = dlopen(path_to_papi, RTLD_LOCAL | RTLD_LAZY); + if(!papi_handle){ + fputs(dlerror(), stderr); + exit(1); + } + printf("papi_handle opened\n"); + fflush(stdout); + + dlerror(); + sym_init = (void* (*)(char*, int*)) dlsym(papi_handle, "papi_sde_init"); + if((error = dlerror()) != NULL) { + fputs(error, stderr); + exit(1); + } + + sym_reg = (void (*)(void*, char*, long long int*)) dlsym(papi_handle, "papi_sde_register_counter"); + if((error = dlerror()) != NULL){ + fputs(error, stderr); + exit(1); + } + + sym_desc = (void (*)(void*, char*, char*)) dlsym(papi_handle, "papi_sde_describe_counter"); + if((error = dlerror()) != NULL){ + fputs(error, stderr); + exit(1); + } + + printf("symbols found\n"); + fflush(stdout); + + sde_handle = (void *) (*sym_init)("OMPI", &event_count); + printf("sde_handle opened\n"); + fflush(stdout); + if((error = dlerror()) != NULL){ + fputs(error, stderr); + exit(1); + } + + printf("sde_handle preparing to register\n"); + fflush(stdout); + + /* We need to register the counters so they can be printed in papi_native_avail + * Note: sde::: will be prepended to the names + */ + iter_start(); + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + printf("Registering: %s (%d of %d)\n", counter_names[i], i+1, OMPI_NUM_COUNTERS); + (*sym_reg)(sde_handle, counter_names[i], &(events[i].value)); + (*sym_desc)(sde_handle, counter_names[i], counter_descriptions[i]); + events[i].value = 0; + } +#endif + + printf("done papi_sde_hook_list_events %s %d\n", __FILE__, __LINE__); + return sde_handle; +} + +/* ############################################################## + * ############### End of PAPI sde Code ######################### + * ############################################################## + */ + +/* ############################################################## + * ############### Begin Utility Functions ###################### + * ############################################################## + */ + +/* Initializes the OMPI software events. The default functionality is to + * turn all of the counters on. + * Note: in the future, turning events on and off should be done through + * an MCA parameter. + */ +void ompi_sw_event_init() +{ + int i; + + iter_start(); + + /* Turn all counters on */ + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + attached_event[i] = 1; + } + + (void)mca_base_pvar_register("ompi", "opal", "software_events", counter_names[OMPI_SEND], counter_descriptions[OMPI_SEND], + OPAL_INFO_LVL_4, MPI_T_PVAR_CLASS_SIZE, + MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, NULL, MPI_T_BIND_NO_OBJECT, + MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS, + ompi_sw_event_get_send, NULL, ompi_sw_event_notify, NULL); + + /* For initializing the PAPI sde component environment */ + ompi_sde_init(); +} + +/* Calls iter_release to free all of the OMPI software events data structures */ +void ompi_sw_event_fini() +{ + iter_release(); +} + +/* Records an update to a counter using an atomic add operation. */ +void ompi_sw_event_record(unsigned int event_id, long long value) +{ + if(OPAL_UNLIKELY(attached_event[event_id] == 1)){ + OPAL_THREAD_ADD64(&events[event_id].value, value); + } +} + +/* Starts microsecond-precision timer and stores the start value in usec */ +void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *usec) +{ + /* Check whether usec == 0.0 to make sure the timer hasn't started yet */ + if(OPAL_UNLIKELY(attached_event[event_id] == 1 && *usec == 0)){ + *usec = opal_timer_base_get_usec(); + } +} + +/* Stops a microsecond-precision timer and calculates the total elapsed time + * based on the starting time in usec and putting the result in usec. + */ +void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *usec) +{ + if(OPAL_UNLIKELY(attached_event[event_id] == 1)){ + *usec = opal_timer_base_get_usec() - *usec; + OPAL_THREAD_ADD64(&events[event_id].value, (long long)*usec); + } +} + +/* A function to output the value of all of the counters. This is currently + * implemented in MPI_Finalize, but we need to find a better way for this to + * happen. + */ +void ompi_sw_event_print_all() +{ + /*int i, j, rank, world_size, offset; + long long *recv_buffer, *send_buffer; + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &world_size); + + if(rank == 0){ + send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); + recv_buffer = (long long*)malloc(world_size * OMPI_NUM_COUNTERS * sizeof(long long)); + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + send_buffer[i] = events[i].value; + } + MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); + } + else{ + send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + send_buffer[i] = events[i].value; + } + MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); + } + + if(rank == 0){ + fprintf(stdout, "OMPI Software Counters:\n"); + offset = 0; + for(j = 0; j < world_size; j++){ + fprintf(stdout, "World Rank %d:\n", j); + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + fprintf(stdout, "%s\t%lld\n", counter_names[offset+i], events[offset+i].value); + } + offset += OMPI_NUM_COUNTERS; + } + }*/ +} + diff --git a/opal/runtime/ompi_software_events.h b/opal/runtime/ompi_software_events.h new file mode 100644 index 00000000000..551b65de2d3 --- /dev/null +++ b/opal/runtime/ompi_software_events.h @@ -0,0 +1,138 @@ +#ifndef OMPI_SOFTWARE_EVENT +#define OMPI_SOFTWARE_EVENT + +#include +#include +#include +#include +#include +#include "ompi/include/ompi_config.h" +#include "opal/mca/timer/timer.h" +#include "opal/mca/base/mca_base_pvar.h" + +#include MCA_timer_IMPLEMENTATION_HEADER + +/* This enumeration serves as event ids for the various events */ +enum OMPI_COUNTERS{ + OMPI_SEND, + OMPI_RECV, + OMPI_ISEND, + OMPI_IRECV, + OMPI_BCAST, + OMPI_REDUCE, + OMPI_ALLREDUCE, + OMPI_SCATTER, + OMPI_GATHER, + OMPI_ALLTOALL, + OMPI_ALLGATHER, + OMPI_BYTES_RECEIVED_USER, + OMPI_BYTES_RECEIVED_MPI, + OMPI_BYTES_SENT_USER, + OMPI_BYTES_SENT_MPI, + OMPI_BYTES_PUT, + OMPI_BYTES_GET, + OMPI_UNEXPECTED, + OMPI_OUT_OF_SEQUENCE, + OMPI_MATCH_TIME, + OMPI_OOS_MATCH_TIME, + OMPI_PROGRESS_SWITCH, + OMPI_NUM_COUNTERS +}; + +/* A structure for storing the event data */ +typedef struct ompi_event_s{ + char *name; + long long value; +} ompi_event_t; + +/* Structure and helper functions for PAPI software_events component + * Note: This component is being superceded by the sde component. + */ +struct PAPI_SOFTWARE_EVENT_S{ + char name[32]; + int version[3]; + int (*iter_start)(void); + char* (*iter_next)(void); + int (*iter_release)(void); + int (*attach_event)(char*, long long**); + int (*detach_event)(char*); +}; + +int iter_start(void); +char* iter_next(void); +int iter_release(void); +int attach_event(char *name, long long **value); +int detach_event(char *name); + +/* End of PAPI software_events component stuff */ + +OMPI_DECLSPEC extern unsigned int attached_event[OMPI_NUM_COUNTERS]; +OMPI_DECLSPEC extern ompi_event_t *events; + +/* OMPI software event utility functions */ +void ompi_sw_event_init(void); +void ompi_sw_event_fini(void); +void ompi_sw_event_record(unsigned int event_id, long long value); +void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *usec); +void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *usec); +void ompi_sw_event_print_all(void); + +/* MPI_T utility functions */ +static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count); +long long ompi_sw_event_get_counter(int counter_id); +static int ompi_sw_event_get_send(const struct mca_base_pvar_t *pvar, void *value, void *obj_handle); + +/* Functions for the PAPI sde component */ +void ompi_sde_init(void); +/* PAPI sde component interface functions */ +typedef void* papi_handle_t; + +/* This should be defined at build time through an MCA parameter */ +#define SOFTWARE_EVENTS_ENABLE + +/* Macros for using the utility functions throughout the codebase. + * If SOFTWARE_EVENTS_ENABLE is not defined, the macros become no-ops. + */ +#ifdef SOFTWARE_EVENTS_ENABLE + +#define SW_EVENT_INIT() \ + ompi_sw_event_init() + +#define SW_EVENT_FINI() \ + ompi_sw_event_fini() + +#define SW_EVENT_RECORD(event_id, value) \ + ompi_sw_event_record(event_id, value) + +#define SW_EVENT_TIMER_START(event_id, usec) \ + ompi_sw_event_timer_start(event_id, usec) + +#define SW_EVENT_TIMER_STOP(event_id, usec) \ + ompi_sw_event_timer_stop(event_id, usec) + +#define SW_EVENT_PRINT_ALL() \ + ompi_sw_event_print_all() + +#else /* Software events are not enabled */ + +#define SW_EVENT_INIT() \ + do {} while (0) + +#define SW_EVENT_FINI() \ + do {} while (0) + +#define SW_EVENT_RECORD(event_id, value) \ + do {} while (0) + +#define SW_EVENT_TIMER_START(event_id, usec) \ + do {} while (0) + +#define SW_EVENT_TIMER_STOP(event_id, usec) \ + do {} while (0) + +#define SW_EVENT_PRINT_ALL() \ + do {} while (0) + +#endif + +#endif diff --git a/opal/threads/wait_sync.c b/opal/threads/wait_sync.c index 92b6096406c..c74a7ecaafe 100644 --- a/opal/threads/wait_sync.c +++ b/opal/threads/wait_sync.c @@ -94,8 +94,10 @@ int ompi_sync_wait_mt(ompi_wait_sync_t *sync) /* In case I am the progress manager, pass the duties on */ if( sync == wait_sync_list ) { wait_sync_list = (sync == sync->next) ? NULL : sync->next; - if( NULL != wait_sync_list ) + if( NULL != wait_sync_list ){ + /* This is a possible placement for a progress switch counter */ WAIT_SYNC_PASS_OWNERSHIP(wait_sync_list); + } } OPAL_THREAD_UNLOCK(&wait_sync_lock); From ccb9ba09ee0c9e2ab85a4bae4c8cfc4d556fe5f3 Mon Sep 17 00:00:00 2001 From: David Eberius Date: Wed, 28 Jun 2017 13:43:08 -0400 Subject: [PATCH 02/12] Moved the software counters driver code up to the ompi level. Added PAPI sde driver code. Temporarily removed MPI_T helper functions. --- ompi/mca/pml/ob1/pml_ob1.c | 2 +- ompi/mca/pml/ob1/pml_ob1_isend.c | 2 +- ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 2 +- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 2 +- ompi/mca/pml/ob1/pml_ob1_sendreq.c | 2 +- ompi/mpi/c/allgather.c | 2 +- ompi/mpi/c/allreduce.c | 2 +- ompi/mpi/c/alltoall.c | 2 +- ompi/mpi/c/bcast.c | 2 +- ompi/mpi/c/finalize.c | 2 +- ompi/mpi/c/gather.c | 2 +- ompi/mpi/c/init.c | 2 +- ompi/mpi/c/init_thread.c | 2 +- ompi/mpi/c/irecv.c | 2 +- ompi/mpi/c/isend.c | 2 +- ompi/mpi/c/recv.c | 2 +- ompi/mpi/c/reduce.c | 2 +- ompi/mpi/c/scatter.c | 2 +- ompi/mpi/c/send.c | 2 +- ompi/runtime/Makefile.am | 12 +++++--- {opal => ompi}/runtime/ompi_software_events.c | 17 ++++++----- {opal => ompi}/runtime/ompi_software_events.h | 6 ++-- ompi/runtime/papi_sde_interface.c | 30 +++++++++++++++++++ ompi/runtime/papi_sde_interface.h | 15 ++++++++++ opal/runtime/Makefile.am | 9 ++---- 25 files changed, 88 insertions(+), 39 deletions(-) rename {opal => ompi}/runtime/ompi_software_events.c (98%) rename {opal => ompi}/runtime/ompi_software_events.h (99%) create mode 100644 ompi/runtime/papi_sde_interface.c create mode 100644 ompi/runtime/papi_sde_interface.h diff --git a/ompi/mca/pml/ob1/pml_ob1.c b/ompi/mca/pml/ob1/pml_ob1.c index 6575c95bb12..9c7ff8a4076 100644 --- a/ompi/mca/pml/ob1/pml_ob1.c +++ b/ompi/mca/pml/ob1/pml_ob1.c @@ -36,7 +36,7 @@ #include "opal_stdint.h" #include "opal/mca/btl/btl.h" #include "opal/mca/btl/base/base.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #include "ompi/mca/pml/pml.h" #include "ompi/mca/pml/base/base.h" diff --git a/ompi/mca/pml/ob1/pml_ob1_isend.c b/ompi/mca/pml/ob1/pml_ob1_isend.c index 7b188b93108..696be1f598b 100644 --- a/ompi/mca/pml/ob1/pml_ob1_isend.c +++ b/ompi/mca/pml/ob1/pml_ob1_isend.c @@ -28,7 +28,7 @@ #include "pml_ob1_sendreq.h" #include "pml_ob1_recvreq.h" #include "ompi/peruse/peruse-internal.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" /** * Single usage request. As we allow recursive calls (as an diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index 47869242521..34e98756d61 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -39,7 +39,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/peruse/peruse-internal.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #include "pml_ob1.h" #include "pml_ob1_comm.h" diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index 7fb8851dcfd..fc2c9029861 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -29,7 +29,7 @@ #include "opal/mca/mpool/mpool.h" #include "opal/util/arch.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #include "ompi/mca/pml/pml.h" #include "ompi/mca/bml/bml.h" #include "pml_ob1_comm.h" diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index 6b30bf6a5f0..8a1deabed92 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -29,7 +29,7 @@ #include "ompi_config.h" #include "opal/prefetch.h" #include "opal/mca/mpool/mpool.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #include "ompi/constants.h" #include "ompi/mca/pml/pml.h" #include "pml_ob1.h" diff --git a/ompi/mpi/c/allgather.c b/ompi/mpi/c/allgather.c index 5a05e2685df..07d62deb282 100644 --- a/ompi/mpi/c/allgather.c +++ b/ompi/mpi/c/allgather.c @@ -32,7 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/allreduce.c b/ompi/mpi/c/allreduce.c index c38293667ff..f485e202965 100644 --- a/ompi/mpi/c/allreduce.c +++ b/ompi/mpi/c/allreduce.c @@ -31,7 +31,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/alltoall.c b/ompi/mpi/c/alltoall.c index 471b38e00e5..5001293d117 100644 --- a/ompi/mpi/c/alltoall.c +++ b/ompi/mpi/c/alltoall.c @@ -33,7 +33,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/bcast.c b/ompi/mpi/c/bcast.c index 7f4de50e561..b0ba0b8f8e9 100644 --- a/ompi/mpi/c/bcast.c +++ b/ompi/mpi/c/bcast.c @@ -26,7 +26,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/finalize.c b/ompi/mpi/c/finalize.c index 22ef9004c78..b35751fcebf 100644 --- a/ompi/mpi/c/finalize.c +++ b/ompi/mpi/c/finalize.c @@ -23,7 +23,7 @@ #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/params.h" #include "ompi/errhandler/errhandler.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/gather.c b/ompi/mpi/c/gather.c index 1890d13cbf8..4fd06446609 100644 --- a/ompi/mpi/c/gather.c +++ b/ompi/mpi/c/gather.c @@ -32,7 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/init.c b/ompi/mpi/c/init.c index 31c21b74961..472e9a9efcc 100644 --- a/ompi/mpi/c/init.c +++ b/ompi/mpi/c/init.c @@ -25,7 +25,7 @@ #include #include "opal/util/show_help.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #include "ompi/mpi/c/bindings.h" #include "ompi/communicator/communicator.h" #include "ompi/errhandler/errhandler.h" diff --git a/ompi/mpi/c/init_thread.c b/ompi/mpi/c/init_thread.c index fba9d6371d0..061d6d99c4b 100644 --- a/ompi/mpi/c/init_thread.c +++ b/ompi/mpi/c/init_thread.c @@ -26,7 +26,7 @@ #include "ompi_config.h" #include "opal/util/show_help.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/params.h" #include "ompi/communicator/communicator.h" diff --git a/ompi/mpi/c/irecv.c b/ompi/mpi/c/irecv.c index 42f0236bb9e..5b40bf0bf64 100644 --- a/ompi/mpi/c/irecv.c +++ b/ompi/mpi/c/irecv.c @@ -27,7 +27,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/isend.c b/ompi/mpi/c/isend.c index 18ce9b241ab..63d81dbdec6 100644 --- a/ompi/mpi/c/isend.c +++ b/ompi/mpi/c/isend.c @@ -31,7 +31,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/recv.c b/ompi/mpi/c/recv.c index 2c036f8b634..37504971b69 100644 --- a/ompi/mpi/c/recv.c +++ b/ompi/mpi/c/recv.c @@ -27,7 +27,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/memchecker.h" #include "ompi/request/request.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/reduce.c b/ompi/mpi/c/reduce.c index e9603a8dadf..76e0354a023 100644 --- a/ompi/mpi/c/reduce.c +++ b/ompi/mpi/c/reduce.c @@ -31,7 +31,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/scatter.c b/ompi/mpi/c/scatter.c index 44a318646e4..3564d233282 100644 --- a/ompi/mpi/c/scatter.c +++ b/ompi/mpi/c/scatter.c @@ -32,7 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/mpi/c/send.c b/ompi/mpi/c/send.c index 7b73647dec5..2dee463be22 100644 --- a/ompi/mpi/c/send.c +++ b/ompi/mpi/c/send.c @@ -30,7 +30,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "opal/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_software_events.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/runtime/Makefile.am b/ompi/runtime/Makefile.am index 427abba2674..0aa5e999c32 100644 --- a/ompi/runtime/Makefile.am +++ b/ompi/runtime/Makefile.am @@ -25,9 +25,11 @@ dist_ompidata_DATA += runtime/help-mpi-runtime.txt headers += \ runtime/mpiruntime.h \ - runtime/ompi_cr.h \ + runtime/ompi_cr.h \ runtime/params.h \ - runtime/ompi_info_support.h + runtime/ompi_info_support.h \ + runtime/ompi_software_events.h \ + runtime/papi_sde_interface.h lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ runtime/ompi_mpi_abort.c \ @@ -36,5 +38,7 @@ lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ runtime/ompi_mpi_finalize.c \ runtime/ompi_mpi_params.c \ runtime/ompi_mpi_preconnect.c \ - runtime/ompi_cr.c \ - runtime/ompi_info_support.c + runtime/ompi_cr.c \ + runtime/ompi_info_support.c \ + runtime/ompi_software_events.c \ + runtime/papi_sde_interface.c diff --git a/opal/runtime/ompi_software_events.c b/ompi/runtime/ompi_software_events.c similarity index 98% rename from opal/runtime/ompi_software_events.c rename to ompi/runtime/ompi_software_events.c index 6289f9e21e7..dcc9ad78ca5 100644 --- a/opal/runtime/ompi_software_events.c +++ b/ompi/runtime/ompi_software_events.c @@ -59,7 +59,7 @@ OMPI_DECLSPEC ompi_event_t *events = NULL; * ################# Begin MPI_T Functions ###################### * ############################################################## */ - +#if 0 static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count) { (void)obj_handle; @@ -83,9 +83,11 @@ static int ompi_sw_event_get_send(const struct mca_base_pvar_t *pvar, void *valu long long *counter_value = (long long*)value; *counter_value = ompi_sw_event_get_counter(OMPI_SEND); - return OPAL_SUCCESS; + return OMPI_SUCCESS; } +#endif + /* ############################################################## * ############ Begin PAPI software_events Code ################# * ############################################################## @@ -98,8 +100,7 @@ int iter_start() if(events == NULL){ events = (ompi_event_t*)malloc(OMPI_NUM_COUNTERS * sizeof(ompi_event_t)); - } - else{ + } else { fprintf(stderr, "The events data structure has already been allocated.\n"); } @@ -226,7 +227,7 @@ void ompi_sde_init() { /* Required registration of counters and optional counter descriptions */ for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - printf("Registering: %s (%d of %d)\n", counter_names[i], i, OMPI_NUM_COUNTERS); + //printf("Registering: %s (%d of %d)\n", counter_names[i], i, OMPI_NUM_COUNTERS); papi_sde_register_counter(sde_handle, counter_names[i], &(events[i].value) ); papi_sde_describe_counter(sde_handle, counter_names[i], counter_descriptions[i]); } @@ -349,13 +350,13 @@ void ompi_sw_event_init() for(i = 0; i < OMPI_NUM_COUNTERS; i++){ attached_event[i] = 1; } - - (void)mca_base_pvar_register("ompi", "opal", "software_events", counter_names[OMPI_SEND], counter_descriptions[OMPI_SEND], + /* + (void)mca_base_pvar_register("ompi", "runtime", "software_events", counter_names[OMPI_SEND], counter_descriptions[OMPI_SEND], OPAL_INFO_LVL_4, MPI_T_PVAR_CLASS_SIZE, MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, NULL, MPI_T_BIND_NO_OBJECT, MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS, ompi_sw_event_get_send, NULL, ompi_sw_event_notify, NULL); - + */ /* For initializing the PAPI sde component environment */ ompi_sde_init(); } diff --git a/opal/runtime/ompi_software_events.h b/ompi/runtime/ompi_software_events.h similarity index 99% rename from opal/runtime/ompi_software_events.h rename to ompi/runtime/ompi_software_events.h index 551b65de2d3..ca08490decc 100644 --- a/opal/runtime/ompi_software_events.h +++ b/ompi/runtime/ompi_software_events.h @@ -5,7 +5,8 @@ #include #include #include -#include + +#include "ompi/include/mpi.h" #include "ompi/include/ompi_config.h" #include "opal/mca/timer/timer.h" #include "opal/mca/base/mca_base_pvar.h" @@ -78,10 +79,11 @@ void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *usec); void ompi_sw_event_print_all(void); /* MPI_T utility functions */ +/* static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count); long long ompi_sw_event_get_counter(int counter_id); static int ompi_sw_event_get_send(const struct mca_base_pvar_t *pvar, void *value, void *obj_handle); - +*/ /* Functions for the PAPI sde component */ void ompi_sde_init(void); /* PAPI sde component interface functions */ diff --git a/ompi/runtime/papi_sde_interface.c b/ompi/runtime/papi_sde_interface.c new file mode 100644 index 00000000000..7b0e86c83d2 --- /dev/null +++ b/ompi/runtime/papi_sde_interface.c @@ -0,0 +1,30 @@ +#include +#include +#include "papi_sde_interface.h" + +#pragma weak papi_sde_init +#pragma weak papi_sde_register_counter +#pragma weak papi_sde_describe_counter + +OMPI_DECLSPEC papi_handle_t +__attribute__((weak)) +papi_sde_init(char *name_of_library, int *event_count) +{ + printf("weak papi_sde_init called from %s\n", __FILE__); + void * ptr = NULL; + return ptr; +} + +OMPI_DECLSPEC void +__attribute__((weak)) +papi_sde_register_counter(papi_handle_t handle, char *event_name, long long int *counter) +{ + printf("weak papi_sde_register_counter called from %s\n", __FILE__); +} + +OMPI_DECLSPEC void +__attribute__((weak)) +papi_sde_describe_counter(papi_handle_t handle, char *event_name, char *event_description) +{ + printf("weak papi_sde_describe_counter called from %s\n", __FILE__); +} diff --git a/ompi/runtime/papi_sde_interface.h b/ompi/runtime/papi_sde_interface.h new file mode 100644 index 00000000000..54154f8a186 --- /dev/null +++ b/ompi/runtime/papi_sde_interface.h @@ -0,0 +1,15 @@ +#ifndef PAPI_SDE_INTERFACE_H +#define PAPI_SDE_INTERFACE_H + +#include "ompi/include/ompi_config.h" + +// interface to papi SDE functions +typedef void* papi_handle_t; +papi_handle_t papi_sde_init(char *name_of_library, int *event_count); +void papi_sde_register_counter(papi_handle_t handle, char *event_name, long long int *counter); +void papi_sde_describe_counter(papi_handle_t handle, char *event_name, char *event_description ); + +// required for papi_native_avail +void* papi_sde_hook_list_events( void ); + +#endif diff --git a/opal/runtime/Makefile.am b/opal/runtime/Makefile.am index 6ecb583e64f..5bef9322ae7 100644 --- a/opal/runtime/Makefile.am +++ b/opal/runtime/Makefile.am @@ -36,9 +36,7 @@ headers += \ runtime/opal_cr.h \ runtime/opal_info_support.h \ runtime/opal_params.h \ - runtime/opal_progress_threads.h \ - runtime/ompi_software_events.h \ - runtime/papi_sde_interface.h + runtime/opal_progress_threads.h lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \ runtime/opal_progress.c \ @@ -47,6 +45,5 @@ lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \ runtime/opal_params.c \ runtime/opal_cr.c \ runtime/opal_info_support.c \ - runtime/opal_progress_threads.c \ - runtime/ompi_software_events.c \ - runtime/papi_sde_interface.c + runtime/opal_progress_threads.c + From cd79dcc0fb43c5bc5ce14c08aca09ab6b52db11a Mon Sep 17 00:00:00 2001 From: David Eberius Date: Wed, 23 Aug 2017 16:16:32 -0400 Subject: [PATCH 03/12] Added a new USER_OR_MPI macro for determining which counter the bytes sent/received should be put into. Added some more protection into the code. Started work on getting rid of the loops in pml_ob1_sendreq.c. --- ompi/mca/bml/bml.h | 2 -- ompi/mca/pml/ob1/pml_ob1.c | 1 - ompi/mca/pml/ob1/pml_ob1_isend.c | 2 +- ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 8 +++--- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 39 ++++------------------------- ompi/mca/pml/ob1/pml_ob1_sendreq.c | 35 +++++++++++++++++++++----- ompi/mpi/c/bcast.c | 7 ------ ompi/mpi/c/isend.c | 1 - ompi/mpi/c/recv.c | 1 - ompi/mpi/c/send.c | 1 - ompi/runtime/ompi_software_events.c | 34 +++++++++++++++++++++---- ompi/runtime/ompi_software_events.h | 11 ++++++-- opal/mca/btl/btl.h | 1 - opal/threads/wait_sync.c | 2 +- 14 files changed, 77 insertions(+), 68 deletions(-) diff --git a/ompi/mca/bml/bml.h b/ompi/mca/bml/bml.h index d48df9643d6..df731a64a04 100644 --- a/ompi/mca/bml/bml.h +++ b/ompi/mca/bml/bml.h @@ -286,7 +286,6 @@ static inline int mca_bml_base_send_status( mca_bml_base_btl_t* bml_btl, mca_btl_base_module_t* btl = bml_btl->btl; des->des_context = (void*) bml_btl; - return btl->btl_send(btl, bml_btl->btl_endpoint, des, tag); } @@ -301,7 +300,6 @@ static inline int mca_bml_base_sendi( mca_bml_base_btl_t* bml_btl, mca_btl_base_descriptor_t** descriptor ) { mca_btl_base_module_t* btl = bml_btl->btl; - return btl->btl_sendi(btl, bml_btl->btl_endpoint, convertor, header, header_size, payload_size, order, flags, tag, descriptor); diff --git a/ompi/mca/pml/ob1/pml_ob1.c b/ompi/mca/pml/ob1/pml_ob1.c index 9c7ff8a4076..5cab48ef6df 100644 --- a/ompi/mca/pml/ob1/pml_ob1.c +++ b/ompi/mca/pml/ob1/pml_ob1.c @@ -679,7 +679,6 @@ int mca_pml_ob1_send_fin( ompi_proc_t* proc, /* queue request */ rc = mca_bml_base_send( bml_btl, fin, MCA_PML_OB1_HDR_TYPE_FIN ); - if( OPAL_LIKELY( rc >= 0 ) ) { if( OPAL_LIKELY( 1 == rc ) ) { MCA_PML_OB1_PROGRESS_PENDING(bml_btl); diff --git a/ompi/mca/pml/ob1/pml_ob1_isend.c b/ompi/mca/pml/ob1/pml_ob1_isend.c index 696be1f598b..2095a00bc9f 100644 --- a/ompi/mca/pml/ob1/pml_ob1_isend.c +++ b/ompi/mca/pml/ob1/pml_ob1_isend.c @@ -121,7 +121,7 @@ static inline int mca_pml_ob1_send_inline (const void *buf, size_t count, size, MCA_BTL_NO_ORDER, MCA_BTL_DES_FLAGS_PRIORITY | MCA_BTL_DES_FLAGS_BTL_OWNERSHIP, MCA_PML_OB1_HDR_TYPE_MATCH, NULL); - if(rc == OPAL_SUCCESS){ + if(OPAL_LIKELY(rc == OPAL_SUCCESS)){ if(tag >= 0){ SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, size); } diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index 34e98756d61..8aeaffab478 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -457,8 +457,7 @@ void mca_pml_ob1_recv_frag_callback_match(mca_btl_base_module_t* btl, if(match->req_recv.req_base.req_tag >= 0){ SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_USER, (long long)(bytes_received)); - } - else{ + } else { SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)(bytes_received)); } @@ -786,7 +785,9 @@ match_one(mca_btl_base_module_t *btl, mca_pml_ob1_comm_proc_t *proc, mca_pml_ob1_recv_frag_t* frag) { +#ifdef SOFTWARE_EVENTS_ENABLE opal_timer_t usecs = 0; +#endif SW_EVENT_TIMER_START(OMPI_MATCH_TIME, &usecs); mca_pml_ob1_recv_request_t *match; @@ -827,7 +828,6 @@ match_one(mca_btl_base_module_t *btl, /* this frag is already processed, so we want to break out of the loop and not end up back on the unexpected queue. */ SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &usecs); - /*SW_EVENT_RECORD(OMPI_MATCH_TIME, (long long)usecs);*/ return NULL; } @@ -835,7 +835,6 @@ match_one(mca_btl_base_module_t *btl, PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_MSG_MATCH_POSTED_REQ, &(match->req_recv.req_base), PERUSE_RECV); SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &usecs); - /*SW_EVENT_RECORD(OMPI_MATCH_TIME, (long long)usecs);*/ return match; } @@ -849,7 +848,6 @@ match_one(mca_btl_base_module_t *btl, PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_INSERT_IN_UNEX_Q, comm_ptr, hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &usecs); - /*SW_EVENT_RECORD(OMPI_MATCH_TIME, (long long)usecs);*/ return NULL; } while(true); diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index fc2c9029861..487066fc611 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -243,6 +243,7 @@ int mca_pml_ob1_recv_request_ack_send_btl( des->des_cbfunc = mca_pml_ob1_recv_ctl_completion; rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_ACK); + SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)size); if( OPAL_LIKELY( rc >= 0 ) ) { return OMPI_SUCCESS; @@ -432,28 +433,8 @@ static int mca_pml_ob1_recv_request_put_frag (mca_pml_ob1_rdma_frag_t *frag) /* send rdma request to peer */ rc = mca_bml_base_send (bml_btl, ctl, MCA_PML_OB1_HDR_TYPE_PUT); -#ifdef SOFTWARE_EVENTS_ENABLE - volatile int64_t bytes_sent; - unsigned int i; - if(attached_event[OMPI_BYTES_SENT_USER] == 1){ - if(recvreq->req_recv.req_base.req_tag >= 0){ - bytes_sent = 0; - for(i = 0; i < ctl->des_segment_count; i++){ - bytes_sent += ctl->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); - } - } - if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ - if(recvreq->req_recv.req_base.req_tag < 0){ - bytes_sent = 0; - for(i = 0; i < ctl->des_segment_count; i++){ - bytes_sent += ctl->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); - } - } -#endif + /* Increment counter for bytes_put even though they probably haven't all been received yet */ + SW_EVENT_RECORD(OMPI_BYTES_PUT, frag->rdma_length); if (OPAL_UNLIKELY(rc < 0)) { mca_bml_base_free (bml_btl, ctl); @@ -556,12 +537,7 @@ void mca_pml_ob1_recv_request_progress_frag( mca_pml_ob1_recv_request_t* recvreq OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); - if(recvreq->req_recv.req_base.req_tag >= 0){ - SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_USER, (long long)bytes_received); - } - else{ - SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)bytes_received); - } + SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* check completion status */ if(recv_request_pml_complete_check(recvreq) == false && @@ -925,12 +901,7 @@ void mca_pml_ob1_recv_request_progress_match( mca_pml_ob1_recv_request_t* recvre */ recvreq->req_bytes_received += bytes_received; - if(recvreq->req_recv.req_base.req_tag >= 0){ - SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_USER, (long long)bytes_received); - } - else{ - SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)bytes_received); - } + SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); recv_request_pml_complete(recvreq); } diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index 8a1deabed92..d0322284b3b 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -451,15 +451,19 @@ int mca_pml_ob1_send_request_start_buffered( /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RNDV); + /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, sendreq->req_bytes_delivered + req_bytes_delivered, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ + #ifdef SOFTWARE_EVENTS_ENABLE volatile int64_t bytes_sent; unsigned int i; if(attached_event[OMPI_BYTES_SENT_USER] == 1){ if(sendreq->req_send.req_base.req_tag >= 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } + bytes_sent = 0; + for(i = 0; i < des->des_segment_count; i++){ + bytes_sent += des->des_segments[i].seg_len; + } + bytes_sent = sendreq->req_bytes_delivered; SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); } } @@ -469,6 +473,7 @@ int mca_pml_ob1_send_request_start_buffered( for(i = 0; i < des->des_segment_count; i++){ bytes_sent += des->des_segments[i].seg_len; } + bytes_sent = sendreq->req_bytes_delivered; SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); } } @@ -522,12 +527,13 @@ int mca_pml_ob1_send_request_start_copy( mca_pml_ob1_send_request_t* sendreq, &des); if(rc == OPAL_SUCCESS){ - if(sendreq->req_send.req_base.req_tag >= 0){ + /*if(sendreq->req_send.req_base.req_tag >= 0){ SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, size); } else{ SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, size); - } + }*/ + SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); } if( OPAL_LIKELY(OMPI_SUCCESS == rc) ) { @@ -603,6 +609,11 @@ int mca_pml_ob1_send_request_start_copy( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send_status(bml_btl, des, MCA_PML_OB1_HDR_TYPE_MATCH); + /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, sendreq->req_bytes_delivered - OMPI_PML_OB1_MATCH_HDR_LEN, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ + /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ + #ifdef SOFTWARE_EVENTS_ENABLE volatile int64_t bytes_sent; unsigned int i; @@ -687,6 +698,9 @@ int mca_pml_ob1_send_request_start_prepare( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_MATCH); + /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size,//sendreq->req_bytes_delivered, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ + #ifdef SOFTWARE_EVENTS_ENABLE volatile int64_t bytes_sent; unsigned int i; @@ -815,6 +829,9 @@ int mca_pml_ob1_send_request_start_rdma( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RGET); + /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, sendreq->req_bytes_delivered, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ + #ifdef SOFTWARE_EVENTS_ENABLE volatile int64_t bytes_sent; unsigned int i; @@ -919,6 +936,9 @@ int mca_pml_ob1_send_request_start_rndv( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RNDV); + /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, sendreq->req_bytes_delivered, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ + #ifdef SOFTWARE_EVENTS_ENABLE volatile int64_t bytes_sent; unsigned int i; @@ -1187,6 +1207,9 @@ mca_pml_ob1_send_request_schedule_once(mca_pml_ob1_send_request_t* sendreq) /* initiate send - note that this may complete before the call returns */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_FRAG); + /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, sendreq->req_bytes_delivered, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ + #ifdef SOFTWARE_EVENTS_ENABLE volatile int64_t bytes_sent; unsigned int i; diff --git a/ompi/mpi/c/bcast.c b/ompi/mpi/c/bcast.c index b0ba0b8f8e9..ea0613e4ad6 100644 --- a/ompi/mpi/c/bcast.c +++ b/ompi/mpi/c/bcast.c @@ -113,12 +113,5 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, err = comm->c_coll->coll_bcast(buffer, count, datatype, root, comm, comm->c_coll->coll_bcast_module); - if(ompi_comm_rank(comm) == root){ - SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, count * sizeof(datatype) * ((int)ompi_comm_size(comm)-1)); - } - else{ - SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, count * sizeof(datatype)); - } - OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME); } diff --git a/ompi/mpi/c/isend.c b/ompi/mpi/c/isend.c index 63d81dbdec6..fe808f3e4a4 100644 --- a/ompi/mpi/c/isend.c +++ b/ompi/mpi/c/isend.c @@ -93,7 +93,6 @@ int MPI_Isend(const void *buf, int count, MPI_Datatype type, int dest, rc = MCA_PML_CALL(isend(buf, count, type, dest, tag, MCA_PML_BASE_SEND_STANDARD, comm, request)); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/recv.c b/ompi/mpi/c/recv.c index 37504971b69..118ca9e8395 100644 --- a/ompi/mpi/c/recv.c +++ b/ompi/mpi/c/recv.c @@ -79,6 +79,5 @@ int MPI_Recv(void *buf, int count, MPI_Datatype type, int source, OPAL_CR_ENTER_LIBRARY(); rc = MCA_PML_CALL(recv(buf, count, type, source, tag, comm, status)); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/send.c b/ompi/mpi/c/send.c index 2dee463be22..b85b6803657 100644 --- a/ompi/mpi/c/send.c +++ b/ompi/mpi/c/send.c @@ -78,6 +78,5 @@ int MPI_Send(const void *buf, int count, MPI_Datatype type, int dest, OPAL_CR_ENTER_LIBRARY(); rc = MCA_PML_CALL(send(buf, count, type, dest, tag, MCA_PML_BASE_SEND_STANDARD, comm)); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/ompi/runtime/ompi_software_events.c b/ompi/runtime/ompi_software_events.c index dcc9ad78ca5..100dd51acbf 100644 --- a/ompi/runtime/ompi_software_events.c +++ b/ompi/runtime/ompi_software_events.c @@ -1,5 +1,7 @@ #include "ompi_software_events.h" +opal_timer_t sys_clock_freq_mhz = 0; + OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { "OMPI_SEND", "OMPI_RECV", @@ -59,14 +61,13 @@ OMPI_DECLSPEC ompi_event_t *events = NULL; * ################# Begin MPI_T Functions ###################### * ############################################################## */ -#if 0 static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count) { (void)obj_handle; if(MCA_BASE_PVAR_HANDLE_BIND == event) *count = 1; - return OPAL_SUCCESS; + return MPI_SUCCESS; } inline long long ompi_sw_event_get_counter(int counter_id) @@ -83,11 +84,9 @@ static int ompi_sw_event_get_send(const struct mca_base_pvar_t *pvar, void *valu long long *counter_value = (long long*)value; *counter_value = ompi_sw_event_get_counter(OMPI_SEND); - return OMPI_SUCCESS; + return MPI_SUCCESS; } -#endif - /* ############################################################## * ############ Begin PAPI software_events Code ################# * ############################################################## @@ -343,7 +342,18 @@ void* papi_sde_hook_list_events(void) void ompi_sw_event_init() { int i; + /* +#if OPAL_HAVE_SYS_TIMER_GET_CYCLES + printf("OPAL_HAVE_SYS_TIMER_GET_CYCLES defined\n"); +#endif +#if OPAL_HAVE_CLOCK_GETTIME + printf("OPAL_HAVE_CLOCK_GETTIME defined\n"); +#endif + printf("Clock Frequency: %d Hz\n", (int)opal_timer_base_get_freq()); + sys_clock_freq_mhz = 2300;//opal_timer_base_get_freq() / 1000000; + printf("Clock Frequency (converted): %d MHz\n", (int)sys_clock_freq_mhz); +*/ iter_start(); /* Turn all counters on */ @@ -380,6 +390,7 @@ void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *usec) { /* Check whether usec == 0.0 to make sure the timer hasn't started yet */ if(OPAL_UNLIKELY(attached_event[event_id] == 1 && *usec == 0)){ + //*usec = opal_timer_base_get_cycles(); *usec = opal_timer_base_get_usec(); } } @@ -390,11 +401,24 @@ void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *usec) void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *usec) { if(OPAL_UNLIKELY(attached_event[event_id] == 1)){ + //*usec = (opal_timer_base_get_cycles() - *usec) / sys_clock_freq_mhz; *usec = opal_timer_base_get_usec() - *usec; OPAL_THREAD_ADD64(&events[event_id].value, (long long)*usec); } } +/* Checks a tag, and records the user version of the counter if it's greater + * than or equal to 0 and records the mpi version of the counter otherwise. + */ +void ompi_sw_event_user_or_mpi(int tag, long long value, unsigned int user_enum, unsigned int mpi_enum) +{ + if(tag >= 0){ + SW_EVENT_RECORD(user_enum, value); + } else { + SW_EVENT_RECORD(mpi_enum, value); + } +} + /* A function to output the value of all of the counters. This is currently * implemented in MPI_Finalize, but we need to find a better way for this to * happen. diff --git a/ompi/runtime/ompi_software_events.h b/ompi/runtime/ompi_software_events.h index ca08490decc..198b196f4e3 100644 --- a/ompi/runtime/ompi_software_events.h +++ b/ompi/runtime/ompi_software_events.h @@ -76,14 +76,15 @@ void ompi_sw_event_fini(void); void ompi_sw_event_record(unsigned int event_id, long long value); void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *usec); void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *usec); +void ompi_sw_event_user_or_mpi(int tag, long long value, unsigned int user_enum, unsigned int mpi_enum); void ompi_sw_event_print_all(void); /* MPI_T utility functions */ -/* + static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count); long long ompi_sw_event_get_counter(int counter_id); static int ompi_sw_event_get_send(const struct mca_base_pvar_t *pvar, void *value, void *obj_handle); -*/ + /* Functions for the PAPI sde component */ void ompi_sde_init(void); /* PAPI sde component interface functions */ @@ -112,6 +113,9 @@ typedef void* papi_handle_t; #define SW_EVENT_TIMER_STOP(event_id, usec) \ ompi_sw_event_timer_stop(event_id, usec) +#define SW_EVENT_USER_OR_MPI(tag, value, enum_if_user, enum_if_mpi) \ + ompi_sw_event_user_or_mpi(tag, value, enum_if_user, enum_if_mpi) + #define SW_EVENT_PRINT_ALL() \ ompi_sw_event_print_all() @@ -132,6 +136,9 @@ typedef void* papi_handle_t; #define SW_EVENT_TIMER_STOP(event_id, usec) \ do {} while (0) +#define SW_EVENT_USER_OR_MPI(tag, value, enum_if_user, enum_if_mpi) \ + do {} while (0) + #define SW_EVENT_PRINT_ALL() \ do {} while (0) diff --git a/opal/mca/btl/btl.h b/opal/mca/btl/btl.h index 2c4a972f6dc..5f0e73b30c7 100644 --- a/opal/mca/btl/btl.h +++ b/opal/mca/btl/btl.h @@ -450,7 +450,6 @@ typedef struct mca_btl_base_segment_t mca_btl_base_segment_t; * des_segments */ - struct mca_btl_base_descriptor_t { opal_free_list_item_t super; mca_btl_base_segment_t *des_segments; /**< local segments */ diff --git a/opal/threads/wait_sync.c b/opal/threads/wait_sync.c index c74a7ecaafe..9b5d75ece71 100644 --- a/opal/threads/wait_sync.c +++ b/opal/threads/wait_sync.c @@ -95,7 +95,7 @@ int ompi_sync_wait_mt(ompi_wait_sync_t *sync) if( sync == wait_sync_list ) { wait_sync_list = (sync == sync->next) ? NULL : sync->next; if( NULL != wait_sync_list ){ - /* This is a possible placement for a progress switch counter */ + /* This is a possible placement for an MPI_T progress switch counter */ WAIT_SYNC_PASS_OWNERSHIP(wait_sync_list); } } From f7d35533ef59a433c06e298e64b9bbfc69b0da79 Mon Sep 17 00:00:00 2001 From: David Eberius Date: Thu, 12 Oct 2017 18:47:08 -0400 Subject: [PATCH 04/12] Switched the timer units over to cycles to avoid division operations. Moved the bytes sent/received counters to reflect when ompi updates its own internal counters. Cleaned up some unnecessary print statements in the papi sde code. --- ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 6 +- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 7 +- ompi/mca/pml/ob1/pml_ob1_sendreq.c | 181 ++-------------------------- ompi/mpi/c/finalize.c | 8 -- ompi/runtime/ompi_software_events.c | 30 ++--- ompi/runtime/ompi_software_events.h | 1 - ompi/runtime/papi_sde_interface.c | 6 +- 7 files changed, 38 insertions(+), 201 deletions(-) diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index 8aeaffab478..491936fdbfb 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -455,11 +455,7 @@ void mca_pml_ob1_recv_frag_callback_match(mca_btl_base_module_t* btl, &bytes_received ); match->req_bytes_received = bytes_received; - if(match->req_recv.req_base.req_tag >= 0){ - SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_USER, (long long)(bytes_received)); - } else { - SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)(bytes_received)); - } + SW_EVENT_USER_OR_MPI(match->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* * Unpacking finished, make the user buffer unaccessable again. diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index 487066fc611..bb11b77574f 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -199,7 +199,10 @@ static void mca_pml_ob1_put_completion (mca_pml_ob1_rdma_frag_t *frag, int64_t r if (OPAL_LIKELY(0 < rdma_size)) { /* check completion status */ + OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, rdma_size); + SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)rdma_size, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); + if (recv_request_pml_complete_check(recvreq) == false && recvreq->req_rdma_offset < recvreq->req_send_offset) { /* schedule additional rdma operations */ @@ -377,6 +380,7 @@ static void mca_pml_ob1_rget_completion (mca_btl_base_module_t* btl, struct mca_ } else { /* is receive request complete */ OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, frag->rdma_length); + SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)frag->rdma_length, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* TODO: re-add order */ mca_pml_ob1_send_fin (recvreq->req_recv.req_base.req_proc, bml_btl, frag->rdma_hdr.hdr_rget.hdr_frag, @@ -536,7 +540,6 @@ void mca_pml_ob1_recv_request_progress_frag( mca_pml_ob1_recv_request_t* recvreq ); OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); - SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* check completion status */ @@ -616,6 +619,7 @@ void mca_pml_ob1_recv_request_frag_copy_finished( mca_btl_base_module_t* btl, des->des_cbfunc(NULL, NULL, des, 0); OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); + SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* check completion status */ if(recv_request_pml_complete_check(recvreq) == false && @@ -830,6 +834,7 @@ void mca_pml_ob1_recv_request_progress_rndv( mca_pml_ob1_recv_request_t* recvreq recvreq->req_recv.req_base.req_datatype); ); OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); + SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); } /* check completion status */ if(recv_request_pml_complete_check(recvreq) == false && diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index d0322284b3b..93f06f0cd2b 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -206,6 +206,8 @@ mca_pml_ob1_rndv_completion_request( mca_bml_base_btl_t* bml_btl, } OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, req_bytes_delivered); + SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, req_bytes_delivered, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); /* advance the request */ OPAL_THREAD_ADD_FETCH32(&sendreq->req_state, -1); @@ -262,6 +264,8 @@ mca_pml_ob1_rget_completion (mca_pml_ob1_rdma_frag_t *frag, int64_t rdma_length) /* count bytes of user data actually delivered and check for request completion */ if (OPAL_LIKELY(0 < rdma_length)) { OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, (size_t) rdma_length); + SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, rdma_length, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); } send_request_pml_complete_check(sendreq); @@ -315,6 +319,8 @@ mca_pml_ob1_frag_completion( mca_btl_base_module_t* btl, OPAL_THREAD_ADD_FETCH32(&sendreq->req_pipeline_depth, -1); OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, req_bytes_delivered); + SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, req_bytes_delivered, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); if(send_request_pml_complete_check(sendreq) == false) { mca_pml_ob1_send_request_schedule(sendreq); @@ -451,34 +457,6 @@ int mca_pml_ob1_send_request_start_buffered( /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RNDV); - /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, sendreq->req_bytes_delivered + req_bytes_delivered, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ - -#ifdef SOFTWARE_EVENTS_ENABLE - volatile int64_t bytes_sent; - unsigned int i; - if(attached_event[OMPI_BYTES_SENT_USER] == 1){ - if(sendreq->req_send.req_base.req_tag >= 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - bytes_sent = sendreq->req_bytes_delivered; - SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); - } - } - if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ - if(sendreq->req_send.req_base.req_tag < 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - bytes_sent = sendreq->req_bytes_delivered; - SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); - } - } -#endif - if( OPAL_LIKELY( rc >= 0 ) ) { if( OPAL_LIKELY( 1 == rc ) ) { mca_pml_ob1_rndv_completion_request( bml_btl, sendreq, req_bytes_delivered); @@ -526,18 +504,9 @@ int mca_pml_ob1_send_request_start_copy( mca_pml_ob1_send_request_t* sendreq, MCA_PML_OB1_HDR_TYPE_MATCH, &des); - if(rc == OPAL_SUCCESS){ - /*if(sendreq->req_send.req_base.req_tag >= 0){ - SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, size); - } - else{ - SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, size); - }*/ - SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); - } - if( OPAL_LIKELY(OMPI_SUCCESS == rc) ) { /* signal request completion */ + SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); send_request_pml_complete(sendreq); return OMPI_SUCCESS; } @@ -609,33 +578,8 @@ int mca_pml_ob1_send_request_start_copy( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send_status(bml_btl, des, MCA_PML_OB1_HDR_TYPE_MATCH); - /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, sendreq->req_bytes_delivered - OMPI_PML_OB1_MATCH_HDR_LEN, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ - /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ - -#ifdef SOFTWARE_EVENTS_ENABLE - volatile int64_t bytes_sent; - unsigned int i; - if(attached_event[OMPI_BYTES_SENT_USER] == 1){ - if(sendreq->req_send.req_base.req_tag >= 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent - OMPI_PML_OB1_MATCH_HDR_LEN); - } - } - if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ - if(sendreq->req_send.req_base.req_tag < 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent - OMPI_PML_OB1_MATCH_HDR_LEN); - } - } -#endif + SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); if( OPAL_LIKELY( rc >= OPAL_SUCCESS ) ) { if( OPAL_LIKELY( 1 == rc ) ) { @@ -698,31 +642,8 @@ int mca_pml_ob1_send_request_start_prepare( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_MATCH); - /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size,//sendreq->req_bytes_delivered, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ - -#ifdef SOFTWARE_EVENTS_ENABLE - volatile int64_t bytes_sent; - unsigned int i; - if(attached_event[OMPI_BYTES_SENT_USER] == 1){ - if(sendreq->req_send.req_base.req_tag >= 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); - } - } - if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ - if(sendreq->req_send.req_base.req_tag < 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); - } - } -#endif + SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); if( OPAL_LIKELY( rc >= OPAL_SUCCESS ) ) { if( OPAL_LIKELY( 1 == rc ) ) { @@ -829,32 +750,6 @@ int mca_pml_ob1_send_request_start_rdma( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RGET); - /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, sendreq->req_bytes_delivered, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ - -#ifdef SOFTWARE_EVENTS_ENABLE - volatile int64_t bytes_sent; - unsigned int i; - if(attached_event[OMPI_BYTES_SENT_USER] == 1){ - if(sendreq->req_send.req_base.req_tag >= 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); - } - } - if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ - if(sendreq->req_send.req_base.req_tag < 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); - } - } -#endif - if (OPAL_UNLIKELY(rc < 0)) { mca_bml_base_free(bml_btl, des); return rc; @@ -936,32 +831,6 @@ int mca_pml_ob1_send_request_start_rndv( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RNDV); - /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, sendreq->req_bytes_delivered, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ - -#ifdef SOFTWARE_EVENTS_ENABLE - volatile int64_t bytes_sent; - unsigned int i; - if(attached_event[OMPI_BYTES_SENT_USER] == 1){ - if(sendreq->req_send.req_base.req_tag >= 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); - } - } - if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ - if(sendreq->req_send.req_base.req_tag < 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); - } - } -#endif - if( OPAL_LIKELY( rc >= 0 ) ) { if( OPAL_LIKELY( 1 == rc ) ) { mca_pml_ob1_rndv_completion_request( bml_btl, sendreq, size ); @@ -1207,32 +1076,6 @@ mca_pml_ob1_send_request_schedule_once(mca_pml_ob1_send_request_t* sendreq) /* initiate send - note that this may complete before the call returns */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_FRAG); - /*SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, sendreq->req_bytes_delivered, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);*/ - -#ifdef SOFTWARE_EVENTS_ENABLE - volatile int64_t bytes_sent; - unsigned int i; - if(attached_event[OMPI_BYTES_SENT_USER] == 1){ - if(sendreq->req_send.req_base.req_tag >= 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, bytes_sent); - } - } - if(attached_event[OMPI_BYTES_SENT_MPI] == 1){ - if(sendreq->req_send.req_base.req_tag < 0){ - bytes_sent = 0; - for(i = 0; i < des->des_segment_count; i++){ - bytes_sent += des->des_segments[i].seg_len; - } - SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, bytes_sent); - } - } -#endif - if( OPAL_LIKELY(rc >= 0) ) { /* update state */ range->range_btls[btl_idx].length -= size; @@ -1305,6 +1148,8 @@ static void mca_pml_ob1_put_completion (mca_btl_base_module_t* btl, struct mca_b /* check for request completion */ OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, frag->rdma_length); + SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, frag->rdma_length, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); send_request_pml_complete_check(sendreq); } else { diff --git a/ompi/mpi/c/finalize.c b/ompi/mpi/c/finalize.c index b35751fcebf..02f21433c00 100644 --- a/ompi/mpi/c/finalize.c +++ b/ompi/mpi/c/finalize.c @@ -41,7 +41,6 @@ int MPI_Finalize(void) int i, j, rank, world_size, offset; long long *recv_buffer, *send_buffer; char *filename; - FILE *fptr; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &world_size); @@ -64,26 +63,19 @@ int MPI_Finalize(void) if(rank == 0){ asprintf(&filename, "sw_events_output_XXXXXX"); - filename = mktemp(filename); - fptr = fopen(filename, "w+"); - - fprintf(fptr, "%d %d\n", world_size, OMPI_NUM_COUNTERS); fprintf(stdout, "OMPI Software Counters:\n"); offset = 0; for(j = 0; j < world_size; j++){ fprintf(stdout, "World Rank %d:\n", j); - fprintf(fptr, "%d\n", j); for(i = 0; i < OMPI_NUM_COUNTERS; i++){ fprintf(stdout, "%s -> %lld\n", events[i].name, recv_buffer[offset+i]); - fprintf(fptr, "%s %lld\n", events[i].name, recv_buffer[offset+i]); } fprintf(stdout, "\n"); offset += OMPI_NUM_COUNTERS; } free(recv_buffer); free(send_buffer); - fclose(fptr); } else{ free(send_buffer); diff --git a/ompi/runtime/ompi_software_events.c b/ompi/runtime/ompi_software_events.c index 100dd51acbf..f7db5fea05b 100644 --- a/ompi/runtime/ompi_software_events.c +++ b/ompi/runtime/ompi_software_events.c @@ -23,8 +23,7 @@ OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { "OMPI_UNEXPECTED", "OMPI_OUT_OF_SEQUENCE", "OMPI_MATCH_TIME", - "OMPI_OOS_MATCH_TIME", - "OMPI_PROGRESS_SWITCH" + "OMPI_OOS_MATCH_TIME" }; OMPI_DECLSPEC const char *counter_descriptions[OMPI_NUM_COUNTERS] = { @@ -48,8 +47,7 @@ OMPI_DECLSPEC const char *counter_descriptions[OMPI_NUM_COUNTERS] = { "The number of messages that arrived as unexpected messages.", "The number of messages that arrived out of the proper sequence.", "The number of microseconds spent matching unexpected messages.", - "The number of microseconds spent matching out of sequence messages.", - "The number of times the progress thread changed." + "The number of microseconds spent matching out of sequence messages." }; /* An array of integer values to denote whether an event is activated (1) or not (0) */ @@ -381,29 +379,31 @@ void ompi_sw_event_fini() void ompi_sw_event_record(unsigned int event_id, long long value) { if(OPAL_UNLIKELY(attached_event[event_id] == 1)){ - OPAL_THREAD_ADD64(&events[event_id].value, value); + OPAL_THREAD_ADD64(&(events[event_id].value), value); } } -/* Starts microsecond-precision timer and stores the start value in usec */ -void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *usec) +/* Starts cycle-precision timer and stores the start value in 'cycles' */ +void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *cycles) { - /* Check whether usec == 0.0 to make sure the timer hasn't started yet */ - if(OPAL_UNLIKELY(attached_event[event_id] == 1 && *usec == 0)){ + /* Check whether cycles == 0.0 to make sure the timer hasn't started yet */ + if(OPAL_UNLIKELY(attached_event[event_id] == 1 && *cycles == 0)){ //*usec = opal_timer_base_get_cycles(); - *usec = opal_timer_base_get_usec(); + //*usec = opal_timer_base_get_usec(); + *cycles = opal_timer_base_get_cycles(); } } -/* Stops a microsecond-precision timer and calculates the total elapsed time - * based on the starting time in usec and putting the result in usec. +/* Stops a cycle-precision timer and calculates the total elapsed time + * based on the starting time in 'cycles' and putting the result in 'cycles'. */ -void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *usec) +void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *cycles) { if(OPAL_UNLIKELY(attached_event[event_id] == 1)){ //*usec = (opal_timer_base_get_cycles() - *usec) / sys_clock_freq_mhz; - *usec = opal_timer_base_get_usec() - *usec; - OPAL_THREAD_ADD64(&events[event_id].value, (long long)*usec); + //*usec = opal_timer_base_get_usec() - *usec; + *cycles = opal_timer_base_get_cycles() - *cycles; + OPAL_THREAD_ADD64(&events[event_id].value, (long long)*cycles); } } diff --git a/ompi/runtime/ompi_software_events.h b/ompi/runtime/ompi_software_events.h index 198b196f4e3..665ea746500 100644 --- a/ompi/runtime/ompi_software_events.h +++ b/ompi/runtime/ompi_software_events.h @@ -36,7 +36,6 @@ enum OMPI_COUNTERS{ OMPI_OUT_OF_SEQUENCE, OMPI_MATCH_TIME, OMPI_OOS_MATCH_TIME, - OMPI_PROGRESS_SWITCH, OMPI_NUM_COUNTERS }; diff --git a/ompi/runtime/papi_sde_interface.c b/ompi/runtime/papi_sde_interface.c index 7b0e86c83d2..4e8b6820156 100644 --- a/ompi/runtime/papi_sde_interface.c +++ b/ompi/runtime/papi_sde_interface.c @@ -10,7 +10,7 @@ OMPI_DECLSPEC papi_handle_t __attribute__((weak)) papi_sde_init(char *name_of_library, int *event_count) { - printf("weak papi_sde_init called from %s\n", __FILE__); + printf("Weak papi_sde_init called from %s. Weak functions will be called papi sde functionality. If you aren't using the papi sde component, disregard this message.\n", __FILE__); void * ptr = NULL; return ptr; } @@ -19,12 +19,12 @@ OMPI_DECLSPEC void __attribute__((weak)) papi_sde_register_counter(papi_handle_t handle, char *event_name, long long int *counter) { - printf("weak papi_sde_register_counter called from %s\n", __FILE__); + /*printf("weak papi_sde_register_counter called from %s\n", __FILE__);*/ } OMPI_DECLSPEC void __attribute__((weak)) papi_sde_describe_counter(papi_handle_t handle, char *event_name, char *event_description) { - printf("weak papi_sde_describe_counter called from %s\n", __FILE__); + /*printf("weak papi_sde_describe_counter called from %s\n", __FILE__);*/ } From e155e271de17952657abdccf9c0f711bc5e98977 Mon Sep 17 00:00:00 2001 From: David Eberius Date: Fri, 20 Oct 2017 16:27:12 -0400 Subject: [PATCH 05/12] Made compiling and using SPCs more streamlined. Added a --with-spc configure option to enable SPCs in the build. Added an MCA parameter, mpi_spc_enable, for turning on specific counters. Temporarily disabled PAPI sde component code. Changed OPAL_THREAD_ADD64 to OPAL_THREAD_ADD_FETCH_SIZE_T. Re-added out of sequence related counters. --- configure.ac | 18 ++ ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 22 +- ompi/mpi/c/finalize.c | 12 +- ompi/mpi/c/init.c | 4 +- ompi/runtime/ompi_mpi_params.c | 10 + ompi/runtime/ompi_software_events.c | 437 ++++++++-------------------- ompi/runtime/ompi_software_events.h | 66 ++--- ompi/runtime/params.h | 8 + 8 files changed, 205 insertions(+), 372 deletions(-) diff --git a/configure.ac b/configure.ac index 64eab61b8fa..2b6247b4ee0 100644 --- a/configure.ac +++ b/configure.ac @@ -287,6 +287,24 @@ AS_IF([test "$enable_oshmem" != "no"], [project_oshmem_amc=true], [project_oshme m4_ifndef([project_oshmem], [project_oshmem_amc=false]) AM_CONDITIONAL([PROJECT_OSHMEM], [test "$project_oshmem_amc" = "true"]) +# Enable/Disable Software-Based Performance Counters Capability +AC_ARG_ENABLE(spc, + AC_HELP_STRING([--enable-spc], + [Enable software-based performance counters capability (default: disabled)])) +if test "$enable_spc" = "yes"; then + AC_MSG_RESULT([yes]) + SOFTWARE_EVENTS_ENABLE=1 +else + AC_MSG_RESULT([no]) + SOFTWARE_EVENTS_ENABLE=0 +fi +AC_DEFINE_UNQUOTED([SOFTWARE_EVENTS_ENABLE], + [$SOFTWARE_EVENTS_ENABLE], + [If the software-based performance counters capability should be enabled.]) +AM_CONDITIONAL(SOFTWARE_EVENTS_ENABLE, test "$SOFTWARE_EVENTS_ENABLE" = "1") + +AS_IF([test "$enable_spc" != "no"], [project_spc_amc=true], [project_spc_amc=false]) + if test "$enable_binaries" = "no" && test "$enable_dist" = "yes"; then AC_MSG_WARN([--disable-binaries is incompatible with --enable dist]) AC_MSG_ERROR([Cannot continue]) diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index 491936fdbfb..dea21331d55 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -315,9 +315,16 @@ check_cantmatch_for_match(mca_pml_ob1_comm_proc_t *proc) { mca_pml_ob1_recv_frag_t *frag = proc->frags_cant_match; +#if SOFTWARE_EVENTS_ENABLE == 1 + opal_timer_t timer = 0; +#endif + SW_EVENT_TIMER_START(OMPI_OOS_MATCH_TIME, &timer); if( (NULL != frag) && (frag->hdr.hdr_match.hdr_seq == proc->expected_sequence) ) { - return remove_head_from_ordered_list(&proc->frags_cant_match); + mca_pml_ob1_recv_frag_t* ret = remove_head_from_ordered_list(&proc->frags_cant_match); + SW_EVENT_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); + return ret; } + SW_EVENT_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); return NULL; } @@ -389,6 +396,7 @@ void mca_pml_ob1_recv_frag_callback_match(mca_btl_base_module_t* btl, MCA_PML_OB1_RECV_FRAG_ALLOC(frag); MCA_PML_OB1_RECV_FRAG_INIT(frag, hdr, segments, num_segments, btl); append_frag_to_ordered_list(&proc->frags_cant_match, frag, proc->expected_sequence); + SW_EVENT_RECORD(OMPI_OUT_OF_SEQUENCE, 1); OB1_MATCHING_UNLOCK(&comm->matching_lock); return; } @@ -781,10 +789,10 @@ match_one(mca_btl_base_module_t *btl, mca_pml_ob1_comm_proc_t *proc, mca_pml_ob1_recv_frag_t* frag) { -#ifdef SOFTWARE_EVENTS_ENABLE - opal_timer_t usecs = 0; +#if SOFTWARE_EVENTS_ENABLE == 1 + opal_timer_t timer = 0; #endif - SW_EVENT_TIMER_START(OMPI_MATCH_TIME, &usecs); + SW_EVENT_TIMER_START(OMPI_MATCH_TIME, &timer); mca_pml_ob1_recv_request_t *match; mca_pml_ob1_comm_t *comm = (mca_pml_ob1_comm_t *)comm_ptr->c_pml_comm; @@ -823,14 +831,14 @@ match_one(mca_btl_base_module_t *btl, num_segments); /* this frag is already processed, so we want to break out of the loop and not end up back on the unexpected queue. */ - SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &usecs); + SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &timer); return NULL; } PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_MSG_MATCH_POSTED_REQ, &(match->req_recv.req_base), PERUSE_RECV); - SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &usecs); + SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &timer); return match; } @@ -843,7 +851,7 @@ match_one(mca_btl_base_module_t *btl, PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_INSERT_IN_UNEX_Q, comm_ptr, hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); - SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &usecs); + SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &timer); return NULL; } while(true); diff --git a/ompi/mpi/c/finalize.c b/ompi/mpi/c/finalize.c index 02f21433c00..a8e503d0050 100644 --- a/ompi/mpi/c/finalize.c +++ b/ompi/mpi/c/finalize.c @@ -37,10 +37,12 @@ static const char FUNC_NAME[] = "MPI_Finalize"; int MPI_Finalize(void) { -#ifdef SOFTWARE_EVENTS_ENABLE + /* If --with-spc was specified, print all of the final SPC values + * aggregated across the whole MPI run. + */ +#if SOFTWARE_EVENTS_ENABLE == 1 int i, j, rank, world_size, offset; long long *recv_buffer, *send_buffer; - char *filename; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &world_size); @@ -62,8 +64,6 @@ int MPI_Finalize(void) } if(rank == 0){ - asprintf(&filename, "sw_events_output_XXXXXX"); - fprintf(stdout, "OMPI Software Counters:\n"); offset = 0; for(j = 0; j < world_size; j++){ @@ -82,10 +82,6 @@ int MPI_Finalize(void) } MPI_Barrier(MPI_COMM_WORLD); - - /*SW_EVENT_PRINT_ALL();*/ - - /*SW_EVENT_FINI();*/ #endif OPAL_CR_FINALIZE_LIBRARY(); diff --git a/ompi/mpi/c/init.c b/ompi/mpi/c/init.c index 472e9a9efcc..da378dbf048 100644 --- a/ompi/mpi/c/init.c +++ b/ompi/mpi/c/init.c @@ -48,8 +48,6 @@ int MPI_Init(int *argc, char ***argv) char *env; int required = MPI_THREAD_SINGLE; - SW_EVENT_INIT(); - /* check for environment overrides for required thread level. If there is, check to see that it is a valid/supported thread level. If not, default to MPI_THREAD_MULTIPLE. */ @@ -86,5 +84,7 @@ int MPI_Init(int *argc, char ***argv) OPAL_CR_INIT_LIBRARY(); + SW_EVENT_INIT(); + return MPI_SUCCESS; } diff --git a/ompi/runtime/ompi_mpi_params.c b/ompi/runtime/ompi_mpi_params.c index f8376db633d..77a368d36f7 100644 --- a/ompi/runtime/ompi_mpi_params.c +++ b/ompi/runtime/ompi_mpi_params.c @@ -75,6 +75,8 @@ bool ompi_async_mpi_finalize = false; uint32_t ompi_add_procs_cutoff = OMPI_ADD_PROCS_CUTOFF_DEFAULT; bool ompi_mpi_dynamics_enabled = true; +char *ompi_mpi_spc_enable_string = NULL; + static bool show_default_mca_params = false; static bool show_file_mca_params = false; static bool show_enviro_mca_params = false; @@ -315,6 +317,14 @@ int ompi_mpi_register_params(void) MCA_BASE_VAR_SYN_FLAG_DEPRECATED); } + ompi_mpi_spc_enable_string = NULL; + (void) mca_base_var_register("ompi", "mpi", NULL, "spc_enable", + "A comma delimeted string listing the SPC counters to enable.", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_spc_enable_string); + return OMPI_SUCCESS; } diff --git a/ompi/runtime/ompi_software_events.c b/ompi/runtime/ompi_software_events.c index f7db5fea05b..ab3d90366ec 100644 --- a/ompi/runtime/ompi_software_events.c +++ b/ompi/runtime/ompi_software_events.c @@ -2,6 +2,10 @@ opal_timer_t sys_clock_freq_mhz = 0; +/* Array for converting from SPC indices to MPI_T indices */ +OMPI_DECLSPEC int mpi_t_indices[OMPI_NUM_COUNTERS] = {0}; + +/* Array of names for each counter. Used for MPI_T and PAPI sde initialization */ OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { "OMPI_SEND", "OMPI_RECV", @@ -26,6 +30,7 @@ OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { "OMPI_OOS_MATCH_TIME" }; +/* Array of descriptions for each counter. Used for MPI_T and PAPI sde initialization */ OMPI_DECLSPEC const char *counter_descriptions[OMPI_NUM_COUNTERS] = { "The number of times MPI_Send was called.", "The number of times MPI_Recv was called.", @@ -62,348 +67,184 @@ OMPI_DECLSPEC ompi_event_t *events = NULL; static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count) { (void)obj_handle; - if(MCA_BASE_PVAR_HANDLE_BIND == event) - *count = 1; - - return MPI_SUCCESS; -} -inline long long ompi_sw_event_get_counter(int counter_id) -{ - if(events != NULL) - return events[counter_id].value; - else - return 0; /* -1 would be preferred to indicate lack of initialization, but the type needs to be unsigned */ -} + int i; -static int ompi_sw_event_get_send(const struct mca_base_pvar_t *pvar, void *value, void *obj_handle) -{ - (void) obj_handle; - long long *counter_value = (long long*)value; - *counter_value = ompi_sw_event_get_counter(OMPI_SEND); + /* For this event, we need to set count to the number of long long type + * values for this counter. All SPC counters are one long long, so we + * always set count to 1. + */ + if(MCA_BASE_PVAR_HANDLE_BIND == event) + *count = 1; + /* For this event, we need to turn on the counter */ + else if(MCA_BASE_PVAR_HANDLE_START == event){ + /* Loop over the mpi_t_inddices array and find the correct SPC index to turn on */ + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + if(pvar->pvar_index == mpi_t_indices[i]){ + attached_event[i] = 1; + break; + } + } + } + /* For this event, we need to turn off the counter */ + else if(MCA_BASE_PVAR_HANDLE_STOP == event){ + /* Loop over the mpi_t_inddices array and find the correct SPC index to turn off */ + for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + if(pvar->pvar_index == mpi_t_indices[i]){ + attached_event[i] = 0; + break; + } + } + } return MPI_SUCCESS; } /* ############################################################## - * ############ Begin PAPI software_events Code ################# + * ################# Begin SPC Functions ######################## * ############################################################## */ -/* Allocates and initializes the events data structure */ -int iter_start() -{ - int i; - - if(events == NULL){ - events = (ompi_event_t*)malloc(OMPI_NUM_COUNTERS * sizeof(ompi_event_t)); - } else { - fprintf(stderr, "The events data structure has already been allocated.\n"); - } - - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - events[i].name = counter_names[i]; - events[i].value = 0; - } - return 0; -} - -/* Returns the name of the next event in the data structure */ -char* iter_next() -{ - static int i = 0; - - if(i < OMPI_NUM_COUNTERS){ - i++; - return events[i-1].name; - } - else{ - /* Finished iterating through the list. Return NULL and reset i */ - i = 0; - return NULL; - } -} - -/* Frees the events data structure */ -int iter_release() -{ - free(events); - return 0; -} - -/* If an event named 'event_name' exists, attach the corresponding event's value - * to the supplied long long pointer. +/* This function returns the current count of an SPC counter that has been retistered + * as an MPI_T pvar. The MPI_T index is not necessarily the same as the SPC index, + * so we need to convert from MPI_T index to SPC index and then set the 'value' argument + * to the correct value for this pvar. */ -int attach_event(char *event_name, long long **value) -{ - int i; - - if(events == NULL){ - fprintf(stderr, "Error: The iterator hasn't been started. The event cannot be attached.\n"); - return -1; - } +static int ompi_sw_event_get_count(const struct mca_base_pvar_t *pvar, void *value, void *obj_handle) +{ + (void) obj_handle; - if(event_name == NULL){ - fprintf(stderr, "Error: No event name specified for attach_event.\n"); - return -1; - } + int i; + long long *counter_value = (long long*)value; for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - if(strcmp(event_name, events[i].name) == 0){ - break; + if(pvar->pvar_index == mpi_t_indices[i]){ + /* If this is a timer-based counter, we need to convert from cycles to microseconds */ + if(i == OMPI_MATCH_TIME || i == OMPI_OOS_MATCH_TIME) + *counter_value = events[i].value / sys_clock_freq_mhz; + else + *counter_value = events[i].value; + return MPI_SUCCESS; } } - - if(i < OMPI_NUM_COUNTERS){ - *value = &events[i].value; - attached_event[i] = 1; - - return 0; - } - else{ - fprintf(stderr, "Error: Could not find an event by that name. The event cannot be attached.\n"); - return -1; - } + /* If all else fails, simply set value to 0 */ + *counter_value = 0; + return MPI_SUCCESS; } -/* If an event with the name 'event_name' exists, reset its value to 0 - * and set the corresponding value in attached_event to 0. - */ -int detach_event(char *event_name) +/* Initializes the events data structure and allocates memory for it if needed. */ +void events_init() { int i; + /* If the events data structure hasn't been allocated yet, allocate memory for it */ if(events == NULL){ - fprintf(stderr, "Error: The iterator hasn't been started. The event cannot be detached.\n"); - return -1; - } - - if(event_name == NULL){ - fprintf(stderr, "Error: No event name specified for detach_event.\n"); - return -1; + events = (ompi_event_t*)malloc(OMPI_NUM_COUNTERS * sizeof(ompi_event_t)); } - + /* The data structure has been allocated, so we simply initialize all of the counters + * with their names and an initial count of 0. + */ for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - if(strcmp(event_name, events[i].name) == 0){ - break; - } - } - - if(i < OMPI_NUM_COUNTERS){ - attached_event[i] = 0; + events[i].name = counter_names[i]; events[i].value = 0; - - return 0; - } - else{ - fprintf(stderr, "Error: Could not find an event by that name. The event cannot be detached.\n"); - return -1; - } -} - -/* A structure to expose to the PAPI software_events component to use these events */ -struct PAPI_SOFTWARE_EVENT_S papi_software_events = {"ompi", {0, 0, 0}, iter_start, iter_next, iter_release, attach_event, detach_event}; - -/* ############################################################## - * ############ End of PAPI software_events Code ################ - * ############################################################## - */ - -/* ############################################################## - * ############### Begin PAPI sde Code ########################## - * ############################################################## - */ - -/* An initialization function for the PAPI sde component. - * This creates an sde handle with the name OMPI and registers all events and - * event descriptions with the sde component. - */ -void ompi_sde_init() { - int i, event_count = OMPI_NUM_COUNTERS; - void *sde_handle = (void *)papi_sde_init("OMPI", &event_count); - - /* Required registration of counters and optional counter descriptions */ - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - //printf("Registering: %s (%d of %d)\n", counter_names[i], i, OMPI_NUM_COUNTERS); - papi_sde_register_counter(sde_handle, counter_names[i], &(events[i].value) ); - papi_sde_describe_counter(sde_handle, counter_names[i], counter_descriptions[i]); } } -/* Define PAPI_DYNAMIC_SDE since we are assuming PAPI is linked dynamically. - * Note: In the future we should support both dynamic and static linking of PAPI. +/* Initializes the SPC data structures and registers all counters as MPI_T pvars. + * Turns on only the counters that were specified in the mpi_spc_enable MCA parameter. */ -#define PAPI_DYNAMIC_SDE -/* This function will be called from papi_native_avail to list all of the OMPI - * events with their names and descriptions. In order for the dynamic version - * to work, the environment variable PAPI_SHARED_LIB must contain the full path - * to the PAPI shared library like the following: - * /path/to/papi/install/lib/libpapi.so - * - * This function will use dlsym to get the appropriate functions for initializing - * the PAPI sde component's environment and register all of the events. - */ -void* papi_sde_hook_list_events(void) +void ompi_sw_event_init() { - int i, event_count = OMPI_NUM_COUNTERS; - char *error; - void *papi_handle; - void* (*sym_init)(char *name_of_library, int *event_count); - void (*sym_reg)( void *handle, char *event_name, long long *counter); - void (*sym_desc)(void *handle, char *event_name, char *event_description); - void *sde_handle = NULL; + int i, j, ret, found = 0, all_on = 0; - printf("papi_sde_hook_list_events\n"); + /* Initialize the clock frequency variable as the CPU's frequency in MHz */ + sys_clock_freq_mhz = opal_timer_base_get_freq() / 1000000; -#ifdef PAPI_DYNAMIC_SDE - printf("PAPI_DYNAMIC_SDE defined\n"); - fflush(stdout); + events_init(); - char *path_to_papi = getenv("PAPI_SHARED_LIB"); - if(path_to_papi == NULL) - return NULL; + /* Get the MCA params string of counters to turn on */ + char **arg_strings = opal_argv_split(ompi_mpi_spc_enable_string, ','); + int num_args = opal_argv_count(arg_strings); - printf("path_to_papi = %s\n", path_to_papi); - - papi_handle = dlopen(path_to_papi, RTLD_LOCAL | RTLD_LAZY); - if(!papi_handle){ - fputs(dlerror(), stderr); - exit(1); - } - printf("papi_handle opened\n"); - fflush(stdout); - - dlerror(); - sym_init = (void* (*)(char*, int*)) dlsym(papi_handle, "papi_sde_init"); - if((error = dlerror()) != NULL) { - fputs(error, stderr); - exit(1); - } - - sym_reg = (void (*)(void*, char*, long long int*)) dlsym(papi_handle, "papi_sde_register_counter"); - if((error = dlerror()) != NULL){ - fputs(error, stderr); - exit(1); - } - - sym_desc = (void (*)(void*, char*, char*)) dlsym(papi_handle, "papi_sde_describe_counter"); - if((error = dlerror()) != NULL){ - fputs(error, stderr); - exit(1); - } - - printf("symbols found\n"); - fflush(stdout); - - sde_handle = (void *) (*sym_init)("OMPI", &event_count); - printf("sde_handle opened\n"); - fflush(stdout); - if((error = dlerror()) != NULL){ - fputs(error, stderr); - exit(1); - } - - printf("sde_handle preparing to register\n"); - fflush(stdout); - - /* We need to register the counters so they can be printed in papi_native_avail - * Note: sde::: will be prepended to the names + /* If there is only one argument and it is 'all', then all counters + * should be turned on. If the size is 0, then no counters will be enabled. */ - iter_start(); - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - printf("Registering: %s (%d of %d)\n", counter_names[i], i+1, OMPI_NUM_COUNTERS); - (*sym_reg)(sde_handle, counter_names[i], &(events[i].value)); - (*sym_desc)(sde_handle, counter_names[i], counter_descriptions[i]); - events[i].value = 0; + if(num_args == 1){ + if(strcmp(arg_strings[0], "all") == 0) + all_on = 1; } -#endif - - printf("done papi_sde_hook_list_events %s %d\n", __FILE__, __LINE__); - return sde_handle; -} - -/* ############################################################## - * ############### End of PAPI sde Code ######################### - * ############################################################## - */ - -/* ############################################################## - * ############### Begin Utility Functions ###################### - * ############################################################## - */ - -/* Initializes the OMPI software events. The default functionality is to - * turn all of the counters on. - * Note: in the future, turning events on and off should be done through - * an MCA parameter. - */ -void ompi_sw_event_init() -{ - int i; - /* -#if OPAL_HAVE_SYS_TIMER_GET_CYCLES - printf("OPAL_HAVE_SYS_TIMER_GET_CYCLES defined\n"); -#endif -#if OPAL_HAVE_CLOCK_GETTIME - printf("OPAL_HAVE_CLOCK_GETTIME defined\n"); -#endif - printf("Clock Frequency: %d Hz\n", (int)opal_timer_base_get_freq()); - sys_clock_freq_mhz = 2300;//opal_timer_base_get_freq() / 1000000; - printf("Clock Frequency (converted): %d MHz\n", (int)sys_clock_freq_mhz); -*/ - iter_start(); - - /* Turn all counters on */ + /* Turn on only the counters that were specified in the MCA parameter */ for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - attached_event[i] = 1; + if(all_on) + attached_event[i] = 1; + else{ + /* Note: If no arguments were given, this will be skipped */ + for(j = 0; j < num_args && found < num_args; j++){ + if(strcmp(counter_names[i], arg_strings[j]) == 0){ + attached_event[i] = 1; + found++; + } + } + } + + /* Registers the current counter as an MPI_T pvar regardless of whether it's been turned on or not */ + ret = mca_base_pvar_register("ompi", "runtime", "software_events", counter_names[i], counter_descriptions[i], + OPAL_INFO_LVL_4, MPI_T_PVAR_CLASS_SIZE, + MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, NULL, MPI_T_BIND_NO_OBJECT, + MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS, + ompi_sw_event_get_count, NULL, ompi_sw_event_notify, NULL); + /* Initialize the mpi_t_indices array with the MPI_T indices. + * The array index indicates the SPC index, while the value indicates + * the MPI_T index. + */ + if(ret != OPAL_ERROR){ + mpi_t_indices[i] = ret; + } else{ + mpi_t_indices[i] = -1; + } } - /* - (void)mca_base_pvar_register("ompi", "runtime", "software_events", counter_names[OMPI_SEND], counter_descriptions[OMPI_SEND], - OPAL_INFO_LVL_4, MPI_T_PVAR_CLASS_SIZE, - MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, NULL, MPI_T_BIND_NO_OBJECT, - MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS, - ompi_sw_event_get_send, NULL, ompi_sw_event_notify, NULL); - */ - /* For initializing the PAPI sde component environment */ - ompi_sde_init(); } -/* Calls iter_release to free all of the OMPI software events data structures */ +/* Frees any dynamically alocated OMPI software events data structures */ void ompi_sw_event_fini() { - iter_release(); + free(events); } /* Records an update to a counter using an atomic add operation. */ void ompi_sw_event_record(unsigned int event_id, long long value) { + /* Denoted unlikely because counters will often be turned off. */ if(OPAL_UNLIKELY(attached_event[event_id] == 1)){ - OPAL_THREAD_ADD64(&(events[event_id].value), value); + OPAL_THREAD_ADD_FETCH_SIZE_T(&(events[event_id].value), value); } } -/* Starts cycle-precision timer and stores the start value in 'cycles' */ +/* Starts cycle-precision timer and stores the start value in the 'cycles' argument. + * Note: This assumes that the 'cycles' argument is initialized to 0 if the timer + * hasn't been started yet. + */ void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *cycles) { - /* Check whether cycles == 0.0 to make sure the timer hasn't started yet */ + /* Check whether cycles == 0.0 to make sure the timer hasn't started yet. + * This is denoted unlikely because the counters will often be turned off. + */ if(OPAL_UNLIKELY(attached_event[event_id] == 1 && *cycles == 0)){ - //*usec = opal_timer_base_get_cycles(); - //*usec = opal_timer_base_get_usec(); *cycles = opal_timer_base_get_cycles(); } } /* Stops a cycle-precision timer and calculates the total elapsed time - * based on the starting time in 'cycles' and putting the result in 'cycles'. + * based on the starting time in 'cycles' and stores the result in the + * 'cycles' argument. */ void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *cycles) { + /* This is denoted unlikely because the counters will often be turned off. */ if(OPAL_UNLIKELY(attached_event[event_id] == 1)){ - //*usec = (opal_timer_base_get_cycles() - *usec) / sys_clock_freq_mhz; - //*usec = opal_timer_base_get_usec() - *usec; *cycles = opal_timer_base_get_cycles() - *cycles; - OPAL_THREAD_ADD64(&events[event_id].value, (long long)*cycles); + OPAL_THREAD_ADD_FETCH_SIZE_T(&events[event_id].value, (long long)*cycles); } } @@ -418,45 +259,3 @@ void ompi_sw_event_user_or_mpi(int tag, long long value, unsigned int user_enum, SW_EVENT_RECORD(mpi_enum, value); } } - -/* A function to output the value of all of the counters. This is currently - * implemented in MPI_Finalize, but we need to find a better way for this to - * happen. - */ -void ompi_sw_event_print_all() -{ - /*int i, j, rank, world_size, offset; - long long *recv_buffer, *send_buffer; - - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &world_size); - - if(rank == 0){ - send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); - recv_buffer = (long long*)malloc(world_size * OMPI_NUM_COUNTERS * sizeof(long long)); - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - send_buffer[i] = events[i].value; - } - MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); - } - else{ - send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - send_buffer[i] = events[i].value; - } - MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); - } - - if(rank == 0){ - fprintf(stdout, "OMPI Software Counters:\n"); - offset = 0; - for(j = 0; j < world_size; j++){ - fprintf(stdout, "World Rank %d:\n", j); - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - fprintf(stdout, "%s\t%lld\n", counter_names[offset+i], events[offset+i].value); - } - offset += OMPI_NUM_COUNTERS; - } - }*/ -} - diff --git a/ompi/runtime/ompi_software_events.h b/ompi/runtime/ompi_software_events.h index 665ea746500..a0274f3df31 100644 --- a/ompi/runtime/ompi_software_events.h +++ b/ompi/runtime/ompi_software_events.h @@ -8,11 +8,33 @@ #include "ompi/include/mpi.h" #include "ompi/include/ompi_config.h" +#include "ompi/datatype/ompi_datatype.h" +#include "ompi/runtime/params.h" #include "opal/mca/timer/timer.h" #include "opal/mca/base/mca_base_pvar.h" +#include "opal/util/argv.h" #include MCA_timer_IMPLEMENTATION_HEADER +/* INSTRUCTIONS FOR ADDING COUNTERS + * 1.) Add a new counter name in the OMPI_COUNTERS enum before + * OMPI_NUM_COUNTERS below. + * 2.) Add corresponding counter name and descriptions to the + * counter_names and counter_descriptions arrays in + * ompi_software_events.c NOTE: The names and descriptions + * MUST be in the same array location as where you added the + * counter name in step 1. + * 3.) If this counter is based on a timer, add its enum name to + * the logic for timer-based counters in the ompi_sw_event_get_count + * function in ompi_software_events.c + * 4.) Instrument the Open MPI code base where it makes sense for + * your counter to be modified using the SW_EVENT_RECORD macro. + * Note: If your counter is timer-based you should use the + * SW_EVENT_TIMER_START and SW_EVENT_TIMER_STOP macros to record + * the time in cycles to then be converted to microseconds later + * in the ompi_sw_event_get_count function when requested by MPI_T + */ + /* This enumeration serves as event ids for the various events */ enum OMPI_COUNTERS{ OMPI_SEND, @@ -36,7 +58,7 @@ enum OMPI_COUNTERS{ OMPI_OUT_OF_SEQUENCE, OMPI_MATCH_TIME, OMPI_OOS_MATCH_TIME, - OMPI_NUM_COUNTERS + OMPI_NUM_COUNTERS /* This serves as the number of counters. It must be last. */ }; /* A structure for storing the event data */ @@ -45,31 +67,13 @@ typedef struct ompi_event_s{ long long value; } ompi_event_t; -/* Structure and helper functions for PAPI software_events component - * Note: This component is being superceded by the sde component. - */ -struct PAPI_SOFTWARE_EVENT_S{ - char name[32]; - int version[3]; - int (*iter_start)(void); - char* (*iter_next)(void); - int (*iter_release)(void); - int (*attach_event)(char*, long long**); - int (*detach_event)(char*); -}; - -int iter_start(void); -char* iter_next(void); -int iter_release(void); -int attach_event(char *name, long long **value); -int detach_event(char *name); - -/* End of PAPI software_events component stuff */ - OMPI_DECLSPEC extern unsigned int attached_event[OMPI_NUM_COUNTERS]; OMPI_DECLSPEC extern ompi_event_t *events; -/* OMPI software event utility functions */ +/* Events data structure initialization function */ +void events_init(void); + +/* OMPI software event (SPC) utility functions */ void ompi_sw_event_init(void); void ompi_sw_event_fini(void); void ompi_sw_event_record(unsigned int event_id, long long value); @@ -79,23 +83,13 @@ void ompi_sw_event_user_or_mpi(int tag, long long value, unsigned int user_enum, void ompi_sw_event_print_all(void); /* MPI_T utility functions */ - static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count); long long ompi_sw_event_get_counter(int counter_id); -static int ompi_sw_event_get_send(const struct mca_base_pvar_t *pvar, void *value, void *obj_handle); - -/* Functions for the PAPI sde component */ -void ompi_sde_init(void); -/* PAPI sde component interface functions */ -typedef void* papi_handle_t; - -/* This should be defined at build time through an MCA parameter */ -#define SOFTWARE_EVENTS_ENABLE -/* Macros for using the utility functions throughout the codebase. - * If SOFTWARE_EVENTS_ENABLE is not defined, the macros become no-ops. +/* Macros for using the software event utility functions throughout the codebase. + * If SOFTWARE_EVENTS_ENABLE is not 1, the macros become no-ops. */ -#ifdef SOFTWARE_EVENTS_ENABLE +#if SOFTWARE_EVENTS_ENABLE == 1 #define SW_EVENT_INIT() \ ompi_sw_event_init() diff --git a/ompi/runtime/params.h b/ompi/runtime/params.h index 5716e142523..399b4ac6da4 100644 --- a/ompi/runtime/params.h +++ b/ompi/runtime/params.h @@ -141,6 +141,14 @@ OMPI_DECLSPEC extern bool ompi_async_mpi_init; /* EXPERIMENTAL: do not perform an RTE barrier at the beginning of MPI_Finalize */ OMPI_DECLSPEC extern bool ompi_async_mpi_finalize; +/** + * Whether or not to print the MCA parameters to a file or to stdout + * + * If this argument is set then it is used when parameters are dumped + * when the mpi_show_mca_params is set. + */ +OMPI_DECLSPEC extern char * ompi_mpi_spc_enable_string; + /** * Register MCA parameters used by the MPI layer. From faf4a81beb7f2daae10a8c493066c39658a14be1 Mon Sep 17 00:00:00 2001 From: David Eberius Date: Thu, 14 Dec 2017 18:34:06 -0500 Subject: [PATCH 06/12] Renamed all of the sw_event code to spc for consistency. Fixed a bug where multithreaded runs would fail because the spc initialization happened before opal initialization. Made a better way to keep track of timer-based counters. Made the output in MPI_Finalize make more sense in cases where some counters are turned off. Added SPC_FINI() to MPI_Finalize and made some coding style/formatting changes. --- configure.ac | 10 +- ompi/mca/pml/ob1/pml_ob1.c | 8 +- ompi/mca/pml/ob1/pml_ob1_isend.c | 11 +- ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 26 ++-- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 37 ++--- ompi/mca/pml/ob1/pml_ob1_sendreq.c | 43 ++---- ompi/mpi/c/allgather.c | 4 +- ompi/mpi/c/allreduce.c | 4 +- ompi/mpi/c/alltoall.c | 4 +- ompi/mpi/c/bcast.c | 5 +- ompi/mpi/c/finalize.c | 36 +++-- ompi/mpi/c/gather.c | 4 +- ompi/mpi/c/init.c | 4 +- ompi/mpi/c/init_thread.c | 6 +- ompi/mpi/c/irecv.c | 5 +- ompi/mpi/c/isend.c | 4 +- ompi/mpi/c/recv.c | 4 +- ompi/mpi/c/reduce.c | 4 +- ompi/mpi/c/scatter.c | 4 +- ompi/mpi/c/send.c | 4 +- ompi/runtime/Makefile.am | 6 +- ompi/runtime/ompi_mpi_params.c | 8 +- ompi/runtime/ompi_software_events.h | 140 ----------------- .../{ompi_software_events.c => ompi_spc.c} | 96 +++++++----- ompi/runtime/ompi_spc.h | 141 ++++++++++++++++++ ompi/runtime/papi_sde_interface.c | 30 ---- ompi/runtime/papi_sde_interface.h | 15 -- ompi/runtime/params.h | 9 +- opal/runtime/Makefile.am | 1 - opal/threads/wait_sync.c | 4 +- 30 files changed, 315 insertions(+), 362 deletions(-) delete mode 100644 ompi/runtime/ompi_software_events.h rename ompi/runtime/{ompi_software_events.c => ompi_spc.c} (75%) create mode 100644 ompi/runtime/ompi_spc.h delete mode 100644 ompi/runtime/papi_sde_interface.c delete mode 100644 ompi/runtime/papi_sde_interface.h diff --git a/configure.ac b/configure.ac index 2b6247b4ee0..89e98f2d95b 100644 --- a/configure.ac +++ b/configure.ac @@ -293,15 +293,15 @@ AC_ARG_ENABLE(spc, [Enable software-based performance counters capability (default: disabled)])) if test "$enable_spc" = "yes"; then AC_MSG_RESULT([yes]) - SOFTWARE_EVENTS_ENABLE=1 + SPC_ENABLE=1 else AC_MSG_RESULT([no]) - SOFTWARE_EVENTS_ENABLE=0 + SPC_ENABLE=0 fi -AC_DEFINE_UNQUOTED([SOFTWARE_EVENTS_ENABLE], - [$SOFTWARE_EVENTS_ENABLE], +AC_DEFINE_UNQUOTED([SPC_ENABLE], + [$SPC_ENABLE], [If the software-based performance counters capability should be enabled.]) -AM_CONDITIONAL(SOFTWARE_EVENTS_ENABLE, test "$SOFTWARE_EVENTS_ENABLE" = "1") +AM_CONDITIONAL(SPC_ENABLE, test "$SPC_ENABLE" = "1") AS_IF([test "$enable_spc" != "no"], [project_spc_amc=true], [project_spc_amc=false]) diff --git a/ompi/mca/pml/ob1/pml_ob1.c b/ompi/mca/pml/ob1/pml_ob1.c index 5cab48ef6df..f29e6732051 100644 --- a/ompi/mca/pml/ob1/pml_ob1.c +++ b/ompi/mca/pml/ob1/pml_ob1.c @@ -36,7 +36,7 @@ #include "opal_stdint.h" #include "opal/mca/btl/btl.h" #include "opal/mca/btl/base/base.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #include "ompi/mca/pml/pml.h" #include "ompi/mca/pml/base/base.h" @@ -196,7 +196,9 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) mca_pml_ob1_recv_frag_t *frag, *next_frag; mca_pml_ob1_comm_proc_t* pml_proc; mca_pml_ob1_match_hdr_t* hdr; - opal_timer_t usecs = 0; +#if SPC_ENABLE == 1 + opal_timer_t timer = 0; +#endif if (NULL == pml_comm) { return OMPI_ERR_OUT_OF_RESOURCE; @@ -274,7 +276,7 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) goto add_fragment_to_unexpected; } } - SW_EVENT_TIMER_STOP(OMPI_OOS_MATCH_TIME, &usecs); + SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); } else { append_frag_to_ordered_list(&pml_proc->frags_cant_match, frag, pml_proc->expected_sequence); diff --git a/ompi/mca/pml/ob1/pml_ob1_isend.c b/ompi/mca/pml/ob1/pml_ob1_isend.c index 2095a00bc9f..5ab3a773d7c 100644 --- a/ompi/mca/pml/ob1/pml_ob1_isend.c +++ b/ompi/mca/pml/ob1/pml_ob1_isend.c @@ -28,7 +28,7 @@ #include "pml_ob1_sendreq.h" #include "pml_ob1_recvreq.h" #include "ompi/peruse/peruse-internal.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" /** * Single usage request. As we allow recursive calls (as an @@ -121,13 +121,8 @@ static inline int mca_pml_ob1_send_inline (const void *buf, size_t count, size, MCA_BTL_NO_ORDER, MCA_BTL_DES_FLAGS_PRIORITY | MCA_BTL_DES_FLAGS_BTL_OWNERSHIP, MCA_PML_OB1_HDR_TYPE_MATCH, NULL); - if(OPAL_LIKELY(rc == OPAL_SUCCESS)){ - if(tag >= 0){ - SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, size); - } - else{ - SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, size); - } + if(OPAL_LIKELY(rc == OPAL_SUCCESS)) { + SPC_USER_OR_MPI(tag, (long long)size, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); } if (count > 0) { diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index dea21331d55..f27abd2e1c1 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -39,7 +39,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/peruse/peruse-internal.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #include "pml_ob1.h" #include "pml_ob1_comm.h" @@ -324,7 +324,7 @@ check_cantmatch_for_match(mca_pml_ob1_comm_proc_t *proc) SW_EVENT_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); return ret; } - SW_EVENT_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); + SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); return NULL; } @@ -462,9 +462,8 @@ void mca_pml_ob1_recv_frag_callback_match(mca_btl_base_module_t* btl, &iov_count, &bytes_received ); match->req_bytes_received = bytes_received; - - SW_EVENT_USER_OR_MPI(match->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); - + SPC_USER_OR_MPI(match->req_recv.req_base.req_tag, (long long)bytes_received, + OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* * Unpacking finished, make the user buffer unaccessable again. */ @@ -789,10 +788,10 @@ match_one(mca_btl_base_module_t *btl, mca_pml_ob1_comm_proc_t *proc, mca_pml_ob1_recv_frag_t* frag) { -#if SOFTWARE_EVENTS_ENABLE == 1 +#if SPC_ENABLE == 1 opal_timer_t timer = 0; #endif - SW_EVENT_TIMER_START(OMPI_MATCH_TIME, &timer); + SPC_TIMER_START(OMPI_MATCH_TIME, &timer); mca_pml_ob1_recv_request_t *match; mca_pml_ob1_comm_t *comm = (mca_pml_ob1_comm_t *)comm_ptr->c_pml_comm; @@ -831,28 +830,23 @@ match_one(mca_btl_base_module_t *btl, num_segments); /* this frag is already processed, so we want to break out of the loop and not end up back on the unexpected queue. */ - SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &timer); - + SPC_TIMER_STOP(OMPI_MATCH_TIME, &timer); return NULL; } PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_MSG_MATCH_POSTED_REQ, &(match->req_recv.req_base), PERUSE_RECV); - SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &timer); - + SPC_TIMER_STOP(OMPI_MATCH_TIME, &timer); return match; } /* if no match found, place on unexpected queue */ append_frag_to_list(&proc->unexpected_frags, btl, hdr, segments, num_segments, frag); - - SW_EVENT_RECORD(OMPI_UNEXPECTED, 1); - + SPC_RECORD(OMPI_UNEXPECTED, 1); PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_INSERT_IN_UNEX_Q, comm_ptr, hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); - SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &timer); - + SPC_TIMER_STOP(OMPI_MATCH_TIME, &timer); return NULL; } while(true); } diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index bb11b77574f..ace333a4b5b 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -29,7 +29,7 @@ #include "opal/mca/mpool/mpool.h" #include "opal/util/arch.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #include "ompi/mca/pml/pml.h" #include "ompi/mca/bml/bml.h" #include "pml_ob1_comm.h" @@ -199,10 +199,9 @@ static void mca_pml_ob1_put_completion (mca_pml_ob1_rdma_frag_t *frag, int64_t r if (OPAL_LIKELY(0 < rdma_size)) { /* check completion status */ - OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, rdma_size); - SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)rdma_size, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); - + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)rdma_size, + OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); if (recv_request_pml_complete_check(recvreq) == false && recvreq->req_rdma_offset < recvreq->req_send_offset) { /* schedule additional rdma operations */ @@ -246,8 +245,7 @@ int mca_pml_ob1_recv_request_ack_send_btl( des->des_cbfunc = mca_pml_ob1_recv_ctl_completion; rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_ACK); - SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)size); - + SPC_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)size); if( OPAL_LIKELY( rc >= 0 ) ) { return OMPI_SUCCESS; } @@ -380,7 +378,8 @@ static void mca_pml_ob1_rget_completion (mca_btl_base_module_t* btl, struct mca_ } else { /* is receive request complete */ OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, frag->rdma_length); - SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)frag->rdma_length, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)frag->rdma_length, + OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* TODO: re-add order */ mca_pml_ob1_send_fin (recvreq->req_recv.req_base.req_proc, bml_btl, frag->rdma_hdr.hdr_rget.hdr_frag, @@ -436,10 +435,8 @@ static int mca_pml_ob1_recv_request_put_frag (mca_pml_ob1_rdma_frag_t *frag) /* send rdma request to peer */ rc = mca_bml_base_send (bml_btl, ctl, MCA_PML_OB1_HDR_TYPE_PUT); - /* Increment counter for bytes_put even though they probably haven't all been received yet */ - SW_EVENT_RECORD(OMPI_BYTES_PUT, frag->rdma_length); - + SPC_RECORD(OMPI_BYTES_PUT, frag->rdma_length); if (OPAL_UNLIKELY(rc < 0)) { mca_bml_base_free (bml_btl, ctl); return rc; @@ -481,10 +478,8 @@ int mca_pml_ob1_recv_request_get_frag (mca_pml_ob1_rdma_frag_t *frag) rc = mca_bml_base_get (bml_btl, frag->local_address, frag->remote_address, local_handle, (mca_btl_base_registration_handle_t *) frag->remote_handle, frag->rdma_length, 0, MCA_BTL_NO_ORDER, mca_pml_ob1_rget_completion, frag); - /* Increment counter for bytes_get even though they probably haven't all been received yet */ - SW_EVENT_RECORD(OMPI_BYTES_GET, frag->rdma_length); - + SPC_RECORD(OMPI_BYTES_GET, frag->rdma_length); if( OPAL_UNLIKELY(OMPI_SUCCESS > rc) ) { return mca_pml_ob1_recv_request_get_frag_failed (frag, OMPI_ERR_OUT_OF_RESOURCE); } @@ -540,8 +535,8 @@ void mca_pml_ob1_recv_request_progress_frag( mca_pml_ob1_recv_request_t* recvreq ); OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); - SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); - + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, + OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* check completion status */ if(recv_request_pml_complete_check(recvreq) == false && recvreq->req_rdma_offset < recvreq->req_send_offset) { @@ -619,8 +614,8 @@ void mca_pml_ob1_recv_request_frag_copy_finished( mca_btl_base_module_t* btl, des->des_cbfunc(NULL, NULL, des, 0); OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); - SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); - + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, + OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* check completion status */ if(recv_request_pml_complete_check(recvreq) == false && recvreq->req_rdma_offset < recvreq->req_send_offset) { @@ -834,7 +829,8 @@ void mca_pml_ob1_recv_request_progress_rndv( mca_pml_ob1_recv_request_t* recvreq recvreq->req_recv.req_base.req_datatype); ); OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); - SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, + OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); } /* check completion status */ if(recv_request_pml_complete_check(recvreq) == false && @@ -905,9 +901,8 @@ void mca_pml_ob1_recv_request_progress_match( mca_pml_ob1_recv_request_t* recvre * for this request. */ recvreq->req_bytes_received += bytes_received; - - SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); - + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, + OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); recv_request_pml_complete(recvreq); } diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index 93f06f0cd2b..589638862f3 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -29,7 +29,7 @@ #include "ompi_config.h" #include "opal/prefetch.h" #include "opal/mca/mpool/mpool.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #include "ompi/constants.h" #include "ompi/mca/pml/pml.h" #include "pml_ob1.h" @@ -206,8 +206,8 @@ mca_pml_ob1_rndv_completion_request( mca_bml_base_btl_t* bml_btl, } OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, req_bytes_delivered); - SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, req_bytes_delivered, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, req_bytes_delivered, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); /* advance the request */ OPAL_THREAD_ADD_FETCH32(&sendreq->req_state, -1); @@ -264,8 +264,8 @@ mca_pml_ob1_rget_completion (mca_pml_ob1_rdma_frag_t *frag, int64_t rdma_length) /* count bytes of user data actually delivered and check for request completion */ if (OPAL_LIKELY(0 < rdma_length)) { OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, (size_t) rdma_length); - SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, rdma_length, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, rdma_length, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); } send_request_pml_complete_check(sendreq); @@ -319,8 +319,8 @@ mca_pml_ob1_frag_completion( mca_btl_base_module_t* btl, OPAL_THREAD_ADD_FETCH32(&sendreq->req_pipeline_depth, -1); OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, req_bytes_delivered); - SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, req_bytes_delivered, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, req_bytes_delivered, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); if(send_request_pml_complete_check(sendreq) == false) { mca_pml_ob1_send_request_schedule(sendreq); @@ -356,7 +356,6 @@ mca_pml_ob1_copy_frag_completion( mca_btl_base_module_t* btl, * we just abort. In theory, a new queue could be created to hold this * fragment and then attempt to send it out on another BTL. */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_FRAG); - if(OPAL_UNLIKELY(rc < 0)) { opal_output(0, "%s:%d FATAL", __FILE__, __LINE__); ompi_rte_abort(-1, NULL); @@ -456,7 +455,6 @@ int mca_pml_ob1_send_request_start_buffered( /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RNDV); - if( OPAL_LIKELY( rc >= 0 ) ) { if( OPAL_LIKELY( 1 == rc ) ) { mca_pml_ob1_rndv_completion_request( bml_btl, sendreq, req_bytes_delivered); @@ -503,10 +501,10 @@ int mca_pml_ob1_send_request_start_copy( mca_pml_ob1_send_request_t* sendreq, MCA_BTL_DES_FLAGS_PRIORITY | MCA_BTL_DES_FLAGS_BTL_OWNERSHIP, MCA_PML_OB1_HDR_TYPE_MATCH, &des); - if( OPAL_LIKELY(OMPI_SUCCESS == rc) ) { /* signal request completion */ - SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); send_request_pml_complete(sendreq); return OMPI_SUCCESS; } @@ -577,10 +575,8 @@ int mca_pml_ob1_send_request_start_copy( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send_status(bml_btl, des, MCA_PML_OB1_HDR_TYPE_MATCH); - - SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); - + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); if( OPAL_LIKELY( rc >= OPAL_SUCCESS ) ) { if( OPAL_LIKELY( 1 == rc ) ) { mca_pml_ob1_match_completion_free_request( bml_btl, sendreq ); @@ -641,10 +637,8 @@ int mca_pml_ob1_send_request_start_prepare( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_MATCH); - - SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); - + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); if( OPAL_LIKELY( rc >= OPAL_SUCCESS ) ) { if( OPAL_LIKELY( 1 == rc ) ) { mca_pml_ob1_match_completion_free_request( bml_btl, sendreq ); @@ -749,7 +743,6 @@ int mca_pml_ob1_send_request_start_rdma( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RGET); - if (OPAL_UNLIKELY(rc < 0)) { mca_bml_base_free(bml_btl, des); return rc; @@ -830,7 +823,6 @@ int mca_pml_ob1_send_request_start_rndv( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_RNDV); - if( OPAL_LIKELY( rc >= 0 ) ) { if( OPAL_LIKELY( 1 == rc ) ) { mca_pml_ob1_rndv_completion_request( bml_btl, sendreq, size ); @@ -1075,7 +1067,6 @@ mca_pml_ob1_send_request_schedule_once(mca_pml_ob1_send_request_t* sendreq) /* initiate send - note that this may complete before the call returns */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_FRAG); - if( OPAL_LIKELY(rc >= 0) ) { /* update state */ range->range_btls[btl_idx].length -= size; @@ -1148,8 +1139,8 @@ static void mca_pml_ob1_put_completion (mca_btl_base_module_t* btl, struct mca_b /* check for request completion */ OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, frag->rdma_length); - SW_EVENT_USER_OR_MPI(sendreq->req_send.req_base.req_tag, frag->rdma_length, - OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, frag->rdma_length, + OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); send_request_pml_complete_check(sendreq); } else { @@ -1200,10 +1191,8 @@ int mca_pml_ob1_send_request_put_frag( mca_pml_ob1_rdma_frag_t *frag ) rc = mca_bml_base_put (bml_btl, frag->local_address, frag->remote_address, local_handle, (mca_btl_base_registration_handle_t *) frag->remote_handle, frag->rdma_length, 0, MCA_BTL_NO_ORDER, mca_pml_ob1_put_completion, frag); - /* Count the bytes put even though they probably haven't been sent yet */ - SW_EVENT_RECORD(OMPI_BYTES_PUT, frag->rdma_length); - + SPC_RECORD(OMPI_BYTES_PUT, frag->rdma_length); if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) { mca_pml_ob1_send_request_put_frag_failed (frag, rc); return rc; diff --git a/ompi/mpi/c/allgather.c b/ompi/mpi/c/allgather.c index 07d62deb282..66474dabf7e 100644 --- a/ompi/mpi/c/allgather.c +++ b/ompi/mpi/c/allgather.c @@ -32,7 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -50,7 +50,7 @@ int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int err; - SW_EVENT_RECORD(OMPI_ALLGATHER, 1); + SPC_RECORD(OMPI_ALLGATHER, 1); MEMCHECKER( int rank; diff --git a/ompi/mpi/c/allreduce.c b/ompi/mpi/c/allreduce.c index f485e202965..c8d97a185e9 100644 --- a/ompi/mpi/c/allreduce.c +++ b/ompi/mpi/c/allreduce.c @@ -31,7 +31,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,7 +48,7 @@ int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, { int err; - SW_EVENT_RECORD(OMPI_ALLREDUCE, 1); + SPC_RECORD(OMPI_ALLREDUCE, 1); MEMCHECKER( memchecker_datatype(datatype); diff --git a/ompi/mpi/c/alltoall.c b/ompi/mpi/c/alltoall.c index 5001293d117..ab734337a7c 100644 --- a/ompi/mpi/c/alltoall.c +++ b/ompi/mpi/c/alltoall.c @@ -33,7 +33,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -52,7 +52,7 @@ int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int err; size_t recvtype_size; - SW_EVENT_RECORD(OMPI_ALLTOALL, 1); + SPC_RECORD(OMPI_ALLTOALL, 1); MEMCHECKER( memchecker_comm(comm); diff --git a/ompi/mpi/c/bcast.c b/ompi/mpi/c/bcast.c index ea0613e4ad6..2f30cdc428c 100644 --- a/ompi/mpi/c/bcast.c +++ b/ompi/mpi/c/bcast.c @@ -26,7 +26,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -42,7 +42,7 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, { int err; - SW_EVENT_RECORD(OMPI_BCAST, 1); + SPC_RECORD(OMPI_BCAST, 1); MEMCHECKER( memchecker_datatype(datatype); @@ -112,6 +112,5 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, err = comm->c_coll->coll_bcast(buffer, count, datatype, root, comm, comm->c_coll->coll_bcast_module); - OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME); } diff --git a/ompi/mpi/c/finalize.c b/ompi/mpi/c/finalize.c index a8e503d0050..685cbef1b63 100644 --- a/ompi/mpi/c/finalize.c +++ b/ompi/mpi/c/finalize.c @@ -23,7 +23,7 @@ #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/params.h" #include "ompi/errhandler/errhandler.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -40,44 +40,52 @@ int MPI_Finalize(void) /* If --with-spc was specified, print all of the final SPC values * aggregated across the whole MPI run. */ -#if SOFTWARE_EVENTS_ENABLE == 1 +#if SPC_ENABLE == 1 int i, j, rank, world_size, offset; long long *recv_buffer, *send_buffer; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &world_size); - if(rank == 0){ + /* Aggregate all of the information on rank 0 using MPI_Gather on MPI_COMM_WORLD */ + if(rank == 0) { send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); recv_buffer = (long long*)malloc(world_size * OMPI_NUM_COUNTERS * sizeof(long long)); - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { send_buffer[i] = events[i].value; } MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); - } - else{ + } else { send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { send_buffer[i] = events[i].value; } MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); } - if(rank == 0){ + /* Once rank 0 has all of the information, print the aggregated counter values for each rank in order */ + if(rank == 0) { fprintf(stdout, "OMPI Software Counters:\n"); - offset = 0; - for(j = 0; j < world_size; j++){ + offset = 0; /* Offset into the recv_buffer for each rank */ + for(j = 0; j < world_size; j++) { fprintf(stdout, "World Rank %d:\n", j); - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - fprintf(stdout, "%s -> %lld\n", events[i].name, recv_buffer[offset+i]); + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { + if(attached_event[i]) { + /* If this is a timer-based counter, we need to covert from cycles to usecs */ + if(timer_event[i]) + SPC_CYCLES_TO_USECS(&recv_buffer[offset+i]); + fprintf(stdout, "%s -> %lld\n", events[i].name, recv_buffer[offset+i]); + } else { + fprintf(stdout, "%s -> Disabled\n", events[i].name); + } } fprintf(stdout, "\n"); offset += OMPI_NUM_COUNTERS; } free(recv_buffer); free(send_buffer); - } - else{ + SPC_FINI(); + } else { free(send_buffer); } diff --git a/ompi/mpi/c/gather.c b/ompi/mpi/c/gather.c index 4fd06446609..9a37f2e7b10 100644 --- a/ompi/mpi/c/gather.c +++ b/ompi/mpi/c/gather.c @@ -32,7 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -50,7 +50,7 @@ int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int err; - SW_EVENT_RECORD(OMPI_GATHER, 1); + SPC_RECORD(OMPI_GATHER, 1); MEMCHECKER( int rank; diff --git a/ompi/mpi/c/init.c b/ompi/mpi/c/init.c index da378dbf048..8c7f564f6fe 100644 --- a/ompi/mpi/c/init.c +++ b/ompi/mpi/c/init.c @@ -25,7 +25,7 @@ #include #include "opal/util/show_help.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #include "ompi/mpi/c/bindings.h" #include "ompi/communicator/communicator.h" #include "ompi/errhandler/errhandler.h" @@ -84,7 +84,7 @@ int MPI_Init(int *argc, char ***argv) OPAL_CR_INIT_LIBRARY(); - SW_EVENT_INIT(); + SPC_INIT(); return MPI_SUCCESS; } diff --git a/ompi/mpi/c/init_thread.c b/ompi/mpi/c/init_thread.c index 061d6d99c4b..c91e3d1ab56 100644 --- a/ompi/mpi/c/init_thread.c +++ b/ompi/mpi/c/init_thread.c @@ -26,7 +26,7 @@ #include "ompi_config.h" #include "opal/util/show_help.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/params.h" #include "ompi/communicator/communicator.h" @@ -49,8 +49,6 @@ int MPI_Init_thread(int *argc, char ***argv, int required, { int err; - SW_EVENT_INIT(); - ompi_hook_base_mpi_init_thread_top(argc, argv, required, provided); if ( MPI_PARAM_CHECK ) { @@ -84,6 +82,8 @@ int MPI_Init_thread(int *argc, char ***argv, int required, OPAL_CR_INIT_LIBRARY(); + SPC_INIT(); + ompi_hook_base_mpi_init_thread_bottom(argc, argv, required, provided); return MPI_SUCCESS; diff --git a/ompi/mpi/c/irecv.c b/ompi/mpi/c/irecv.c index 5b40bf0bf64..a4b5f05d837 100644 --- a/ompi/mpi/c/irecv.c +++ b/ompi/mpi/c/irecv.c @@ -27,7 +27,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -43,7 +43,7 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source, { int rc = MPI_SUCCESS; - SW_EVENT_RECORD(OMPI_IRECV, 1); + SPC_RECORD(OMPI_IRECV, 1); MEMCHECKER( memchecker_datatype(type); @@ -80,6 +80,5 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source, memchecker_call(&opal_memchecker_base_mem_noaccess, buf, count, type); ); rc = MCA_PML_CALL(irecv(buf,count,type,source,tag,comm,request)); - OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/isend.c b/ompi/mpi/c/isend.c index fe808f3e4a4..1b145193607 100644 --- a/ompi/mpi/c/isend.c +++ b/ompi/mpi/c/isend.c @@ -31,7 +31,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -47,7 +47,7 @@ int MPI_Isend(const void *buf, int count, MPI_Datatype type, int dest, { int rc = MPI_SUCCESS; - SW_EVENT_RECORD(OMPI_ISEND, 1); + SPC_RECORD(OMPI_ISEND, 1); MEMCHECKER( memchecker_datatype(type); diff --git a/ompi/mpi/c/recv.c b/ompi/mpi/c/recv.c index 118ca9e8395..dc35792bde2 100644 --- a/ompi/mpi/c/recv.c +++ b/ompi/mpi/c/recv.c @@ -27,7 +27,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/memchecker.h" #include "ompi/request/request.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -43,7 +43,7 @@ int MPI_Recv(void *buf, int count, MPI_Datatype type, int source, { int rc = MPI_SUCCESS; - SW_EVENT_RECORD(OMPI_RECV, 1); + SPC_RECORD(OMPI_RECV, 1); MEMCHECKER( memchecker_datatype(type); diff --git a/ompi/mpi/c/reduce.c b/ompi/mpi/c/reduce.c index 76e0354a023..96256f7e257 100644 --- a/ompi/mpi/c/reduce.c +++ b/ompi/mpi/c/reduce.c @@ -31,7 +31,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,7 +48,7 @@ int MPI_Reduce(const void *sendbuf, void *recvbuf, int count, { int err; - SW_EVENT_RECORD(OMPI_REDUCE, 1); + SPC_RECORD(OMPI_REDUCE, 1); MEMCHECKER( memchecker_datatype(datatype); diff --git a/ompi/mpi/c/scatter.c b/ompi/mpi/c/scatter.c index 3564d233282..8cad2d01adc 100644 --- a/ompi/mpi/c/scatter.c +++ b/ompi/mpi/c/scatter.c @@ -32,7 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -50,7 +50,7 @@ int MPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int err; - SW_EVENT_RECORD(OMPI_SCATTER, 1); + SPC_RECORD(OMPI_SCATTER, 1); MEMCHECKER( memchecker_comm(comm); diff --git a/ompi/mpi/c/send.c b/ompi/mpi/c/send.c index b85b6803657..42a2eb345de 100644 --- a/ompi/mpi/c/send.c +++ b/ompi/mpi/c/send.c @@ -30,7 +30,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -#include "ompi/runtime/ompi_software_events.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -46,7 +46,7 @@ int MPI_Send(const void *buf, int count, MPI_Datatype type, int dest, { int rc = MPI_SUCCESS; - SW_EVENT_RECORD(OMPI_SEND, 1); + SPC_RECORD(OMPI_SEND, 1); MEMCHECKER( memchecker_datatype(type); diff --git a/ompi/runtime/Makefile.am b/ompi/runtime/Makefile.am index 0aa5e999c32..2108ad97cbf 100644 --- a/ompi/runtime/Makefile.am +++ b/ompi/runtime/Makefile.am @@ -28,8 +28,7 @@ headers += \ runtime/ompi_cr.h \ runtime/params.h \ runtime/ompi_info_support.h \ - runtime/ompi_software_events.h \ - runtime/papi_sde_interface.h + runtime/ompi_spc.h lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ runtime/ompi_mpi_abort.c \ @@ -40,5 +39,4 @@ lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ runtime/ompi_mpi_preconnect.c \ runtime/ompi_cr.c \ runtime/ompi_info_support.c \ - runtime/ompi_software_events.c \ - runtime/papi_sde_interface.c + runtime/ompi_spc.c diff --git a/ompi/runtime/ompi_mpi_params.c b/ompi/runtime/ompi_mpi_params.c index 77a368d36f7..49490d3d4ef 100644 --- a/ompi/runtime/ompi_mpi_params.c +++ b/ompi/runtime/ompi_mpi_params.c @@ -75,7 +75,7 @@ bool ompi_async_mpi_finalize = false; uint32_t ompi_add_procs_cutoff = OMPI_ADD_PROCS_CUTOFF_DEFAULT; bool ompi_mpi_dynamics_enabled = true; -char *ompi_mpi_spc_enable_string = NULL; +char *ompi_mpi_spc_attach_string = NULL; static bool show_default_mca_params = false; static bool show_file_mca_params = false; @@ -317,13 +317,13 @@ int ompi_mpi_register_params(void) MCA_BASE_VAR_SYN_FLAG_DEPRECATED); } - ompi_mpi_spc_enable_string = NULL; - (void) mca_base_var_register("ompi", "mpi", NULL, "spc_enable", + ompi_mpi_spc_attach_string = NULL; + (void) mca_base_var_register("ompi", "mpi", NULL, "spc_attach", "A comma delimeted string listing the SPC counters to enable.", MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY, - &ompi_mpi_spc_enable_string); + &ompi_mpi_spc_attach_string); return OMPI_SUCCESS; } diff --git a/ompi/runtime/ompi_software_events.h b/ompi/runtime/ompi_software_events.h deleted file mode 100644 index a0274f3df31..00000000000 --- a/ompi/runtime/ompi_software_events.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef OMPI_SOFTWARE_EVENT -#define OMPI_SOFTWARE_EVENT - -#include -#include -#include -#include - -#include "ompi/include/mpi.h" -#include "ompi/include/ompi_config.h" -#include "ompi/datatype/ompi_datatype.h" -#include "ompi/runtime/params.h" -#include "opal/mca/timer/timer.h" -#include "opal/mca/base/mca_base_pvar.h" -#include "opal/util/argv.h" - -#include MCA_timer_IMPLEMENTATION_HEADER - -/* INSTRUCTIONS FOR ADDING COUNTERS - * 1.) Add a new counter name in the OMPI_COUNTERS enum before - * OMPI_NUM_COUNTERS below. - * 2.) Add corresponding counter name and descriptions to the - * counter_names and counter_descriptions arrays in - * ompi_software_events.c NOTE: The names and descriptions - * MUST be in the same array location as where you added the - * counter name in step 1. - * 3.) If this counter is based on a timer, add its enum name to - * the logic for timer-based counters in the ompi_sw_event_get_count - * function in ompi_software_events.c - * 4.) Instrument the Open MPI code base where it makes sense for - * your counter to be modified using the SW_EVENT_RECORD macro. - * Note: If your counter is timer-based you should use the - * SW_EVENT_TIMER_START and SW_EVENT_TIMER_STOP macros to record - * the time in cycles to then be converted to microseconds later - * in the ompi_sw_event_get_count function when requested by MPI_T - */ - -/* This enumeration serves as event ids for the various events */ -enum OMPI_COUNTERS{ - OMPI_SEND, - OMPI_RECV, - OMPI_ISEND, - OMPI_IRECV, - OMPI_BCAST, - OMPI_REDUCE, - OMPI_ALLREDUCE, - OMPI_SCATTER, - OMPI_GATHER, - OMPI_ALLTOALL, - OMPI_ALLGATHER, - OMPI_BYTES_RECEIVED_USER, - OMPI_BYTES_RECEIVED_MPI, - OMPI_BYTES_SENT_USER, - OMPI_BYTES_SENT_MPI, - OMPI_BYTES_PUT, - OMPI_BYTES_GET, - OMPI_UNEXPECTED, - OMPI_OUT_OF_SEQUENCE, - OMPI_MATCH_TIME, - OMPI_OOS_MATCH_TIME, - OMPI_NUM_COUNTERS /* This serves as the number of counters. It must be last. */ -}; - -/* A structure for storing the event data */ -typedef struct ompi_event_s{ - char *name; - long long value; -} ompi_event_t; - -OMPI_DECLSPEC extern unsigned int attached_event[OMPI_NUM_COUNTERS]; -OMPI_DECLSPEC extern ompi_event_t *events; - -/* Events data structure initialization function */ -void events_init(void); - -/* OMPI software event (SPC) utility functions */ -void ompi_sw_event_init(void); -void ompi_sw_event_fini(void); -void ompi_sw_event_record(unsigned int event_id, long long value); -void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *usec); -void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *usec); -void ompi_sw_event_user_or_mpi(int tag, long long value, unsigned int user_enum, unsigned int mpi_enum); -void ompi_sw_event_print_all(void); - -/* MPI_T utility functions */ -static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count); -long long ompi_sw_event_get_counter(int counter_id); - -/* Macros for using the software event utility functions throughout the codebase. - * If SOFTWARE_EVENTS_ENABLE is not 1, the macros become no-ops. - */ -#if SOFTWARE_EVENTS_ENABLE == 1 - -#define SW_EVENT_INIT() \ - ompi_sw_event_init() - -#define SW_EVENT_FINI() \ - ompi_sw_event_fini() - -#define SW_EVENT_RECORD(event_id, value) \ - ompi_sw_event_record(event_id, value) - -#define SW_EVENT_TIMER_START(event_id, usec) \ - ompi_sw_event_timer_start(event_id, usec) - -#define SW_EVENT_TIMER_STOP(event_id, usec) \ - ompi_sw_event_timer_stop(event_id, usec) - -#define SW_EVENT_USER_OR_MPI(tag, value, enum_if_user, enum_if_mpi) \ - ompi_sw_event_user_or_mpi(tag, value, enum_if_user, enum_if_mpi) - -#define SW_EVENT_PRINT_ALL() \ - ompi_sw_event_print_all() - -#else /* Software events are not enabled */ - -#define SW_EVENT_INIT() \ - do {} while (0) - -#define SW_EVENT_FINI() \ - do {} while (0) - -#define SW_EVENT_RECORD(event_id, value) \ - do {} while (0) - -#define SW_EVENT_TIMER_START(event_id, usec) \ - do {} while (0) - -#define SW_EVENT_TIMER_STOP(event_id, usec) \ - do {} while (0) - -#define SW_EVENT_USER_OR_MPI(tag, value, enum_if_user, enum_if_mpi) \ - do {} while (0) - -#define SW_EVENT_PRINT_ALL() \ - do {} while (0) - -#endif - -#endif diff --git a/ompi/runtime/ompi_software_events.c b/ompi/runtime/ompi_spc.c similarity index 75% rename from ompi/runtime/ompi_software_events.c rename to ompi/runtime/ompi_spc.c index ab3d90366ec..9f57356d23c 100644 --- a/ompi/runtime/ompi_software_events.c +++ b/ompi/runtime/ompi_spc.c @@ -1,4 +1,4 @@ -#include "ompi_software_events.h" +#include "ompi_spc.h" opal_timer_t sys_clock_freq_mhz = 0; @@ -57,6 +57,8 @@ OMPI_DECLSPEC const char *counter_descriptions[OMPI_NUM_COUNTERS] = { /* An array of integer values to denote whether an event is activated (1) or not (0) */ OMPI_DECLSPEC unsigned int attached_event[OMPI_NUM_COUNTERS] = { 0 }; +/* An array of integer values to denote whether an event is timer-based (1) or not (0) */ +OMPI_DECLSPEC unsigned int timer_event[OMPI_NUM_COUNTERS] = { 0 }; /* An array of event structures to store the event data (name and value) */ OMPI_DECLSPEC ompi_event_t *events = NULL; @@ -64,7 +66,7 @@ OMPI_DECLSPEC ompi_event_t *events = NULL; * ################# Begin MPI_T Functions ###################### * ############################################################## */ -static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count) +static int ompi_spc_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count) { (void)obj_handle; @@ -77,20 +79,20 @@ static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t eve if(MCA_BASE_PVAR_HANDLE_BIND == event) *count = 1; /* For this event, we need to turn on the counter */ - else if(MCA_BASE_PVAR_HANDLE_START == event){ + else if(MCA_BASE_PVAR_HANDLE_START == event) { /* Loop over the mpi_t_inddices array and find the correct SPC index to turn on */ - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - if(pvar->pvar_index == mpi_t_indices[i]){ + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { + if(pvar->pvar_index == mpi_t_indices[i]) { attached_event[i] = 1; break; } } } /* For this event, we need to turn off the counter */ - else if(MCA_BASE_PVAR_HANDLE_STOP == event){ + else if(MCA_BASE_PVAR_HANDLE_STOP == event) { /* Loop over the mpi_t_inddices array and find the correct SPC index to turn off */ - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - if(pvar->pvar_index == mpi_t_indices[i]){ + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { + if(pvar->pvar_index == mpi_t_indices[i]) { attached_event[i] = 0; break; } @@ -110,17 +112,17 @@ static int ompi_sw_event_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t eve * so we need to convert from MPI_T index to SPC index and then set the 'value' argument * to the correct value for this pvar. */ -static int ompi_sw_event_get_count(const struct mca_base_pvar_t *pvar, void *value, void *obj_handle) +static int ompi_spc_get_count(const struct mca_base_pvar_t *pvar, void *value, void *obj_handle) { (void) obj_handle; int i; long long *counter_value = (long long*)value; - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ - if(pvar->pvar_index == mpi_t_indices[i]){ + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { + if(pvar->pvar_index == mpi_t_indices[i]) { /* If this is a timer-based counter, we need to convert from cycles to microseconds */ - if(i == OMPI_MATCH_TIME || i == OMPI_OOS_MATCH_TIME) + if(timer_event[i]) *counter_value = events[i].value / sys_clock_freq_mhz; else *counter_value = events[i].value; @@ -138,22 +140,22 @@ void events_init() int i; /* If the events data structure hasn't been allocated yet, allocate memory for it */ - if(events == NULL){ + if(events == NULL) { events = (ompi_event_t*)malloc(OMPI_NUM_COUNTERS * sizeof(ompi_event_t)); } /* The data structure has been allocated, so we simply initialize all of the counters * with their names and an initial count of 0. */ - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { events[i].name = counter_names[i]; events[i].value = 0; } } /* Initializes the SPC data structures and registers all counters as MPI_T pvars. - * Turns on only the counters that were specified in the mpi_spc_enable MCA parameter. + * Turns on only the counters that were specified in the mpi_spc_attach MCA parameter. */ -void ompi_sw_event_init() +void ompi_spc_init() { int i, j, ret, found = 0, all_on = 0; @@ -163,60 +165,71 @@ void ompi_sw_event_init() events_init(); /* Get the MCA params string of counters to turn on */ - char **arg_strings = opal_argv_split(ompi_mpi_spc_enable_string, ','); + char **arg_strings = opal_argv_split(ompi_mpi_spc_attach_string, ','); int num_args = opal_argv_count(arg_strings); /* If there is only one argument and it is 'all', then all counters * should be turned on. If the size is 0, then no counters will be enabled. */ - if(num_args == 1){ + if(num_args == 1) { if(strcmp(arg_strings[0], "all") == 0) all_on = 1; } /* Turn on only the counters that were specified in the MCA parameter */ - for(i = 0; i < OMPI_NUM_COUNTERS; i++){ + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { if(all_on) attached_event[i] = 1; - else{ + else { /* Note: If no arguments were given, this will be skipped */ - for(j = 0; j < num_args && found < num_args; j++){ - if(strcmp(counter_names[i], arg_strings[j]) == 0){ + for(j = 0; j < num_args && found < num_args; j++) { + if(strcmp(counter_names[i], arg_strings[j]) == 0) { attached_event[i] = 1; found++; } } } + /* ######################################################################## + * ################## Add Timer-Based Counter Enums Here ################## + * ######################################################################## + */ + /* If this is a timer event, sent the corresponding timer_event entry to 1 */ + if(i == OMPI_MATCH_TIME || i == OMPI_OOS_MATCH_TIME) + timer_event[i] = 1; + else + timer_event[i] = 0; + /* Registers the current counter as an MPI_T pvar regardless of whether it's been turned on or not */ - ret = mca_base_pvar_register("ompi", "runtime", "software_events", counter_names[i], counter_descriptions[i], + ret = mca_base_pvar_register("ompi", "runtime", "spc", counter_names[i], counter_descriptions[i], OPAL_INFO_LVL_4, MPI_T_PVAR_CLASS_SIZE, MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, NULL, MPI_T_BIND_NO_OBJECT, MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS, - ompi_sw_event_get_count, NULL, ompi_sw_event_notify, NULL); + ompi_spc_get_count, NULL, ompi_spc_notify, NULL); + /* Initialize the mpi_t_indices array with the MPI_T indices. * The array index indicates the SPC index, while the value indicates * the MPI_T index. */ - if(ret != OPAL_ERROR){ + if(ret != OPAL_ERROR) { mpi_t_indices[i] = ret; - } else{ + } else { mpi_t_indices[i] = -1; } } } -/* Frees any dynamically alocated OMPI software events data structures */ -void ompi_sw_event_fini() +/* Frees any dynamically alocated OMPI SPC data structures */ +void ompi_spc_fini() { free(events); } /* Records an update to a counter using an atomic add operation. */ -void ompi_sw_event_record(unsigned int event_id, long long value) +void ompi_spc_record(unsigned int event_id, long long value) { /* Denoted unlikely because counters will often be turned off. */ - if(OPAL_UNLIKELY(attached_event[event_id] == 1)){ + if(OPAL_UNLIKELY(attached_event[event_id] == 1)) { OPAL_THREAD_ADD_FETCH_SIZE_T(&(events[event_id].value), value); } } @@ -225,12 +238,12 @@ void ompi_sw_event_record(unsigned int event_id, long long value) * Note: This assumes that the 'cycles' argument is initialized to 0 if the timer * hasn't been started yet. */ -void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *cycles) +void ompi_spc_timer_start(unsigned int event_id, opal_timer_t *cycles) { /* Check whether cycles == 0.0 to make sure the timer hasn't started yet. * This is denoted unlikely because the counters will often be turned off. */ - if(OPAL_UNLIKELY(attached_event[event_id] == 1 && *cycles == 0)){ + if(OPAL_UNLIKELY(attached_event[event_id] == 1 && *cycles == 0)) { *cycles = opal_timer_base_get_cycles(); } } @@ -239,10 +252,10 @@ void ompi_sw_event_timer_start(unsigned int event_id, opal_timer_t *cycles) * based on the starting time in 'cycles' and stores the result in the * 'cycles' argument. */ -void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *cycles) +void ompi_spc_timer_stop(unsigned int event_id, opal_timer_t *cycles) { /* This is denoted unlikely because the counters will often be turned off. */ - if(OPAL_UNLIKELY(attached_event[event_id] == 1)){ + if(OPAL_UNLIKELY(attached_event[event_id] == 1)) { *cycles = opal_timer_base_get_cycles() - *cycles; OPAL_THREAD_ADD_FETCH_SIZE_T(&events[event_id].value, (long long)*cycles); } @@ -251,11 +264,18 @@ void ompi_sw_event_timer_stop(unsigned int event_id, opal_timer_t *cycles) /* Checks a tag, and records the user version of the counter if it's greater * than or equal to 0 and records the mpi version of the counter otherwise. */ -void ompi_sw_event_user_or_mpi(int tag, long long value, unsigned int user_enum, unsigned int mpi_enum) +void ompi_spc_user_or_mpi(int tag, long long value, unsigned int user_enum, unsigned int mpi_enum) { - if(tag >= 0){ - SW_EVENT_RECORD(user_enum, value); + if(tag >= 0) { + SPC_RECORD(user_enum, value); } else { - SW_EVENT_RECORD(mpi_enum, value); + SPC_RECORD(mpi_enum, value); } } + +/* Converts a counter value that is in cycles to microseconds. + */ +void ompi_spc_cycles_to_usecs(long long *cycles) +{ + *cycles = *cycles / sys_clock_freq_mhz; +} diff --git a/ompi/runtime/ompi_spc.h b/ompi/runtime/ompi_spc.h new file mode 100644 index 00000000000..e7bb41ae86d --- /dev/null +++ b/ompi/runtime/ompi_spc.h @@ -0,0 +1,141 @@ +#ifndef OMPI_SPC +#define OMPI_SPC + +#include +#include +#include +#include + +#include "ompi/include/mpi.h" +#include "ompi/include/ompi_config.h" +#include "ompi/datatype/ompi_datatype.h" +#include "ompi/runtime/params.h" +#include "opal/mca/timer/timer.h" +#include "opal/mca/base/mca_base_pvar.h" +#include "opal/util/argv.h" + +#include MCA_timer_IMPLEMENTATION_HEADER + +/* INSTRUCTIONS FOR ADDING COUNTERS + * 1.) Add a new counter name in the OMPI_COUNTERS enum before + * OMPI_NUM_COUNTERS below. + * 2.) Add corresponding counter name and descriptions to the + * counter_names and counter_descriptions arrays in + * ompi_spc.c NOTE: The names and descriptions + * MUST be in the same array location as where you added the + * counter name in step 1. + * 3.) If this counter is based on a timer, add its enum name to + * the logic for timer-based counters in the ompi_spc_init + * function in ompi_spc.c + * 4.) Instrument the Open MPI code base where it makes sense for + * your counter to be modified using the SPC_RECORD macro. + * Note: If your counter is timer-based you should use the + * SPC_TIMER_START and SPC_TIMER_STOP macros to record + * the time in cycles to then be converted to microseconds later + * in the ompi_spc_get_count function when requested by MPI_T + */ + +/* This enumeration serves as event ids for the various events */ +enum OMPI_COUNTERS{ + OMPI_SEND, + OMPI_RECV, + OMPI_ISEND, + OMPI_IRECV, + OMPI_BCAST, + OMPI_REDUCE, + OMPI_ALLREDUCE, + OMPI_SCATTER, + OMPI_GATHER, + OMPI_ALLTOALL, + OMPI_ALLGATHER, + OMPI_BYTES_RECEIVED_USER, + OMPI_BYTES_RECEIVED_MPI, + OMPI_BYTES_SENT_USER, + OMPI_BYTES_SENT_MPI, + OMPI_BYTES_PUT, + OMPI_BYTES_GET, + OMPI_UNEXPECTED, + OMPI_OUT_OF_SEQUENCE, + OMPI_MATCH_TIME, + OMPI_OOS_MATCH_TIME, + OMPI_NUM_COUNTERS /* This serves as the number of counters. It must be last. */ +}; + +/* A structure for storing the event data */ +typedef struct ompi_event_s{ + char *name; + long long value; +} ompi_event_t; + +OMPI_DECLSPEC extern unsigned int attached_event[OMPI_NUM_COUNTERS]; +OMPI_DECLSPEC extern unsigned int timer_event[OMPI_NUM_COUNTERS]; +OMPI_DECLSPEC extern ompi_event_t *events; + +/* Events data structure initialization function */ +void events_init(void); + +/* OMPI SPC utility functions */ +void ompi_spc_init(void); +void ompi_spc_fini(void); +void ompi_spc_record(unsigned int event_id, long long value); +void ompi_spc_timer_start(unsigned int event_id, opal_timer_t *cycles); +void ompi_spc_timer_stop(unsigned int event_id, opal_timer_t *cycles); +void ompi_spc_user_or_mpi(int tag, long long value, unsigned int user_enum, unsigned int mpi_enum); +void ompi_spc_cycles_to_usecs(long long *cycles); + +/* MPI_T utility functions */ +static int ompi_spc_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count); +long long ompi_spc_get_counter(int counter_id); + +/* Macros for using the SPC utility functions throughout the codebase. + * If SPC_ENABLE is not 1, the macros become no-ops. + */ +#if SPC_ENABLE == 1 + +#define SPC_INIT() \ + ompi_spc_init() + +#define SPC_FINI() \ + ompi_spc_fini() + +#define SPC_RECORD(event_id, value) \ + ompi_spc_record(event_id, value) + +#define SPC_TIMER_START(event_id, usec) \ + ompi_spc_timer_start(event_id, usec) + +#define SPC_TIMER_STOP(event_id, usec) \ + ompi_spc_timer_stop(event_id, usec) + +#define SPC_USER_OR_MPI(tag, value, enum_if_user, enum_if_mpi) \ + ompi_spc_user_or_mpi(tag, value, enum_if_user, enum_if_mpi) + +#define SPC_CYCLES_TO_USECS(cycles) \ + ompi_spc_cycles_to_usecs(cycles) + +#else /* SPCs are not enabled */ + +#define SPC_INIT() \ + do {} while (0) + +#define SPC_FINI() \ + do {} while (0) + +#define SPC_RECORD(event_id, value) \ + do {} while (0) + +#define SPC_TIMER_START(event_id, usec) \ + do {} while (0) + +#define SPC_TIMER_STOP(event_id, usec) \ + do {} while (0) + +#define SPC_USER_OR_MPI(tag, value, enum_if_user, enum_if_mpi) \ + do {} while (0) + +#define SPC_CYCLES_TO_USECS(cycles) \ + do {} while (0) + +#endif + +#endif diff --git a/ompi/runtime/papi_sde_interface.c b/ompi/runtime/papi_sde_interface.c deleted file mode 100644 index 4e8b6820156..00000000000 --- a/ompi/runtime/papi_sde_interface.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include "papi_sde_interface.h" - -#pragma weak papi_sde_init -#pragma weak papi_sde_register_counter -#pragma weak papi_sde_describe_counter - -OMPI_DECLSPEC papi_handle_t -__attribute__((weak)) -papi_sde_init(char *name_of_library, int *event_count) -{ - printf("Weak papi_sde_init called from %s. Weak functions will be called papi sde functionality. If you aren't using the papi sde component, disregard this message.\n", __FILE__); - void * ptr = NULL; - return ptr; -} - -OMPI_DECLSPEC void -__attribute__((weak)) -papi_sde_register_counter(papi_handle_t handle, char *event_name, long long int *counter) -{ - /*printf("weak papi_sde_register_counter called from %s\n", __FILE__);*/ -} - -OMPI_DECLSPEC void -__attribute__((weak)) -papi_sde_describe_counter(papi_handle_t handle, char *event_name, char *event_description) -{ - /*printf("weak papi_sde_describe_counter called from %s\n", __FILE__);*/ -} diff --git a/ompi/runtime/papi_sde_interface.h b/ompi/runtime/papi_sde_interface.h deleted file mode 100644 index 54154f8a186..00000000000 --- a/ompi/runtime/papi_sde_interface.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef PAPI_SDE_INTERFACE_H -#define PAPI_SDE_INTERFACE_H - -#include "ompi/include/ompi_config.h" - -// interface to papi SDE functions -typedef void* papi_handle_t; -papi_handle_t papi_sde_init(char *name_of_library, int *event_count); -void papi_sde_register_counter(papi_handle_t handle, char *event_name, long long int *counter); -void papi_sde_describe_counter(papi_handle_t handle, char *event_name, char *event_description ); - -// required for papi_native_avail -void* papi_sde_hook_list_events( void ); - -#endif diff --git a/ompi/runtime/params.h b/ompi/runtime/params.h index 399b4ac6da4..a14be1e50c8 100644 --- a/ompi/runtime/params.h +++ b/ompi/runtime/params.h @@ -142,12 +142,11 @@ OMPI_DECLSPEC extern bool ompi_async_mpi_init; OMPI_DECLSPEC extern bool ompi_async_mpi_finalize; /** - * Whether or not to print the MCA parameters to a file or to stdout - * - * If this argument is set then it is used when parameters are dumped - * when the mpi_show_mca_params is set. + * A comma delimited list of SPC counters to turn on or 'attach'. To turn + * all counters on, the string can be simply "all". An empty string will + * keep all counters turned off. */ -OMPI_DECLSPEC extern char * ompi_mpi_spc_enable_string; +OMPI_DECLSPEC extern char * ompi_mpi_spc_attach_string; /** diff --git a/opal/runtime/Makefile.am b/opal/runtime/Makefile.am index 5bef9322ae7..fab8ead6104 100644 --- a/opal/runtime/Makefile.am +++ b/opal/runtime/Makefile.am @@ -46,4 +46,3 @@ lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \ runtime/opal_cr.c \ runtime/opal_info_support.c \ runtime/opal_progress_threads.c - diff --git a/opal/threads/wait_sync.c b/opal/threads/wait_sync.c index 9b5d75ece71..b8e3c423c0a 100644 --- a/opal/threads/wait_sync.c +++ b/opal/threads/wait_sync.c @@ -94,8 +94,8 @@ int ompi_sync_wait_mt(ompi_wait_sync_t *sync) /* In case I am the progress manager, pass the duties on */ if( sync == wait_sync_list ) { wait_sync_list = (sync == sync->next) ? NULL : sync->next; - if( NULL != wait_sync_list ){ - /* This is a possible placement for an MPI_T progress switch counter */ + if( NULL != wait_sync_list ) { + /* This is a possible placement for an MPI_T progress switch pvar */ WAIT_SYNC_PASS_OWNERSHIP(wait_sync_list); } } From bf9f4a895bf37b5ce703187691ce2907ac821e45 Mon Sep 17 00:00:00 2001 From: David Eberius Date: Wed, 31 Jan 2018 14:49:08 -0500 Subject: [PATCH 07/12] Updated copyright information, added an MCA parameter for turning on and off dumping SPC counters in MPI_Finalize, and some minor bug fixes. --- configure.ac | 2 +- ompi/mca/pml/ob1/pml_ob1.c | 5 +- ompi/mca/pml/ob1/pml_ob1_isend.c | 2 +- ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 7 ++ ompi/mca/pml/ob1/pml_ob1_recvreq.c | 2 + ompi/mca/pml/ob1/pml_ob1_sendreq.c | 2 +- ompi/mpi/c/finalize.c | 8 +- ompi/mpi/c/init.c | 2 +- ompi/mpi/c/init_thread.c | 2 +- ompi/mpi/c/irecv.c | 2 +- ompi/mpi/c/isend.c | 2 +- ompi/mpi/c/recv.c | 2 +- ompi/mpi/c/send.c | 2 +- ompi/runtime/Makefile.am | 2 +- ompi/runtime/ompi_mpi_params.c | 11 ++- ompi/runtime/ompi_spc.c | 124 ++++++++++++++++++++-------- ompi/runtime/ompi_spc.h | 23 ++++++ ompi/runtime/params.h | 8 +- opal/threads/wait_sync.c | 4 +- 19 files changed, 159 insertions(+), 53 deletions(-) diff --git a/configure.ac b/configure.ac index 89e98f2d95b..7416c99164b 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ # Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana # University Research and Technology # Corporation. All rights reserved. -# Copyright (c) 2004-2015 The University of Tennessee and The University +# Copyright (c) 2004-2017 The University of Tennessee and The University # of Tennessee Research Foundation. All rights # reserved. # Copyright (c) 2004-2007 High Performance Computing Center Stuttgart, diff --git a/ompi/mca/pml/ob1/pml_ob1.c b/ompi/mca/pml/ob1/pml_ob1.c index f29e6732051..c41eb78b008 100644 --- a/ompi/mca/pml/ob1/pml_ob1.c +++ b/ompi/mca/pml/ob1/pml_ob1.c @@ -254,6 +254,8 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) continue; } + SPC_TIMER_START(OMPI_OOS_MATCH_TIME, &timer); + if (((uint16_t)hdr->hdr_seq) == ((uint16_t)pml_proc->expected_sequence) ) { add_fragment_to_unexpected: @@ -268,7 +270,6 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) * situation as the cant_match is only checked when a new fragment is received from * the network. */ - SW_EVENT_TIMER_START(OMPI_OOS_MATCH_TIME, &usecs); if( NULL != pml_proc->frags_cant_match ) { frag = check_cantmatch_for_match(pml_proc); if( NULL != frag ) { @@ -276,11 +277,11 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) goto add_fragment_to_unexpected; } } - SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); } else { append_frag_to_ordered_list(&pml_proc->frags_cant_match, frag, pml_proc->expected_sequence); } + SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); } return OMPI_SUCCESS; } diff --git a/ompi/mca/pml/ob1/pml_ob1_isend.c b/ompi/mca/pml/ob1/pml_ob1_isend.c index 5ab3a773d7c..b20ae4b7857 100644 --- a/ompi/mca/pml/ob1/pml_ob1_isend.c +++ b/ompi/mca/pml/ob1/pml_ob1_isend.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2015 The University of Tennessee and The University + * Copyright (c) 2004-2017 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index f27abd2e1c1..79c5142d727 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -844,6 +844,8 @@ match_one(mca_btl_base_module_t *btl, append_frag_to_list(&proc->unexpected_frags, btl, hdr, segments, num_segments, frag); SPC_RECORD(OMPI_UNEXPECTED, 1); + SPC_RECORD(OMPI_UNEXPECTED_IN_QUEUE, 1); + SPC_UPDATE_WATERMARK(OMPI_MAX_UNEXPECTED_IN_QUEUE, OMPI_UNEXPECTED_IN_QUEUE); PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_INSERT_IN_UNEX_Q, comm_ptr, hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); SPC_TIMER_STOP(OMPI_MATCH_TIME, &timer); @@ -940,6 +942,11 @@ static int mca_pml_ob1_recv_frag_match( mca_btl_base_module_t *btl, MCA_PML_OB1_RECV_FRAG_ALLOC(frag); MCA_PML_OB1_RECV_FRAG_INIT(frag, hdr, segments, num_segments, btl); append_frag_to_ordered_list(&proc->frags_cant_match, frag, next_msg_seq_expected); + + SPC_RECORD(OMPI_OUT_OF_SEQUENCE, 1); + SPC_RECORD(OMPI_OOS_IN_QUEUE, 1); + SPC_UPDATE_WATERMARK(OMPI_MAX_OOS_IN_QUEUE, OMPI_OOS_IN_QUEUE); + OB1_MATCHING_UNLOCK(&comm->matching_lock); return OMPI_SUCCESS; } diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index ace333a4b5b..d30fbaf9943 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -1245,6 +1245,7 @@ void mca_pml_ob1_recv_req_start(mca_pml_ob1_recv_request_t *req) opal_list_remove_item(&proc->unexpected_frags, (opal_list_item_t*)frag); + SPC_RECORD(OMPI_UNEXPECTED_IN_QUEUE, -1); OB1_MATCHING_UNLOCK(&ob1_comm->matching_lock); switch(hdr->hdr_common.hdr_type) { @@ -1275,6 +1276,7 @@ void mca_pml_ob1_recv_req_start(mca_pml_ob1_recv_request_t *req) restarted with this request during mrecv */ opal_list_remove_item(&proc->unexpected_frags, (opal_list_item_t*)frag); + SPC_RECORD(OMPI_UNEXPECTED_IN_QUEUE, -1); OB1_MATCHING_UNLOCK(&ob1_comm->matching_lock); req->req_recv.req_base.req_addr = frag; diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index 589638862f3..7054221131c 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2016 The University of Tennessee and The University + * Copyright (c) 2004-2017 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/finalize.c b/ompi/mpi/c/finalize.c index 685cbef1b63..f2831ec7c6e 100644 --- a/ompi/mpi/c/finalize.c +++ b/ompi/mpi/c/finalize.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -25,6 +25,8 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/runtime/ompi_spc.h" +#include "ompi/runtime/params.h" + #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_Finalize = PMPI_Finalize @@ -41,6 +43,9 @@ int MPI_Finalize(void) * aggregated across the whole MPI run. */ #if SPC_ENABLE == 1 + if(!ompi_mpi_spc_dump_enabled) + goto skip_dump; + int i, j, rank, world_size, offset; long long *recv_buffer, *send_buffer; @@ -90,6 +95,7 @@ int MPI_Finalize(void) } MPI_Barrier(MPI_COMM_WORLD); + skip_dump: #endif OPAL_CR_FINALIZE_LIBRARY(); diff --git a/ompi/mpi/c/init.c b/ompi/mpi/c/init.c index 8c7f564f6fe..ffa4b62a362 100644 --- a/ompi/mpi/c/init.c +++ b/ompi/mpi/c/init.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2017 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/init_thread.c b/ompi/mpi/c/init_thread.c index c91e3d1ab56..609fd7e4a74 100644 --- a/ompi/mpi/c/init_thread.c +++ b/ompi/mpi/c/init_thread.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2017 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/irecv.c b/ompi/mpi/c/irecv.c index a4b5f05d837..f177923bc83 100644 --- a/ompi/mpi/c/irecv.c +++ b/ompi/mpi/c/irecv.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2017 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/isend.c b/ompi/mpi/c/isend.c index 1b145193607..cea1afd4dc0 100644 --- a/ompi/mpi/c/isend.c +++ b/ompi/mpi/c/isend.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2017 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/recv.c b/ompi/mpi/c/recv.c index dc35792bde2..5387f816e87 100644 --- a/ompi/mpi/c/recv.c +++ b/ompi/mpi/c/recv.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2017 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/send.c b/ompi/mpi/c/send.c index 42a2eb345de..c17e9c57ae0 100644 --- a/ompi/mpi/c/send.c +++ b/ompi/mpi/c/send.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2017 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/runtime/Makefile.am b/ompi/runtime/Makefile.am index 2108ad97cbf..c4dd14bee1c 100644 --- a/ompi/runtime/Makefile.am +++ b/ompi/runtime/Makefile.am @@ -2,7 +2,7 @@ # Copyright (c) 2004-2007 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 +# Copyright (c) 2004-2017 The University of Tennessee and The University # of Tennessee Research Foundation. All rights # reserved. # Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, diff --git a/ompi/runtime/ompi_mpi_params.c b/ompi/runtime/ompi_mpi_params.c index 49490d3d4ef..0604fd3c1bf 100644 --- a/ompi/runtime/ompi_mpi_params.c +++ b/ompi/runtime/ompi_mpi_params.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -76,6 +76,7 @@ uint32_t ompi_add_procs_cutoff = OMPI_ADD_PROCS_CUTOFF_DEFAULT; bool ompi_mpi_dynamics_enabled = true; char *ompi_mpi_spc_attach_string = NULL; +bool ompi_mpi_spc_dump_enabled = false; static bool show_default_mca_params = false; static bool show_file_mca_params = false; @@ -325,6 +326,14 @@ int ompi_mpi_register_params(void) MCA_BASE_VAR_SCOPE_READONLY, &ompi_mpi_spc_attach_string); + ompi_mpi_spc_dump_enabled = false; + (void) mca_base_var_register("ompi", "mpi", NULL, "spc_dump_enabled", + "A boolean value for whether (true) or not (false) to enable dumping SPC counters in MPI_Finalize.", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_spc_dump_enabled); + return OMPI_SUCCESS; } diff --git a/ompi/runtime/ompi_spc.c b/ompi/runtime/ompi_spc.c index 9f57356d23c..c99341482ab 100644 --- a/ompi/runtime/ompi_spc.c +++ b/ompi/runtime/ompi_spc.c @@ -1,9 +1,23 @@ +/* + * Copyright (c) 2004-2018 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + #include "ompi_spc.h" opal_timer_t sys_clock_freq_mhz = 0; /* Array for converting from SPC indices to MPI_T indices */ OMPI_DECLSPEC int mpi_t_indices[OMPI_NUM_COUNTERS] = {0}; +OMPI_DECLSPEC int mpi_t_offset = -1; +OMPI_DECLSPEC int mpi_t_disabled = 0; /* Array of names for each counter. Used for MPI_T and PAPI sde initialization */ OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { @@ -27,7 +41,11 @@ OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { "OMPI_UNEXPECTED", "OMPI_OUT_OF_SEQUENCE", "OMPI_MATCH_TIME", - "OMPI_OOS_MATCH_TIME" + "OMPI_OOS_MATCH_TIME", + "OMPI_UNEXPECTED_IN_QUEUE", + "OMPI_OOS_IN_QUEUE", + "OMPI_MAX_UNEXPECTED_IN_QUEUE", + "OMPI_MAX_OOS_IN_QUEUE" }; /* Array of descriptions for each counter. Used for MPI_T and PAPI sde initialization */ @@ -43,16 +61,22 @@ OMPI_DECLSPEC const char *counter_descriptions[OMPI_NUM_COUNTERS] = { "The number of times MPI_Gather was called.", "The number of times MPI_Alltoall was called.", "The number of times MPI_Allgather was called.", - "The number of bytes received by the user through point-to-point communications. Note: Excludes RDMA operations.", + "The number of bytes received by the user through point-to-point communications. Note: Includes bytes transferred using internal RMA operations.", "The number of bytes received by MPI through collective, control, or other internal communications.", - "The number of bytes sent by the user through point-to-point communications. Note: Excludes RDMA operations.", + "The number of bytes sent by the user through point-to-point communications. Note: Includes bytes transferred using internal RMA operations.", "The number of bytes sent by MPI through collective, control, or other internal communications.", - "The number of bytes sent/received using RDMA Put operations.", - "The number of bytes sent/received using RDMA Get operations.", + "The number of bytes sent/received using RMA Put operations both through user-level Put functions and internal Put functions.", + "The number of bytes sent/received using RMA Get operations both through user-level Get functions and internal Get functions.", "The number of messages that arrived as unexpected messages.", "The number of messages that arrived out of the proper sequence.", "The number of microseconds spent matching unexpected messages.", - "The number of microseconds spent matching out of sequence messages." + "The number of microseconds spent matching out of sequence messages.", + "The number of messages that are currently in the unexpected message queue(s) of an MPI process.", + "The number of messages that are currently in the out of sequence message queue(s) of an MPI process.", + "The maximum number of messages that the unexpected message queue(s) within an MPI process contained at once since the last reset of this counter. \ +Note: This counter is reset each time it is read.", + "The maximum number of messages that the out of sequence message queue(s) within an MPI process contained at once since the last reset of this counter. \ +Note: This counter is reset each time it is read." }; /* An array of integer values to denote whether an event is activated (1) or not (0) */ @@ -70,33 +94,29 @@ static int ompi_spc_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, v { (void)obj_handle; - int i; + int index; + + if(OPAL_UNLIKELY(mpi_t_disabled == 1)) + return MPI_SUCCESS; /* For this event, we need to set count to the number of long long type * values for this counter. All SPC counters are one long long, so we * always set count to 1. */ - if(MCA_BASE_PVAR_HANDLE_BIND == event) + if(MCA_BASE_PVAR_HANDLE_BIND == event) { *count = 1; + } /* For this event, we need to turn on the counter */ else if(MCA_BASE_PVAR_HANDLE_START == event) { - /* Loop over the mpi_t_inddices array and find the correct SPC index to turn on */ - for(i = 0; i < OMPI_NUM_COUNTERS; i++) { - if(pvar->pvar_index == mpi_t_indices[i]) { - attached_event[i] = 1; - break; - } - } + /* Convert from MPI_T pvar index to SPC index */ + index = pvar->pvar_index - mpi_t_offset; + attached_event[index] = 1; } /* For this event, we need to turn off the counter */ else if(MCA_BASE_PVAR_HANDLE_STOP == event) { - /* Loop over the mpi_t_inddices array and find the correct SPC index to turn off */ - for(i = 0; i < OMPI_NUM_COUNTERS; i++) { - if(pvar->pvar_index == mpi_t_indices[i]) { - attached_event[i] = 0; - break; - } - } + /* Convert from MPI_T pvar index to SPC index */ + index = pvar->pvar_index - mpi_t_offset; + attached_event[index] = 0; } return MPI_SUCCESS; @@ -116,21 +136,24 @@ static int ompi_spc_get_count(const struct mca_base_pvar_t *pvar, void *value, v { (void) obj_handle; - int i; long long *counter_value = (long long*)value; - for(i = 0; i < OMPI_NUM_COUNTERS; i++) { - if(pvar->pvar_index == mpi_t_indices[i]) { - /* If this is a timer-based counter, we need to convert from cycles to microseconds */ - if(timer_event[i]) - *counter_value = events[i].value / sys_clock_freq_mhz; - else - *counter_value = events[i].value; - return MPI_SUCCESS; - } + if(OPAL_UNLIKELY(mpi_t_disabled == 1)) { + *counter_value = 0; + return MPI_SUCCESS; } - /* If all else fails, simply set value to 0 */ - *counter_value = 0; + + /* Convert from MPI_T pvar index to SPC index */ + int index = pvar->pvar_index - mpi_t_offset; + /* Set the counter value to the current SPC value */ + *counter_value = events[index].value; + /* If this is a timer-based counter, convert from cycles to microseconds */ + if(timer_event[index]) + *counter_value /= sys_clock_freq_mhz; + /* If this is a high watermark counter, reset it after it has been read */ + if(index == OMPI_MAX_UNEXPECTED_IN_QUEUE || index == OMPI_MAX_OOS_IN_QUEUE) + events[index].value = 0; + return MPI_SUCCESS; } @@ -176,6 +199,7 @@ void ompi_spc_init() all_on = 1; } + int prev = -1; /* Turn on only the counters that were specified in the MCA parameter */ for(i = 0; i < OMPI_NUM_COUNTERS; i++) { if(all_on) @@ -213,8 +237,22 @@ void ompi_spc_init() */ if(ret != OPAL_ERROR) { mpi_t_indices[i] = ret; + + if(mpi_t_offset == -1) { + mpi_t_offset = ret; + prev = ret; + } else if(ret != prev + 1) { + mpi_t_disabled = 1; + fprintf(stderr, "There was an error registering SPCs as MPI_T pvars. SPCs will be disabled for MPI_T.\n"); + break; + } else { + prev = ret; + } } else { mpi_t_indices[i] = -1; + mpi_t_disabled = 1; + fprintf(stderr, "There was an error registering SPCs as MPI_T pvars. SPCs will be disabled for MPI_T.\n"); + break; } } } @@ -266,13 +304,29 @@ void ompi_spc_timer_stop(unsigned int event_id, opal_timer_t *cycles) */ void ompi_spc_user_or_mpi(int tag, long long value, unsigned int user_enum, unsigned int mpi_enum) { - if(tag >= 0) { + if(tag >= 0 || tag == MPI_ANY_TAG) { SPC_RECORD(user_enum, value); } else { SPC_RECORD(mpi_enum, value); } } +/* Checks whether the counter denoted by value_enum exceeds the current value of the + * counter denoted by watermark_enum, and if so sets the watermark_enum counter to the + * value of the value_enum counter. + */ +void ompi_spc_update_watermark(unsigned int watermark_enum, unsigned int value_enum) +{ + /* Denoted unlikely because counters will often be turned off. */ + if(OPAL_UNLIKELY(attached_event[watermark_enum] == 1 && attached_event[value_enum] == 1)) { + /* WARNING: This assumes that this function was called while a lock has already been taken. + * This function is NOT thread safe otherwise! + */ + if(events[value_enum].value > events[watermark_enum].value) + events[watermark_enum].value = events[value_enum].value; + } +} + /* Converts a counter value that is in cycles to microseconds. */ void ompi_spc_cycles_to_usecs(long long *cycles) diff --git a/ompi/runtime/ompi_spc.h b/ompi/runtime/ompi_spc.h index e7bb41ae86d..f96e4431b72 100644 --- a/ompi/runtime/ompi_spc.h +++ b/ompi/runtime/ompi_spc.h @@ -1,3 +1,15 @@ +/* + * Copyright (c) 2004-2018 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + #ifndef OMPI_SPC #define OMPI_SPC @@ -58,6 +70,10 @@ enum OMPI_COUNTERS{ OMPI_OUT_OF_SEQUENCE, OMPI_MATCH_TIME, OMPI_OOS_MATCH_TIME, + OMPI_UNEXPECTED_IN_QUEUE, + OMPI_OOS_IN_QUEUE, + OMPI_MAX_UNEXPECTED_IN_QUEUE, + OMPI_MAX_OOS_IN_QUEUE, OMPI_NUM_COUNTERS /* This serves as the number of counters. It must be last. */ }; @@ -82,6 +98,7 @@ void ompi_spc_timer_start(unsigned int event_id, opal_timer_t *cycles); void ompi_spc_timer_stop(unsigned int event_id, opal_timer_t *cycles); void ompi_spc_user_or_mpi(int tag, long long value, unsigned int user_enum, unsigned int mpi_enum); void ompi_spc_cycles_to_usecs(long long *cycles); +void ompi_spc_update_watermark(unsigned int watermark_enum, unsigned int value_enum); /* MPI_T utility functions */ static int ompi_spc_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, void *obj_handle, int *count); @@ -113,6 +130,9 @@ long long ompi_spc_get_counter(int counter_id); #define SPC_CYCLES_TO_USECS(cycles) \ ompi_spc_cycles_to_usecs(cycles) +#define SPC_UPDATE_WATERMARK(watermark_enum, value_enum) \ + ompi_spc_update_watermark(watermark_enum, value_enum) + #else /* SPCs are not enabled */ #define SPC_INIT() \ @@ -136,6 +156,9 @@ long long ompi_spc_get_counter(int counter_id); #define SPC_CYCLES_TO_USECS(cycles) \ do {} while (0) +#define SPC_UPDATE_WATERMARK(watermark_enum, value_enum) \ + do {} while (0) + #endif #endif diff --git a/ompi/runtime/params.h b/ompi/runtime/params.h index a14be1e50c8..194ac060da1 100644 --- a/ompi/runtime/params.h +++ b/ompi/runtime/params.h @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -148,6 +148,12 @@ OMPI_DECLSPEC extern bool ompi_async_mpi_finalize; */ OMPI_DECLSPEC extern char * ompi_mpi_spc_attach_string; +/** + * A boolean value that determines whether or not to dump the SPC counter + * values in MPI_Finalize. A value of true dumps the counters and false does not. + */ +OMPI_DECLSPEC extern bool ompi_mpi_spc_dump_enabled; + /** * Register MCA parameters used by the MPI layer. diff --git a/opal/threads/wait_sync.c b/opal/threads/wait_sync.c index b8e3c423c0a..92b6096406c 100644 --- a/opal/threads/wait_sync.c +++ b/opal/threads/wait_sync.c @@ -94,10 +94,8 @@ int ompi_sync_wait_mt(ompi_wait_sync_t *sync) /* In case I am the progress manager, pass the duties on */ if( sync == wait_sync_list ) { wait_sync_list = (sync == sync->next) ? NULL : sync->next; - if( NULL != wait_sync_list ) { - /* This is a possible placement for an MPI_T progress switch pvar */ + if( NULL != wait_sync_list ) WAIT_SYNC_PASS_OWNERSHIP(wait_sync_list); - } } OPAL_THREAD_UNLOCK(&wait_sync_lock); From 223e4d54f19971c98a3d2691eedbbe3d39ce593f Mon Sep 17 00:00:00 2001 From: David Eberius Date: Wed, 21 Feb 2018 15:00:03 -0500 Subject: [PATCH 08/12] Added an SPC test and example. Fixed a bug that would count messages with MPI_ANY_TAG to count as BYTES_RECEIVED_MPI. --- configure.ac | 2 +- examples/Makefile | 5 +- examples/Makefile.include | 3 +- examples/spc_example.c | 121 +++++++++++++++++++ ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 2 +- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 10 +- ompi/mca/pml/ob1/pml_ob1_sendreq.c | 14 +-- ompi/mpi/c/finalize.c | 63 +--------- ompi/mpi/c/sendrecv.c | 3 + ompi/mpi/c/sendrecv_replace.c | 3 + ompi/runtime/ompi_spc.c | 74 +++++++++++- ompi/runtime/ompi_spc.h | 5 +- test/Makefile.am | 2 +- test/spc/Makefile.am | 24 ++++ test/spc/spc_test.c | 176 ++++++++++++++++++++++++++++ 15 files changed, 423 insertions(+), 84 deletions(-) create mode 100644 examples/spc_example.c create mode 100644 test/spc/Makefile.am create mode 100644 test/spc/spc_test.c diff --git a/configure.ac b/configure.ac index 7416c99164b..a5754bb2785 100644 --- a/configure.ac +++ b/configure.ac @@ -1445,7 +1445,7 @@ AC_CONFIG_FILES([ test/util/Makefile ]) -m4_ifdef([project_ompi], [AC_CONFIG_FILES([test/monitoring/Makefile])]) +m4_ifdef([project_ompi], [AC_CONFIG_FILES([test/monitoring/Makefile test/spc/Makefile])]) AC_CONFIG_FILES([contrib/dist/mofed/debian/rules], [chmod +x contrib/dist/mofed/debian/rules]) diff --git a/examples/Makefile b/examples/Makefile index 86ce69b2b5c..7699b5255a5 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -67,14 +67,15 @@ EXAMPLES = \ oshmem_circular_shift \ oshmem_max_reduction \ oshmem_strided_puts \ - oshmem_symmetric_data + oshmem_symmetric_data \ + spc_example # Default target. Always build the C MPI examples. Only build the # others if we have the appropriate Open MPI / OpenSHMEM language # bindings. -all: hello_c ring_c connectivity_c +all: hello_c ring_c connectivity_c spc_example @ if which ompi_info >/dev/null 2>&1 ; then \ $(MAKE) mpi; \ fi diff --git a/examples/Makefile.include b/examples/Makefile.include index ebf0eb9d370..acd58d82c00 100644 --- a/examples/Makefile.include +++ b/examples/Makefile.include @@ -57,4 +57,5 @@ EXTRA_DIST += \ examples/oshmem_strided_puts.c \ examples/oshmem_symmetric_data.c \ examples/Hello.java \ - examples/Ring.java + examples/Ring.java \ + examples/spc_example.c diff --git a/examples/spc_example.c b/examples/spc_example.c new file mode 100644 index 00000000000..ff1d68fb3f7 --- /dev/null +++ b/examples/spc_example.c @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2018 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * + * Simple example usage of SPCs through MPI_T. + */ + +#include +#include +#include + +#include + +/* Sends 'num_messages' messages of 'message_size' bytes from rank 0 to rank 1. + * All messages are send synchronously and with the same tag in MPI_COMM_WORLD. + */ +void message_exchange(int num_messages, int message_size) +{ + int i, rank; + /* Use calloc to initialize data to 0's */ + char *data = (char*)calloc(message_size, sizeof(char)); + MPI_Status status; + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + if(rank == 0) { + for(i = 0; i < num_messages; i++) + MPI_Send(data, message_size, MPI_BYTE, 1, 123, MPI_COMM_WORLD); + } else if(rank == 1) { + for(i = 0; i < num_messages; i++) + MPI_Recv(data, message_size, MPI_BYTE, 0, 123, MPI_COMM_WORLD, &status); + } + + free(data); +} + +int main(int argc, char **argv) +{ + int num_messages, message_size; + + if(argc < 3) { + printf("Usage: mpirun -np 2 --mca mpi_spc_attach all --mca mpi_spc_dump_enabled true ./test [num_messages] [message_size]\n"); + return -1; + } else { + num_messages = atoi(argv[1]); + message_size = atoi(argv[2]); + } + + int i, rank, size, provided, num, name_len, desc_len, verbosity, bind, var_class, readonly, continuous, atomic, count, index; + MPI_Datatype datatype; + MPI_T_enum enumtype; + MPI_Comm comm; + char name[256], description[256]; + + /* Counter names to be read by ranks 0 and 1 */ + char counter_names[2][40]; + sprintf(counter_names[0], "runtime_spc_OMPI_BYTES_SENT_USER"); + sprintf(counter_names[1], "runtime_spc_OMPI_BYTES_RECEIVED_USER"); + + MPI_Init(NULL, NULL); + MPI_T_init_thread(MPI_THREAD_SINGLE, &provided); + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + if(size != 2) { + fprintf(stderr, "ERROR: This test should be run with two MPI processes.\n"); + return -1; + } + + /* Determine the MPI_T pvar indices for the OMPI_BYTES_SENT/RECIEVED_USER SPCs */ + index = -1; + MPI_T_pvar_get_num(&num); + for(i = 0; i < num; i++) { + name_len = desc_len = 256; + PMPI_T_pvar_get_info(i, name, &name_len, &verbosity, + &var_class, &datatype, &enumtype, description, &desc_len, &bind, + &readonly, &continuous, &atomic); + if(strcmp(name, counter_names[rank]) == 0) { + index = i; + printf("[%d] %s -> %s\n", rank, name, description); + } + } + + /* Make sure we found the counters */ + if(index == -1) { + fprintf(stderr, "ERROR: Couldn't find the appropriate SPC counter in the MPI_T pvars.\n"); + return -1; + } + + int ret; + long long value; + + MPI_T_pvar_session session; + MPI_T_pvar_handle handle; + /* Create the MPI_T sessions/handles for the counters and start the counters */ + ret = MPI_T_pvar_session_create(&session); + ret = MPI_T_pvar_handle_alloc(session, index, NULL, &handle, &count); + ret = MPI_T_pvar_start(session, handle); + + message_exchange(num_messages, message_size); + + ret = MPI_T_pvar_read(session, handle, &value); + /* Print the counter values in order by rank */ + for(i = 0; i < 2; i++) { + if(i == rank) { + printf("[%d] Value Read: %lld\n", rank, value); + fflush(stdout); + } + MPI_Barrier(MPI_COMM_WORLD); + } + /* Stop the MPI_T session, free the handle, and then free the session */ + ret = MPI_T_pvar_stop(session, handle); + ret = MPI_T_pvar_handle_free(session, &handle); + ret = MPI_T_pvar_session_free(&session); + + MPI_T_finalize(); + MPI_Finalize(); + + return 0; +} diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index 79c5142d727..7bfed24cc73 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -462,7 +462,7 @@ void mca_pml_ob1_recv_frag_callback_match(mca_btl_base_module_t* btl, &iov_count, &bytes_received ); match->req_bytes_received = bytes_received; - SPC_USER_OR_MPI(match->req_recv.req_base.req_tag, (long long)bytes_received, + SPC_USER_OR_MPI(match->req_recv.req_base.req_ompi.req_status.MPI_TAG, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* * Unpacking finished, make the user buffer unaccessable again. diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index d30fbaf9943..1f123a2e649 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -200,7 +200,7 @@ static void mca_pml_ob1_put_completion (mca_pml_ob1_rdma_frag_t *frag, int64_t r /* check completion status */ OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, rdma_size); - SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)rdma_size, + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_ompi.req_status.MPI_TAG, (long long)rdma_size, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); if (recv_request_pml_complete_check(recvreq) == false && recvreq->req_rdma_offset < recvreq->req_send_offset) { @@ -535,7 +535,7 @@ void mca_pml_ob1_recv_request_progress_frag( mca_pml_ob1_recv_request_t* recvreq ); OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); - SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_ompi.req_status.MPI_TAG, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* check completion status */ if(recv_request_pml_complete_check(recvreq) == false && @@ -614,7 +614,7 @@ void mca_pml_ob1_recv_request_frag_copy_finished( mca_btl_base_module_t* btl, des->des_cbfunc(NULL, NULL, des, 0); OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); - SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_ompi.req_status.MPI_TAG, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); /* check completion status */ if(recv_request_pml_complete_check(recvreq) == false && @@ -829,7 +829,7 @@ void mca_pml_ob1_recv_request_progress_rndv( mca_pml_ob1_recv_request_t* recvreq recvreq->req_recv.req_base.req_datatype); ); OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received); - SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_ompi.req_status.MPI_TAG, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); } /* check completion status */ @@ -901,7 +901,7 @@ void mca_pml_ob1_recv_request_progress_match( mca_pml_ob1_recv_request_t* recvre * for this request. */ recvreq->req_bytes_received += bytes_received; - SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, + SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_ompi.req_status.MPI_TAG, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI); recv_request_pml_complete(recvreq); } diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index 7054221131c..4d7349043a0 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -206,7 +206,7 @@ mca_pml_ob1_rndv_completion_request( mca_bml_base_btl_t* bml_btl, } OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, req_bytes_delivered); - SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, req_bytes_delivered, + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_ompi.req_status.MPI_TAG, req_bytes_delivered, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); /* advance the request */ @@ -264,7 +264,7 @@ mca_pml_ob1_rget_completion (mca_pml_ob1_rdma_frag_t *frag, int64_t rdma_length) /* count bytes of user data actually delivered and check for request completion */ if (OPAL_LIKELY(0 < rdma_length)) { OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, (size_t) rdma_length); - SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, rdma_length, + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_ompi.req_status.MPI_TAG, rdma_length, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); } @@ -319,7 +319,7 @@ mca_pml_ob1_frag_completion( mca_btl_base_module_t* btl, OPAL_THREAD_ADD_FETCH32(&sendreq->req_pipeline_depth, -1); OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, req_bytes_delivered); - SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, req_bytes_delivered, + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_ompi.req_status.MPI_TAG, req_bytes_delivered, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); if(send_request_pml_complete_check(sendreq) == false) { @@ -503,7 +503,7 @@ int mca_pml_ob1_send_request_start_copy( mca_pml_ob1_send_request_t* sendreq, &des); if( OPAL_LIKELY(OMPI_SUCCESS == rc) ) { /* signal request completion */ - SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_ompi.req_status.MPI_TAG, size, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); send_request_pml_complete(sendreq); return OMPI_SUCCESS; @@ -575,7 +575,7 @@ int mca_pml_ob1_send_request_start_copy( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send_status(bml_btl, des, MCA_PML_OB1_HDR_TYPE_MATCH); - SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_ompi.req_status.MPI_TAG, size, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); if( OPAL_LIKELY( rc >= OPAL_SUCCESS ) ) { if( OPAL_LIKELY( 1 == rc ) ) { @@ -637,7 +637,7 @@ int mca_pml_ob1_send_request_start_prepare( mca_pml_ob1_send_request_t* sendreq, /* send */ rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_MATCH); - SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, size, + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_ompi.req_status.MPI_TAG, size, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); if( OPAL_LIKELY( rc >= OPAL_SUCCESS ) ) { if( OPAL_LIKELY( 1 == rc ) ) { @@ -1139,7 +1139,7 @@ static void mca_pml_ob1_put_completion (mca_btl_base_module_t* btl, struct mca_b /* check for request completion */ OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, frag->rdma_length); - SPC_USER_OR_MPI(sendreq->req_send.req_base.req_tag, frag->rdma_length, + SPC_USER_OR_MPI(sendreq->req_send.req_base.req_ompi.req_status.MPI_TAG, frag->rdma_length, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI); send_request_pml_complete_check(sendreq); diff --git a/ompi/mpi/c/finalize.c b/ompi/mpi/c/finalize.c index f2831ec7c6e..42404768dfb 100644 --- a/ompi/mpi/c/finalize.c +++ b/ompi/mpi/c/finalize.c @@ -25,8 +25,6 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/runtime/ompi_spc.h" -#include "ompi/runtime/params.h" - #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_Finalize = PMPI_Finalize @@ -39,64 +37,11 @@ static const char FUNC_NAME[] = "MPI_Finalize"; int MPI_Finalize(void) { - /* If --with-spc was specified, print all of the final SPC values - * aggregated across the whole MPI run. + /* If --with-spc and ompi_mpi_spc_dump_enabled were specified, print + * all of the final SPC values aggregated across the whole MPI run. + * Also, free all SPC memory. */ -#if SPC_ENABLE == 1 - if(!ompi_mpi_spc_dump_enabled) - goto skip_dump; - - int i, j, rank, world_size, offset; - long long *recv_buffer, *send_buffer; - - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &world_size); - - /* Aggregate all of the information on rank 0 using MPI_Gather on MPI_COMM_WORLD */ - if(rank == 0) { - send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); - recv_buffer = (long long*)malloc(world_size * OMPI_NUM_COUNTERS * sizeof(long long)); - for(i = 0; i < OMPI_NUM_COUNTERS; i++) { - send_buffer[i] = events[i].value; - } - MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); - } else { - send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); - for(i = 0; i < OMPI_NUM_COUNTERS; i++) { - send_buffer[i] = events[i].value; - } - MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); - } - - /* Once rank 0 has all of the information, print the aggregated counter values for each rank in order */ - if(rank == 0) { - fprintf(stdout, "OMPI Software Counters:\n"); - offset = 0; /* Offset into the recv_buffer for each rank */ - for(j = 0; j < world_size; j++) { - fprintf(stdout, "World Rank %d:\n", j); - for(i = 0; i < OMPI_NUM_COUNTERS; i++) { - if(attached_event[i]) { - /* If this is a timer-based counter, we need to covert from cycles to usecs */ - if(timer_event[i]) - SPC_CYCLES_TO_USECS(&recv_buffer[offset+i]); - fprintf(stdout, "%s -> %lld\n", events[i].name, recv_buffer[offset+i]); - } else { - fprintf(stdout, "%s -> Disabled\n", events[i].name); - } - } - fprintf(stdout, "\n"); - offset += OMPI_NUM_COUNTERS; - } - free(recv_buffer); - free(send_buffer); - SPC_FINI(); - } else { - free(send_buffer); - } - - MPI_Barrier(MPI_COMM_WORLD); - skip_dump: -#endif + SPC_FINI(); OPAL_CR_FINALIZE_LIBRARY(); diff --git a/ompi/mpi/c/sendrecv.c b/ompi/mpi/c/sendrecv.c index f37d66bc71d..aa818a0b9ff 100644 --- a/ompi/mpi/c/sendrecv.c +++ b/ompi/mpi/c/sendrecv.c @@ -29,6 +29,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,6 +49,8 @@ int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, ompi_request_t* req; int rc = MPI_SUCCESS; + SPC_RECORD(OMPI_SENDRECV, 1); + MEMCHECKER( memchecker_datatype(sendtype); memchecker_datatype(recvtype); diff --git a/ompi/mpi/c/sendrecv_replace.c b/ompi/mpi/c/sendrecv_replace.c index bb9f4126f13..5117b2c3c73 100644 --- a/ompi/mpi/c/sendrecv_replace.c +++ b/ompi/mpi/c/sendrecv_replace.c @@ -30,6 +30,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/proc/proc.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,6 +49,8 @@ int MPI_Sendrecv_replace(void * buf, int count, MPI_Datatype datatype, { int rc = MPI_SUCCESS; + SPC_RECORD(OMPI_SENDRECV_REPLACE, 1); + MEMCHECKER( memchecker_datatype(datatype); memchecker_call(&opal_memchecker_base_isdefined, buf, count, datatype); diff --git a/ompi/runtime/ompi_spc.c b/ompi/runtime/ompi_spc.c index c99341482ab..8d53d914b1f 100644 --- a/ompi/runtime/ompi_spc.c +++ b/ompi/runtime/ompi_spc.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2004-2018 The University of Tennessee and The University - * of Tennessee Research Foundation. All rights - * reserved. + * Copyright (c) 2018 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. * * $COPYRIGHT$ * @@ -25,6 +25,8 @@ OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { "OMPI_RECV", "OMPI_ISEND", "OMPI_IRECV", + "OMPI_SENDRECV", + "OMPI_SENDRECV_REPLACE", "OMPI_BCAST", "OMPI_REDUCE", "OMPI_ALLREDUCE", @@ -54,6 +56,8 @@ OMPI_DECLSPEC const char *counter_descriptions[OMPI_NUM_COUNTERS] = { "The number of times MPI_Recv was called.", "The number of times MPI_Isend was called.", "The number of times MPI_Irecv was called.", + "The number of times MPI_Sendrecv was called.", + "The number of times MPI_Sendrecv_replace was called.", "The number of times MPI_Bcast was called.", "The number of times MPI_Reduce was called.", "The number of times MPI_Allreduce was called.", @@ -260,7 +264,67 @@ void ompi_spc_init() /* Frees any dynamically alocated OMPI SPC data structures */ void ompi_spc_fini() { - free(events); +#if SPC_ENABLE == 1 + if(!ompi_mpi_spc_dump_enabled) + goto skip_dump; + + int i, j, rank, world_size, offset; + long long *recv_buffer, *send_buffer; + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &world_size); + + /* Aggregate all of the information on rank 0 using MPI_Gather on MPI_COMM_WORLD */ + if(rank == 0) { + send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); + recv_buffer = (long long*)malloc(world_size * OMPI_NUM_COUNTERS * sizeof(long long)); + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { + send_buffer[i] = events[i].value; + } + MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); + } else { + send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { + send_buffer[i] = events[i].value; + } + MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); + } + + /* Once rank 0 has all of the information, print the aggregated counter values for each rank in order */ + if(rank == 0) { + fprintf(stdout, "OMPI Software Counters:\n"); + offset = 0; /* Offset into the recv_buffer for each rank */ + for(j = 0; j < world_size; j++) { + fprintf(stdout, "World Rank %d:\n", j); + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { + if(attached_event[i]) { + /* If this is a timer-based counter, we need to covert from cycles to usecs */ + if(timer_event[i]) + SPC_CYCLES_TO_USECS(&recv_buffer[offset+i]); + fprintf(stdout, "%s -> %lld\n", events[i].name, recv_buffer[offset+i]); + } else { + fprintf(stdout, "%s -> Disabled\n", events[i].name); + } + } + fprintf(stdout, "\n"); + offset += OMPI_NUM_COUNTERS; + } + free(recv_buffer); + free(send_buffer); + } else { + free(send_buffer); + } + + MPI_Barrier(MPI_COMM_WORLD); + skip_dump: + if(rank == 0) + free(events); +#else + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + if(rank == 0) + free(events); +#endif } /* Records an update to a counter using an atomic add operation. */ @@ -304,7 +368,7 @@ void ompi_spc_timer_stop(unsigned int event_id, opal_timer_t *cycles) */ void ompi_spc_user_or_mpi(int tag, long long value, unsigned int user_enum, unsigned int mpi_enum) { - if(tag >= 0 || tag == MPI_ANY_TAG) { + if(tag >= 0) { SPC_RECORD(user_enum, value); } else { SPC_RECORD(mpi_enum, value); diff --git a/ompi/runtime/ompi_spc.h b/ompi/runtime/ompi_spc.h index f96e4431b72..10499bf06ff 100644 --- a/ompi/runtime/ompi_spc.h +++ b/ompi/runtime/ompi_spc.h @@ -18,8 +18,7 @@ #include #include -#include "ompi/include/mpi.h" -#include "ompi/include/ompi_config.h" +#include "ompi/communicator/communicator.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/runtime/params.h" #include "opal/mca/timer/timer.h" @@ -53,6 +52,8 @@ enum OMPI_COUNTERS{ OMPI_RECV, OMPI_ISEND, OMPI_IRECV, + OMPI_SENDRECV, + OMPI_SENDRECV_REPLACE, OMPI_BCAST, OMPI_REDUCE, OMPI_ALLREDUCE, diff --git a/test/Makefile.am b/test/Makefile.am index 4ed25254849..a47e905ef0d 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -24,6 +24,6 @@ # support needs to be first for dependencies SUBDIRS = support asm class threads datatype util dss if PROJECT_OMPI -SUBDIRS += monitoring +SUBDIRS += monitoring spc endif DIST_SUBDIRS = event $(SUBDIRS) diff --git a/test/spc/Makefile.am b/test/spc/Makefile.am new file mode 100644 index 00000000000..3d060b9d418 --- /dev/null +++ b/test/spc/Makefile.am @@ -0,0 +1,24 @@ +# +# Copyright (c) 2018 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# This test requires multiple processes to run. Don't run it as part +# of 'make check' +if PROJECT_OMPI + noinst_PROGRAMS = spc_test + spc_test_SOURCES = spc_test.c + spc_test_LDFLAGS = $(OMPI_PKG_CONFIG_LDFLAGS) + spc_test_LDADD = \ + $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ + $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la +endif # PROJECT_OMPI + +distclean: + rm -rf *.dSYM .deps .libs *.la *.lo spc_test prof *.log *.o *.trs Makefile diff --git a/test/spc/spc_test.c b/test/spc/spc_test.c new file mode 100644 index 00000000000..081b42a8c42 --- /dev/null +++ b/test/spc/spc_test.c @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2018 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * + * Simple example usage of SPCs through MPI_T. + */ + +#include "mpi.h" +#include +#include +#include + +#define MAX_SIZE 1000000 + +/* Sends 'num_messages' messages of 'message_size' bytes from rank 0 to rank 1. + * All messages are sent synchronously and with the same tag in MPI_COMM_WORLD. + */ +void message_exchange(int num_messages, int message_size) +{ + int i, rank; + /* Use calloc to initialize data to 0's */ + char *data = (char*)calloc(message_size, sizeof(char)); + MPI_Status status; + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + if(rank == 0) { + for(i = 0; i < num_messages; i++) + MPI_Send(data, message_size, MPI_BYTE, 1, 123, MPI_COMM_WORLD); + } else if(rank == 1) { + for(i = 0; i < num_messages; i++) + MPI_Recv(data, message_size, MPI_BYTE, 0, 123, MPI_COMM_WORLD, &status); + } + + free(data); +} + +int main(int argc, char **argv) +{ + int i, rank, size, provided, num, name_len, desc_len, verbosity, bind, var_class, readonly, continuous, atomic, count, index, MPI_result; + MPI_Datatype datatype; + MPI_T_enum enumtype; + MPI_Comm comm; + char name[256], description[256]; + + /* Counter names to be read by ranks 0 and 1 */ + char counter_names[2][40]; + sprintf(counter_names[0], "runtime_spc_OMPI_BYTES_SENT_USER"); + sprintf(counter_names[1], "runtime_spc_OMPI_BYTES_RECEIVED_USER"); + + MPI_Init(NULL, NULL); + MPI_result = MPI_T_init_thread(MPI_THREAD_SINGLE, &provided); + if(MPI_result != MPI_SUCCESS) { + fprintf(stderr, "Failed to initialize MPI_T thread.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + if(size != 2) { + fprintf(stderr, "ERROR: This test should be run with two MPI processes.\n"); + return -1; + } + + /* Determine the MPI_T pvar indices for the OMPI_BYTES_SENT/RECIEVED_USER SPCs */ + index = -1; + MPI_result = MPI_T_pvar_get_num(&num); + if(MPI_result != MPI_SUCCESS) { + fprintf(stderr, "Failed to get the number of pvars.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + + for(i = 0; i < num; i++) { + name_len = desc_len = 256; + MPI_T_pvar_get_info(i, name, &name_len, &verbosity, + &var_class, &datatype, &enumtype, description, &desc_len, &bind, + &readonly, &continuous, &atomic); + if(MPI_result != MPI_SUCCESS || MPI_result == MPI_T_ERR_PVAR_NO_STARTSTOP) { + fprintf(stderr, "Failed to get pvar info.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + + if(strcmp(name, counter_names[rank]) == 0) { + index = i; + printf("[%d] %s -> %s\n", rank, name, description); + } + } + + /* Make sure we found the counters */ + if(index == -1) { + fprintf(stderr, "ERROR: Couldn't find the appropriate SPC counter in the MPI_T pvars.\n"); + return -1; + } + + long long value; + + MPI_T_pvar_session session; + MPI_T_pvar_handle handle; + /* Create the MPI_T sessions/handles for the counters and start the counters */ + MPI_result = MPI_T_pvar_session_create(&session); + if(MPI_result != MPI_SUCCESS) { + fprintf(stderr, "Failed to create MPI_T pvar session.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + + MPI_result = MPI_T_pvar_handle_alloc(session, index, NULL, &handle, &count); + if(MPI_result != MPI_SUCCESS) { + fprintf(stderr, "Failed to allocate the pvar handle.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + + MPI_result = MPI_T_pvar_start(session, handle); + if(MPI_result != MPI_SUCCESS) { + if(MPI_result != MPI_T_ERR_PVAR_NO_STARTSTOP) { + fprintf(stderr, "Failed to start the pvar session.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + } + + int message_size = 1, expected_bytes = 0; + while(message_size <= MAX_SIZE) { + expected_bytes += message_size; + message_exchange(1, message_size); + message_size *= 10; + } + + MPI_result = MPI_T_pvar_read(session, handle, &value); + if(MPI_result != MPI_SUCCESS) { + fprintf(stderr, "Failed to read the pvar.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + + /* Print the counter values in order by rank */ + for(i = 0; i < 2; i++) { + if(i == rank) { + printf("[%d] Value Read: %lld\n", rank, value); + fflush(stdout); + if(value != expected_bytes){ + fprintf(stderr, "The counter value is inaccurate! It is '%d'. It should be '%d'\n", value, expected_bytes); + MPI_Abort(MPI_COMM_WORLD, MPI_ERR_OTHER); + } + } + MPI_Barrier(MPI_COMM_WORLD); + } + /* Stop the MPI_T session, free the handle, and then free the session */ + MPI_result = MPI_T_pvar_stop(session, handle); + if(MPI_result != MPI_SUCCESS) { + if(MPI_result != MPI_T_ERR_PVAR_NO_STARTSTOP) { + fprintf(stderr, "Failed to stop the pvar session.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + } + + MPI_result = MPI_T_pvar_handle_free(session, &handle); + if(MPI_result != MPI_SUCCESS) { + fprintf(stderr, "Failed to free the pvar handle.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + + MPI_result = MPI_T_pvar_session_free(&session); + if(MPI_result != MPI_SUCCESS) { + fprintf(stderr, "Failed to free the pvar session.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + + MPI_result = MPI_T_finalize(); + if(MPI_result != MPI_SUCCESS) { + fprintf(stderr, "Failed to finalize MPI_T.\n"); + MPI_Abort(MPI_COMM_WORLD, MPI_result); + } + + MPI_Finalize(); + + return EXIT_SUCCESS; +} From ec4b8935113ae073a24fc0ac3933db2a2eee6c60 Mon Sep 17 00:00:00 2001 From: David Eberius Date: Wed, 21 Feb 2018 15:23:15 -0500 Subject: [PATCH 09/12] Fixed copyright dates. --- configure.ac | 2 +- examples/Makefile | 2 +- examples/Makefile.include | 2 +- ompi/mca/pml/ob1/pml_ob1_isend.c | 2 +- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 2 +- ompi/mca/pml/ob1/pml_ob1_sendreq.c | 2 +- ompi/mpi/c/allgather.c | 2 +- ompi/mpi/c/allreduce.c | 2 +- ompi/mpi/c/alltoall.c | 2 +- ompi/mpi/c/bcast.c | 2 +- ompi/mpi/c/gather.c | 2 +- ompi/mpi/c/init.c | 2 +- ompi/mpi/c/init_thread.c | 2 +- ompi/mpi/c/irecv.c | 2 +- ompi/mpi/c/isend.c | 2 +- ompi/mpi/c/recv.c | 2 +- ompi/mpi/c/reduce.c | 2 +- ompi/mpi/c/scatter.c | 2 +- ompi/mpi/c/send.c | 2 +- ompi/mpi/c/sendrecv.c | 2 +- ompi/mpi/c/sendrecv_replace.c | 2 +- ompi/runtime/Makefile.am | 2 +- opal/mca/base/mca_base_pvar.h | 3 +++ test/Makefile.am | 2 +- 24 files changed, 26 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index a5754bb2785..c4e7b7e57ff 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ # Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana # University Research and Technology # Corporation. All rights reserved. -# Copyright (c) 2004-2017 The University of Tennessee and The University +# Copyright (c) 2004-2018 The University of Tennessee and The University # of Tennessee Research Foundation. All rights # reserved. # Copyright (c) 2004-2007 High Performance Computing Center Stuttgart, diff --git a/examples/Makefile b/examples/Makefile index 7699b5255a5..f7d76874ced 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -2,7 +2,7 @@ # Copyright (c) 2004-2005 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 +# Copyright (c) 2004-2018 The University of Tennessee and The University # of Tennessee Research Foundation. All rights # reserved. # Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, diff --git a/examples/Makefile.include b/examples/Makefile.include index acd58d82c00..85518a1fce3 100644 --- a/examples/Makefile.include +++ b/examples/Makefile.include @@ -3,7 +3,7 @@ # Copyright (c) 2004-2005 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 +# Copyright (c) 2004-2018 The University of Tennessee and The University # of Tennessee Research Foundation. All rights # reserved. # Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, diff --git a/ompi/mca/pml/ob1/pml_ob1_isend.c b/ompi/mca/pml/ob1/pml_ob1_isend.c index b20ae4b7857..b019b7a980a 100644 --- a/ompi/mca/pml/ob1/pml_ob1_isend.c +++ b/ompi/mca/pml/ob1/pml_ob1_isend.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index 1f123a2e649..502f04e0694 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index 4d7349043a0..b51bfe1c814 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/allgather.c b/ompi/mpi/c/allgather.c index 66474dabf7e..aa7793ccf47 100644 --- a/ompi/mpi/c/allgather.c +++ b/ompi/mpi/c/allgather.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/allreduce.c b/ompi/mpi/c/allreduce.c index c8d97a185e9..655e51d6300 100644 --- a/ompi/mpi/c/allreduce.c +++ b/ompi/mpi/c/allreduce.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/alltoall.c b/ompi/mpi/c/alltoall.c index ab734337a7c..8b7b9c59f3d 100644 --- a/ompi/mpi/c/alltoall.c +++ b/ompi/mpi/c/alltoall.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/bcast.c b/ompi/mpi/c/bcast.c index 2f30cdc428c..586ef0e7ad7 100644 --- a/ompi/mpi/c/bcast.c +++ b/ompi/mpi/c/bcast.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/gather.c b/ompi/mpi/c/gather.c index 9a37f2e7b10..f8509c5b20f 100644 --- a/ompi/mpi/c/gather.c +++ b/ompi/mpi/c/gather.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/init.c b/ompi/mpi/c/init.c index ffa4b62a362..66bea74dddd 100644 --- a/ompi/mpi/c/init.c +++ b/ompi/mpi/c/init.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/init_thread.c b/ompi/mpi/c/init_thread.c index 609fd7e4a74..a8b42b3e024 100644 --- a/ompi/mpi/c/init_thread.c +++ b/ompi/mpi/c/init_thread.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/irecv.c b/ompi/mpi/c/irecv.c index f177923bc83..139f633d591 100644 --- a/ompi/mpi/c/irecv.c +++ b/ompi/mpi/c/irecv.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/isend.c b/ompi/mpi/c/isend.c index cea1afd4dc0..9335814d35e 100644 --- a/ompi/mpi/c/isend.c +++ b/ompi/mpi/c/isend.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/recv.c b/ompi/mpi/c/recv.c index 5387f816e87..f92ee3c72a1 100644 --- a/ompi/mpi/c/recv.c +++ b/ompi/mpi/c/recv.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/reduce.c b/ompi/mpi/c/reduce.c index 96256f7e257..3091aac6518 100644 --- a/ompi/mpi/c/reduce.c +++ b/ompi/mpi/c/reduce.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/scatter.c b/ompi/mpi/c/scatter.c index 8cad2d01adc..8942224d3cb 100644 --- a/ompi/mpi/c/scatter.c +++ b/ompi/mpi/c/scatter.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/send.c b/ompi/mpi/c/send.c index c17e9c57ae0..b44ef219aed 100644 --- a/ompi/mpi/c/send.c +++ b/ompi/mpi/c/send.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/sendrecv.c b/ompi/mpi/c/sendrecv.c index aa818a0b9ff..57beaccaa0e 100644 --- a/ompi/mpi/c/sendrecv.c +++ b/ompi/mpi/c/sendrecv.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/mpi/c/sendrecv_replace.c b/ompi/mpi/c/sendrecv_replace.c index 5117b2c3c73..28167e5f6fe 100644 --- a/ompi/mpi/c/sendrecv_replace.c +++ b/ompi/mpi/c/sendrecv_replace.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, diff --git a/ompi/runtime/Makefile.am b/ompi/runtime/Makefile.am index c4dd14bee1c..6d1400eae30 100644 --- a/ompi/runtime/Makefile.am +++ b/ompi/runtime/Makefile.am @@ -2,7 +2,7 @@ # Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana # University Research and Technology # Corporation. All rights reserved. -# Copyright (c) 2004-2017 The University of Tennessee and The University +# Copyright (c) 2004-2018 The University of Tennessee and The University # of Tennessee Research Foundation. All rights # reserved. # Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, diff --git a/opal/mca/base/mca_base_pvar.h b/opal/mca/base/mca_base_pvar.h index e305cbcbfd6..03ff53b98f8 100644 --- a/opal/mca/base/mca_base_pvar.h +++ b/opal/mca/base/mca_base_pvar.h @@ -2,6 +2,9 @@ /* * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2018 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. * * Additional copyrights may follow * diff --git a/test/Makefile.am b/test/Makefile.am index a47e905ef0d..dff34e825f8 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,7 +2,7 @@ # Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana # University Research and Technology # Corporation. All rights reserved. -# Copyright (c) 2004-2015 The University of Tennessee and The University +# Copyright (c) 2004-2018 The University of Tennessee and The University # of Tennessee Research Foundation. All rights # reserved. # Copyright (c) 2004-2009 High Performance Computing Center Stuttgart, From 7f51bc12a15f2c6add0c9c46f633809bdcb7a2b6 Mon Sep 17 00:00:00 2001 From: David Eberius Date: Thu, 1 Mar 2018 13:59:31 -0500 Subject: [PATCH 10/12] Made the dump output more readable and added more top level counters. --- ompi/mpi/c/allgatherv.c | 5 +- ompi/mpi/c/barrier.c | 5 +- ompi/mpi/c/bsend.c | 5 +- ompi/mpi/c/cancel.c | 5 +- ompi/mpi/c/gatherv.c | 5 +- ompi/mpi/c/get.c | 5 +- ompi/mpi/c/iallgather.c | 5 +- ompi/mpi/c/iallgatherv.c | 5 +- ompi/mpi/c/iallreduce.c | 5 +- ompi/mpi/c/ialltoall.c | 5 +- ompi/mpi/c/ialltoallv.c | 5 +- ompi/mpi/c/ialltoallw.c | 5 +- ompi/mpi/c/ibarrier.c | 5 +- ompi/mpi/c/ibcast.c | 5 +- ompi/mpi/c/ibsend.c | 5 +- ompi/mpi/c/igather.c | 5 +- ompi/mpi/c/iprobe.c | 5 +- ompi/mpi/c/ireduce.c | 5 +- ompi/mpi/c/ireduce_scatter.c | 5 +- ompi/mpi/c/ireduce_scatter_block.c | 5 +- ompi/mpi/c/irsend.c | 5 +- ompi/mpi/c/iscan.c | 5 +- ompi/mpi/c/iscatter.c | 5 +- ompi/mpi/c/iscatterv.c | 5 +- ompi/mpi/c/issend.c | 5 +- ompi/mpi/c/mrecv.c | 6 ++ ompi/mpi/c/neighbor_allgather.c | 5 +- ompi/mpi/c/neighbor_allgatherv.c | 5 +- ompi/mpi/c/neighbor_alltoall.c | 5 +- ompi/mpi/c/neighbor_alltoallv.c | 5 +- ompi/mpi/c/neighbor_alltoallw.c | 5 +- ompi/mpi/c/probe.c | 5 +- ompi/mpi/c/put.c | 5 +- ompi/mpi/c/rget.c | 5 +- ompi/mpi/c/rput.c | 5 +- ompi/mpi/c/rsend.c | 6 +- ompi/mpi/c/scan.c | 5 +- ompi/mpi/c/scatterv.c | 5 +- ompi/mpi/c/ssend.c | 5 +- ompi/mpi/c/test.c | 5 +- ompi/mpi/c/testall.c | 5 +- ompi/mpi/c/testany.c | 5 +- ompi/mpi/c/testsome.c | 5 +- ompi/mpi/c/wait.c | 5 +- ompi/mpi/c/waitall.c | 5 +- ompi/mpi/c/waitany.c | 5 +- ompi/mpi/c/waitsome.c | 5 +- ompi/mpi/c/wtick.c | 5 +- ompi/mpi/c/wtime.c | 5 +- ompi/runtime/ompi_spc.c | 106 ++++++++++++++++++++++++++++- ompi/runtime/ompi_spc.h | 49 +++++++++++++ 51 files changed, 351 insertions(+), 51 deletions(-) diff --git a/ompi/mpi/c/allgatherv.c b/ompi/mpi/c/allgatherv.c index 86668682fb5..80c1871af9e 100644 --- a/ompi/mpi/c/allgatherv.c +++ b/ompi/mpi/c/allgatherv.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -32,6 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int i, size, err; + SPC_RECORD(OMPI_ALLGATHERV, 1); + MEMCHECKER( int rank; ptrdiff_t ext; diff --git a/ompi/mpi/c/barrier.c b/ompi/mpi/c/barrier.c index 297e41b0a33..e0e328b8ae9 100644 --- a/ompi/mpi/c/barrier.c +++ b/ompi/mpi/c/barrier.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -25,6 +25,7 @@ #include "ompi/communicator/communicator.h" #include "ompi/errhandler/errhandler.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -40,6 +41,8 @@ int MPI_Barrier(MPI_Comm comm) { int err = MPI_SUCCESS; + SPC_RECORD(OMPI_BARRIER, 1); + MEMCHECKER( memchecker_comm(comm); ); diff --git a/ompi/mpi/c/bsend.c b/ompi/mpi/c/bsend.c index 2d96328f5f8..785516c25b5 100644 --- a/ompi/mpi/c/bsend.c +++ b/ompi/mpi/c/bsend.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -31,6 +31,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/mca/pml/base/pml_base_bsend.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -46,6 +47,8 @@ int MPI_Bsend(const void *buf, int count, MPI_Datatype type, int dest, int tag, { int rc = MPI_SUCCESS; + SPC_RECORD(OMPI_BSEND, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_call(&opal_memchecker_base_isdefined, buf, count, type); diff --git a/ompi/mpi/c/cancel.c b/ompi/mpi/c/cancel.c index 0b5db9e0e3d..f259ced177d 100644 --- a/ompi/mpi/c/cancel.c +++ b/ompi/mpi/c/cancel.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -28,6 +28,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -43,6 +44,8 @@ int MPI_Cancel(MPI_Request *request) { int rc; + SPC_RECORD(OMPI_CANCEL, 1); + MEMCHECKER( memchecker_request(request); ); diff --git a/ompi/mpi/c/gatherv.c b/ompi/mpi/c/gatherv.c index c31cbaba1d6..c341b5095f6 100644 --- a/ompi/mpi/c/gatherv.c +++ b/ompi/mpi/c/gatherv.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -47,6 +48,8 @@ int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int i, size, err; + SPC_RECORD(OMPI_GATHERV, 1); + MEMCHECKER( ptrdiff_t ext; diff --git a/ompi/mpi/c/get.c b/ompi/mpi/c/get.c index 4f2e9037828..b35ab4e742c 100644 --- a/ompi/mpi/c/get.c +++ b/ompi/mpi/c/get.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/win/win.h" #include "ompi/mca/osc/osc.h" #include "ompi/datatype/ompi_datatype.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,6 +49,8 @@ int MPI_Get(void *origin_addr, int origin_count, { int rc; + SPC_RECORD(OMPI_GET, 1); + if (MPI_PARAM_CHECK) { rc = OMPI_SUCCESS; diff --git a/ompi/mpi/c/iallgather.c b/ompi/mpi/c/iallgather.c index e8259305616..67c91fd1dea 100644 --- a/ompi/mpi/c/iallgather.c +++ b/ompi/mpi/c/iallgather.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -32,6 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Iallgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int err; + SPC_RECORD(OMPI_IALLGATHER, 1); + MEMCHECKER( int rank; ptrdiff_t ext; diff --git a/ompi/mpi/c/iallgatherv.c b/ompi/mpi/c/iallgatherv.c index 0ec3c486702..bb28ce328e0 100644 --- a/ompi/mpi/c/iallgatherv.c +++ b/ompi/mpi/c/iallgatherv.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -32,6 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Iallgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int i, size, err; + SPC_RECORD(OMPI_IALLGATHERV, 1); + MEMCHECKER( int rank; ptrdiff_t ext; diff --git a/ompi/mpi/c/iallreduce.c b/ompi/mpi/c/iallreduce.c index a4ca64e4e45..709b159294d 100644 --- a/ompi/mpi/c/iallreduce.c +++ b/ompi/mpi/c/iallreduce.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -32,6 +32,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,6 +49,8 @@ int MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, { int err; + SPC_RECORD(OMPI_IALLREDUCE, 1); + MEMCHECKER( memchecker_datatype(datatype); memchecker_comm(comm); diff --git a/ompi/mpi/c/ialltoall.c b/ompi/mpi/c/ialltoall.c index 3e94236717d..232c1123efa 100644 --- a/ompi/mpi/c/ialltoall.c +++ b/ompi/mpi/c/ialltoall.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -32,6 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -50,6 +51,8 @@ int MPI_Ialltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype, size_t sendtype_size, recvtype_size; int err; + SPC_RECORD(OMPI_IALLTOALL, 1); + MEMCHECKER( memchecker_comm(comm); if (MPI_IN_PLACE != sendbuf) { diff --git a/ompi/mpi/c/ialltoallv.c b/ompi/mpi/c/ialltoallv.c index 1997aa5e2fa..429297794ef 100644 --- a/ompi/mpi/c/ialltoallv.c +++ b/ompi/mpi/c/ialltoallv.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -31,6 +31,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Ialltoallv(const void *sendbuf, const int sendcounts[], const int sdispl { int i, size, err; + SPC_RECORD(OMPI_IALLTOALLV, 1); + MEMCHECKER( ptrdiff_t recv_ext; ptrdiff_t send_ext; diff --git a/ompi/mpi/c/ialltoallw.c b/ompi/mpi/c/ialltoallw.c index 81c11aec7a1..82111c510ff 100644 --- a/ompi/mpi/c/ialltoallw.c +++ b/ompi/mpi/c/ialltoallw.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -31,6 +31,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Ialltoallw(const void *sendbuf, const int sendcounts[], const int sdispl { int i, size, err; + SPC_RECORD(OMPI_IALLTOALLW, 1); + MEMCHECKER( ptrdiff_t recv_ext; ptrdiff_t send_ext; diff --git a/ompi/mpi/c/ibarrier.c b/ompi/mpi/c/ibarrier.c index 76c45aa3bc3..45ec69c7192 100644 --- a/ompi/mpi/c/ibarrier.c +++ b/ompi/mpi/c/ibarrier.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -27,6 +27,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -42,6 +43,8 @@ int MPI_Ibarrier(MPI_Comm comm, MPI_Request *request) { int err = MPI_SUCCESS; + SPC_RECORD(OMPI_IBARRIER, 1); + MEMCHECKER( memchecker_comm(comm); ); diff --git a/ompi/mpi/c/ibcast.c b/ompi/mpi/c/ibcast.c index 331d024ef3e..5eeaf5708ea 100644 --- a/ompi/mpi/c/ibcast.c +++ b/ompi/mpi/c/ibcast.c @@ -2,7 +2,7 @@ * Copyright (c) 2012 Oak Rigde National Laboratory. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2017 The University of Tennessee and The University + * Copyright (c) 2017-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * $COPYRIGHT$ @@ -20,6 +20,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -36,6 +37,8 @@ int MPI_Ibcast(void *buffer, int count, MPI_Datatype datatype, { int err; + SPC_RECORD(OMPI_IBCAST, 1); + MEMCHECKER( memchecker_datatype(datatype); memchecker_call(&opal_memchecker_base_isdefined, buffer, count, datatype); diff --git a/ompi/mpi/c/ibsend.c b/ompi/mpi/c/ibsend.c index ec9a127ab2c..89686c23e39 100644 --- a/ompi/mpi/c/ibsend.c +++ b/ompi/mpi/c/ibsend.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -31,6 +31,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/mca/pml/base/pml_base_bsend.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -47,6 +48,8 @@ int MPI_Ibsend(const void *buf, int count, MPI_Datatype type, int dest, { int rc = MPI_SUCCESS; + SPC_RECORD(OMPI_IBSEND, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_call(&opal_memchecker_base_isdefined, buf, count, type); diff --git a/ompi/mpi/c/igather.c b/ompi/mpi/c/igather.c index c1777b5cec4..55d1ec317c7 100644 --- a/ompi/mpi/c/igather.c +++ b/ompi/mpi/c/igather.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -32,6 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Igather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int err; + SPC_RECORD(OMPI_IGATHER, 1); + MEMCHECKER( int rank; ptrdiff_t ext; diff --git a/ompi/mpi/c/iprobe.c b/ompi/mpi/c/iprobe.c index f42da3f9b7c..978bbbb79dc 100644 --- a/ompi/mpi/c/iprobe.c +++ b/ompi/mpi/c/iprobe.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -27,6 +27,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/memchecker.h" #include "ompi/request/request.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -42,6 +43,8 @@ int MPI_Iprobe(int source, int tag, MPI_Comm comm, int *flag, MPI_Status *status { int rc; + SPC_RECORD(OMPI_IPROBE, 1); + MEMCHECKER( memchecker_comm(comm); ); diff --git a/ompi/mpi/c/ireduce.c b/ompi/mpi/c/ireduce.c index 4b1d47d7967..9871dc60c1f 100644 --- a/ompi/mpi/c/ireduce.c +++ b/ompi/mpi/c/ireduce.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -32,6 +32,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,6 +49,8 @@ int MPI_Ireduce(const void *sendbuf, void *recvbuf, int count, { int err; + SPC_RECORD(OMPI_IREDUCE, 1); + MEMCHECKER( memchecker_datatype(datatype); memchecker_comm(comm); diff --git a/ompi/mpi/c/ireduce_scatter.c b/ompi/mpi/c/ireduce_scatter.c index 4d700ba11e5..e159a3d31f1 100644 --- a/ompi/mpi/c/ireduce_scatter.c +++ b/ompi/mpi/c/ireduce_scatter.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -32,6 +32,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,6 +49,8 @@ int MPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts { int i, err, size, count; + SPC_RECORD(OMPI_IREDUCE_SCATTER, 1); + MEMCHECKER( int rank; int count; diff --git a/ompi/mpi/c/ireduce_scatter_block.c b/ompi/mpi/c/ireduce_scatter_block.c index 69f008c95d7..4deca3fd53e 100644 --- a/ompi/mpi/c/ireduce_scatter_block.c +++ b/ompi/mpi/c/ireduce_scatter_block.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -32,6 +32,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Ireduce_scatter_block(const void *sendbuf, void *recvbuf, int recvcount, { int err; + SPC_RECORD(OMPI_IREDUCE_SCATTER_BLOCK, 1); + MEMCHECKER( memchecker_comm(comm); memchecker_datatype(datatype); diff --git a/ompi/mpi/c/irsend.c b/ompi/mpi/c/irsend.c index bc4dd10ab02..0de69f6c13d 100644 --- a/ompi/mpi/c/irsend.c +++ b/ompi/mpi/c/irsend.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -31,6 +31,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -47,6 +48,8 @@ int MPI_Irsend(const void *buf, int count, MPI_Datatype type, int dest, { int rc; + SPC_RECORD(OMPI_IRSEND, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_call(&opal_memchecker_base_isdefined, buf, count, type); diff --git a/ompi/mpi/c/iscan.c b/ompi/mpi/c/iscan.c index 33145e704f2..7fef3a693ac 100644 --- a/ompi/mpi/c/iscan.c +++ b/ompi/mpi/c/iscan.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -31,6 +31,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -47,6 +48,8 @@ int MPI_Iscan(const void *sendbuf, void *recvbuf, int count, { int err; + SPC_RECORD(OMPI_ISCAN, 1); + MEMCHECKER( memchecker_datatype(datatype); memchecker_comm(comm); diff --git a/ompi/mpi/c/iscatter.c b/ompi/mpi/c/iscatter.c index 683200a0b4e..c5ba1ca41a4 100644 --- a/ompi/mpi/c/iscatter.c +++ b/ompi/mpi/c/iscatter.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -32,6 +32,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -49,6 +50,8 @@ int MPI_Iscatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype, { int err; + SPC_RECORD(OMPI_ISCATTER, 1); + MEMCHECKER( memchecker_comm(comm); if(OMPI_COMM_IS_INTRA(comm)) { diff --git a/ompi/mpi/c/iscatterv.c b/ompi/mpi/c/iscatterv.c index a0ec2eb785f..a571f6e9baa 100644 --- a/ompi/mpi/c/iscatterv.c +++ b/ompi/mpi/c/iscatterv.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -47,6 +48,8 @@ int MPI_Iscatterv(const void *sendbuf, const int sendcounts[], const int displs[ { int i, size, err; + SPC_RECORD(OMPI_ISCATTERV, 1); + MEMCHECKER( ptrdiff_t ext; diff --git a/ompi/mpi/c/issend.c b/ompi/mpi/c/issend.c index ef573087dbb..3e2037c355a 100644 --- a/ompi/mpi/c/issend.c +++ b/ompi/mpi/c/issend.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -46,6 +47,8 @@ int MPI_Issend(const void *buf, int count, MPI_Datatype type, int dest, { int rc = MPI_SUCCESS; + SPC_RECORD(OMPI_ISSEND, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_call(&opal_memchecker_base_isdefined, buf, count, type); diff --git a/ompi/mpi/c/mrecv.c b/ompi/mpi/c/mrecv.c index bf1d6b11e9f..7f1748a1bbe 100644 --- a/ompi/mpi/c/mrecv.c +++ b/ompi/mpi/c/mrecv.c @@ -3,6 +3,9 @@ * Copyright (c) 2012-2013 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -18,6 +21,7 @@ #include "ompi/memchecker.h" #include "ompi/request/request.h" #include "ompi/message/message.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -35,6 +39,8 @@ int MPI_Mrecv(void *buf, int count, MPI_Datatype type, int rc = MPI_SUCCESS; ompi_communicator_t *comm; + SPC_RECORD(OMPI_MRECV, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_message(message); diff --git a/ompi/mpi/c/neighbor_allgather.c b/ompi/mpi/c/neighbor_allgather.c index 88df4e78c5c..982ed8b440c 100644 --- a/ompi/mpi/c/neighbor_allgather.c +++ b/ompi/mpi/c/neighbor_allgather.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -35,6 +35,7 @@ #include "ompi/memchecker.h" #include "ompi/mca/topo/topo.h" #include "ompi/mca/topo/base/base.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -52,6 +53,8 @@ int MPI_Neighbor_allgather(const void *sendbuf, int sendcount, MPI_Datatype send { int err; + SPC_RECORD(OMPI_NEIGHBOR_ALLGATHER, 1); + MEMCHECKER( int rank; ptrdiff_t ext; diff --git a/ompi/mpi/c/neighbor_allgatherv.c b/ompi/mpi/c/neighbor_allgatherv.c index 2c775a9e5bb..4aa82a47d9b 100644 --- a/ompi/mpi/c/neighbor_allgatherv.c +++ b/ompi/mpi/c/neighbor_allgatherv.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -36,6 +36,7 @@ #include "ompi/memchecker.h" #include "ompi/mca/topo/topo.h" #include "ompi/mca/topo/base/base.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -53,6 +54,8 @@ int MPI_Neighbor_allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sen { int in_size, out_size, err; + SPC_RECORD(OMPI_NEIGHBOR_ALLGATHERV, 1); + MEMCHECKER( int rank; ptrdiff_t ext; diff --git a/ompi/mpi/c/neighbor_alltoall.c b/ompi/mpi/c/neighbor_alltoall.c index 35a39cbcbc2..280ee9d32e6 100644 --- a/ompi/mpi/c/neighbor_alltoall.c +++ b/ompi/mpi/c/neighbor_alltoall.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -34,6 +34,7 @@ #include "ompi/memchecker.h" #include "ompi/mca/topo/topo.h" #include "ompi/mca/topo/base/base.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -52,6 +53,8 @@ int MPI_Neighbor_alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendt size_t sendtype_size, recvtype_size; int err; + SPC_RECORD(OMPI_NEIGHBOR_ALLTOALL, 1); + MEMCHECKER( memchecker_comm(comm); if (MPI_IN_PLACE != sendbuf) { diff --git a/ompi/mpi/c/neighbor_alltoallv.c b/ompi/mpi/c/neighbor_alltoallv.c index 5004e6b42d6..77955d05659 100644 --- a/ompi/mpi/c/neighbor_alltoallv.c +++ b/ompi/mpi/c/neighbor_alltoallv.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -34,6 +34,7 @@ #include "ompi/memchecker.h" #include "ompi/mca/topo/topo.h" #include "ompi/mca/topo/base/base.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -53,6 +54,8 @@ int MPI_Neighbor_alltoallv(const void *sendbuf, const int sendcounts[], const in int i, err; int indegree, outdegree; + SPC_RECORD(OMPI_NEIGHBOR_ALLTOALLV, 1); + MEMCHECKER( ptrdiff_t recv_ext; ptrdiff_t send_ext; diff --git a/ompi/mpi/c/neighbor_alltoallw.c b/ompi/mpi/c/neighbor_alltoallw.c index 5d339bfa6d6..6ab8854f8be 100644 --- a/ompi/mpi/c/neighbor_alltoallw.c +++ b/ompi/mpi/c/neighbor_alltoallw.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -34,6 +34,7 @@ #include "ompi/memchecker.h" #include "ompi/mca/topo/topo.h" #include "ompi/mca/topo/base/base.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -53,6 +54,8 @@ int MPI_Neighbor_alltoallw(const void *sendbuf, const int sendcounts[], const MP int i, err; int indegree, outdegree; + SPC_RECORD(OMPI_NEIGHBOR_ALLTOALLW, 1); + MEMCHECKER( ptrdiff_t recv_ext; ptrdiff_t send_ext; diff --git a/ompi/mpi/c/probe.c b/ompi/mpi/c/probe.c index c3ce1e160e2..67977bad1be 100644 --- a/ompi/mpi/c/probe.c +++ b/ompi/mpi/c/probe.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -27,6 +27,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/memchecker.h" #include "ompi/request/request.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -42,6 +43,8 @@ int MPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status) { int rc; + SPC_RECORD(OMPI_PROBE, 1); + MEMCHECKER( memchecker_comm(comm); ); diff --git a/ompi/mpi/c/put.c b/ompi/mpi/c/put.c index 441b81bb667..675a6f60f49 100644 --- a/ompi/mpi/c/put.c +++ b/ompi/mpi/c/put.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -31,6 +31,7 @@ #include "ompi/win/win.h" #include "ompi/mca/osc/osc.h" #include "ompi/datatype/ompi_datatype.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,6 +49,8 @@ int MPI_Put(const void *origin_addr, int origin_count, MPI_Datatype origin_datat { int rc; + SPC_RECORD(OMPI_PUT, 1); + if (MPI_PARAM_CHECK) { rc = OMPI_SUCCESS; diff --git a/ompi/mpi/c/rget.c b/ompi/mpi/c/rget.c index 34c5e9dd5e7..8c45e760fbc 100644 --- a/ompi/mpi/c/rget.c +++ b/ompi/mpi/c/rget.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/win/win.h" #include "ompi/mca/osc/osc.h" #include "ompi/datatype/ompi_datatype.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,6 +49,8 @@ int MPI_Rget(void *origin_addr, int origin_count, { int rc; + SPC_RECORD(OMPI_RGET, 1); + if (MPI_PARAM_CHECK) { rc = OMPI_SUCCESS; diff --git a/ompi/mpi/c/rput.c b/ompi/mpi/c/rput.c index 6d66501b2cb..42ac6d8889b 100644 --- a/ompi/mpi/c/rput.c +++ b/ompi/mpi/c/rput.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -31,6 +31,7 @@ #include "ompi/win/win.h" #include "ompi/mca/osc/osc.h" #include "ompi/datatype/ompi_datatype.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -48,6 +49,8 @@ int MPI_Rput(const void *origin_addr, int origin_count, MPI_Datatype origin_data { int rc; + SPC_RECORD(OMPI_RPUT, 1); + if (MPI_PARAM_CHECK) { rc = OMPI_SUCCESS; diff --git a/ompi/mpi/c/rsend.c b/ompi/mpi/c/rsend.c index 5ee5e7f1d38..8f82e035255 100644 --- a/ompi/mpi/c/rsend.c +++ b/ompi/mpi/c/rsend.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,7 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/mca/pml/pml.h" #include "ompi/memchecker.h" - +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -46,6 +46,8 @@ int MPI_Rsend(const void *buf, int count, MPI_Datatype type, int dest, int tag, { int rc = MPI_SUCCESS; + SPC_RECORD(OMPI_RSEND, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_call(&opal_memchecker_base_isdefined, buf, count, type); diff --git a/ompi/mpi/c/scan.c b/ompi/mpi/c/scan.c index 242ccf030ea..e189fe9df26 100644 --- a/ompi/mpi/c/scan.c +++ b/ompi/mpi/c/scan.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -31,6 +31,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/op/op.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -47,6 +48,8 @@ int MPI_Scan(const void *sendbuf, void *recvbuf, int count, { int err; + SPC_RECORD(OMPI_SCAN, 1); + MEMCHECKER( memchecker_datatype(datatype); memchecker_comm(comm); diff --git a/ompi/mpi/c/scatterv.c b/ompi/mpi/c/scatterv.c index 2cfe3163e27..5ff59e89d32 100644 --- a/ompi/mpi/c/scatterv.c +++ b/ompi/mpi/c/scatterv.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -47,6 +48,8 @@ int MPI_Scatterv(const void *sendbuf, const int sendcounts[], const int displs[] { int i, size, err; + SPC_RECORD(OMPI_SCATTERV, 1); + MEMCHECKER( ptrdiff_t ext; diff --git a/ompi/mpi/c/ssend.c b/ompi/mpi/c/ssend.c index 8f27f054957..b8a35a4ba08 100644 --- a/ompi/mpi/c/ssend.c +++ b/ompi/mpi/c/ssend.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/mca/pml/pml.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -45,6 +46,8 @@ int MPI_Ssend(const void *buf, int count, MPI_Datatype type, int dest, int tag, { int rc = MPI_SUCCESS; + SPC_RECORD(OMPI_SSEND, 1); + MEMCHECKER( memchecker_datatype(type); memchecker_call(&opal_memchecker_base_isdefined, buf, count, type); diff --git a/ompi/mpi/c/test.c b/ompi/mpi/c/test.c index 8e29b3c4cf0..4d241b49287 100644 --- a/ompi/mpi/c/test.c +++ b/ompi/mpi/c/test.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -27,6 +27,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -42,6 +43,8 @@ int MPI_Test(MPI_Request *request, int *completed, MPI_Status *status) { int rc; + SPC_RECORD(OMPI_TEST, 1); + MEMCHECKER( memchecker_request (request); ); diff --git a/ompi/mpi/c/testall.c b/ompi/mpi/c/testall.c index 46528bce49a..e4760d26110 100644 --- a/ompi/mpi/c/testall.c +++ b/ompi/mpi/c/testall.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -44,6 +45,8 @@ static const char FUNC_NAME[] = "MPI_Testall"; int MPI_Testall(int count, MPI_Request requests[], int *flag, MPI_Status statuses[]) { + SPC_RECORD(OMPI_TESTALL, 1); + MEMCHECKER( int j; for (j = 0; j < count; j++){ diff --git a/ompi/mpi/c/testany.c b/ompi/mpi/c/testany.c index cc21513f514..acb0b1a5775 100644 --- a/ompi/mpi/c/testany.c +++ b/ompi/mpi/c/testany.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -43,6 +44,8 @@ static const char FUNC_NAME[] = "MPI_Testany"; int MPI_Testany(int count, MPI_Request requests[], int *indx, int *completed, MPI_Status *status) { + SPC_RECORD(OMPI_TESTANY, 1); + MEMCHECKER( int j; for (j = 0; j < count; j++){ diff --git a/ompi/mpi/c/testsome.c b/ompi/mpi/c/testsome.c index 16bc677b328..e97674503d4 100644 --- a/ompi/mpi/c/testsome.c +++ b/ompi/mpi/c/testsome.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -45,6 +46,8 @@ int MPI_Testsome(int incount, MPI_Request requests[], int *outcount, int indices[], MPI_Status statuses[]) { + SPC_RECORD(OMPI_TESTSOME, 1); + MEMCHECKER( int j; for (j = 0; j < incount; j++){ diff --git a/ompi/mpi/c/wait.c b/ompi/mpi/c/wait.c index c8e8a521b77..1ce8bd19783 100644 --- a/ompi/mpi/c/wait.c +++ b/ompi/mpi/c/wait.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2013 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -27,6 +27,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -40,6 +41,8 @@ static const char FUNC_NAME[] = "MPI_Wait"; int MPI_Wait(MPI_Request *request, MPI_Status *status) { + SPC_RECORD(OMPI_WAIT, 1); + MEMCHECKER( memchecker_request(request); ); diff --git a/ompi/mpi/c/waitall.c b/ompi/mpi/c/waitall.c index d70d4684d76..dd9d4317787 100644 --- a/ompi/mpi/c/waitall.c +++ b/ompi/mpi/c/waitall.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -29,6 +29,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -42,6 +43,8 @@ static const char FUNC_NAME[] = "MPI_Waitall"; int MPI_Waitall(int count, MPI_Request requests[], MPI_Status statuses[]) { + SPC_RECORD(OMPI_WAITALL, 1); + MEMCHECKER( int j; for (j = 0; j < count; j++){ diff --git a/ompi/mpi/c/waitany.c b/ompi/mpi/c/waitany.c index ead11415677..aa24433cf45 100644 --- a/ompi/mpi/c/waitany.c +++ b/ompi/mpi/c/waitany.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -43,6 +44,8 @@ static const char FUNC_NAME[] = "MPI_Waitany"; int MPI_Waitany(int count, MPI_Request requests[], int *indx, MPI_Status *status) { + SPC_RECORD(OMPI_WAITANY, 1); + MEMCHECKER( int j; for (j = 0; j < count; j++){ diff --git a/ompi/mpi/c/waitsome.c b/ompi/mpi/c/waitsome.c index 71723da40ad..eeb51f3d5b2 100644 --- a/ompi/mpi/c/waitsome.c +++ b/ompi/mpi/c/waitsome.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -30,6 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -45,6 +46,8 @@ int MPI_Waitsome(int incount, MPI_Request requests[], int *outcount, int indices[], MPI_Status statuses[]) { + SPC_RECORD(OMPI_WAITSOME, 1); + MEMCHECKER( int j; for (j = 0; j < incount; j++){ diff --git a/ompi/mpi/c/wtick.c b/ompi/mpi/c/wtick.c index a246288e777..985e70cc0a8 100644 --- a/ompi/mpi/c/wtick.c +++ b/ompi/mpi/c/wtick.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -34,6 +34,7 @@ #include MCA_timer_IMPLEMENTATION_HEADER #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/mpiruntime.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -44,6 +45,8 @@ double MPI_Wtick(void) { + SPC_RECORD(OMPI_WTICK, 1); + OPAL_CR_NOOP_PROGRESS(); /* diff --git a/ompi/mpi/c/wtime.c b/ompi/mpi/c/wtime.c index 2b72d27ba71..ffdd5b95ab5 100644 --- a/ompi/mpi/c/wtime.c +++ b/ompi/mpi/c/wtime.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 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 + * Copyright (c) 2004-2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -34,6 +34,7 @@ #include MCA_timer_IMPLEMENTATION_HEADER #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/mpiruntime.h" +#include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS @@ -46,6 +47,8 @@ double MPI_Wtime(void) { double wtime; + SPC_RECORD(OMPI_WTIME, 1); + /* * See https://github.com/open-mpi/ompi/issues/3003 to find out * what's happening here. diff --git a/ompi/runtime/ompi_spc.c b/ompi/runtime/ompi_spc.c index 8d53d914b1f..df8a30bca88 100644 --- a/ompi/runtime/ompi_spc.c +++ b/ompi/runtime/ompi_spc.c @@ -22,18 +22,67 @@ OMPI_DECLSPEC int mpi_t_disabled = 0; /* Array of names for each counter. Used for MPI_T and PAPI sde initialization */ OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { "OMPI_SEND", + "OMPI_BSEND", + "OMPI_RSEND", + "OMPI_SSEND", "OMPI_RECV", + "OMPI_MRECV", "OMPI_ISEND", + "OMPI_IBSEND", + "OMPI_IRSEND", + "OMPI_ISSEND", "OMPI_IRECV", "OMPI_SENDRECV", "OMPI_SENDRECV_REPLACE", + "OMPI_PUT", + "OMPI_RPUT", + "OMPI_GET", + "OMPI_RGET", + "OMPI_PROBE", + "OMPI_IPROBE", "OMPI_BCAST", + "OMPI_IBCAST", "OMPI_REDUCE", + "OMPI_IREDUCE", + "OMPI_IREDUCE_SCATTER", + "OMPI_IREDUCE_SCATTER_BLOCK", "OMPI_ALLREDUCE", + "OMPI_IALLREDUCE", + "OMPI_SCAN", + "OMPI_ISCAN", "OMPI_SCATTER", + "OMPI_SCATTERV", + "OMPI_ISCATTER", + "OMPI_ISCATTERV", "OMPI_GATHER", + "OMPI_GATHERV", + "OMPI_IGATHER", "OMPI_ALLTOALL", + "OMPI_IALLTOALL", + "OMPI_IALLTOALLV", + "OMPI_IALLTOALLW", + "OMPI_NEIGHBOR_ALLTOALL", + "OMPI_NEIGHBOR_ALLTOALLV", + "OMPI_NEIGHBOR_ALLTOALLW", "OMPI_ALLGATHER", + "OMPI_ALLGATHERV", + "OMPI_IALLGATHER", + "OMPI_IALLGATHERV", + "OMPI_NEIGHBOR_ALLGATHER", + "OMPI_NEIGHBOR_ALLGATHERV", + "OMPI_TEST", + "OMPI_TESTALL", + "OMPI_TESTANY", + "OMPI_TESTSOME", + "OMPI_WAIT", + "OMPI_WAITALL", + "OMPI_WAITANY", + "OMPI_WAITSOME", + "OMPI_BARRIER", + "OMPI_IBARRIER", + "OMPI_WTICK", + "OMPI_WTIME", + "OMPI_CANCEL", "OMPI_BYTES_RECEIVED_USER", "OMPI_BYTES_RECEIVED_MPI", "OMPI_BYTES_SENT_USER", @@ -53,18 +102,67 @@ OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { /* Array of descriptions for each counter. Used for MPI_T and PAPI sde initialization */ OMPI_DECLSPEC const char *counter_descriptions[OMPI_NUM_COUNTERS] = { "The number of times MPI_Send was called.", + "The number of times MPI_Bsend was called.", + "The number of times MPI_Rsend was called.", + "The number of times MPI_Ssend was called.", "The number of times MPI_Recv was called.", + "The number of times MPI_Mrecv was called.", "The number of times MPI_Isend was called.", + "The number of times MPI_Ibsend was called.", + "The number of times MPI_Irsend was called.", + "The number of times MPI_Issend was called.", "The number of times MPI_Irecv was called.", "The number of times MPI_Sendrecv was called.", "The number of times MPI_Sendrecv_replace was called.", + "The number of times MPI_Put was called.", + "The number of times MPI_Rput was called.", + "The number of times MPI_Get was called.", + "The number of times MPI_Rget was called.", + "The number of times MPI_Probe was called.", + "The number of times MPI_Iprobe was called.", "The number of times MPI_Bcast was called.", + "The number of times MPI_Ibcast was called.", "The number of times MPI_Reduce was called.", + "The number of times MPI_Ireduce was called.", + "The number of times MPI_Ireduce_scatter was called.", + "The number of times MPI_Ireduce_scatter_block was called.", "The number of times MPI_Allreduce was called.", + "The number of times MPI_Iallreduce was called.", + "The number of times MPI_Scan was called.", + "The number of times MPI_Iscan was called.", "The number of times MPI_Scatter was called.", + "The number of times MPI_Scatterv was called.", + "The number of times MPI_Iscatter was called.", + "The number of times MPI_Iscatterv was called.", "The number of times MPI_Gather was called.", + "The number of times MPI_Gatherv was called.", + "The number of times MPI_Igather was called.", "The number of times MPI_Alltoall was called.", + "The number of times MPI_Ialltoall was called.", + "The number of times MPI_Ialltoallv was called.", + "The number of times MPI_Ialltoallw was called.", + "The number of times MPI_Neighbor_alltoall was called.", + "The number of times MPI_Neighbor_alltoallv was called.", + "The number of times MPI_Neighbor_alltoallw was called.", "The number of times MPI_Allgather was called.", + "The number of times MPI_Allgatherv was called.", + "The number of times MPI_Iallgather was called.", + "The number of times MPI_Iallgatherv was called.", + "The number of times MPI_Neighbor_allgather was called.", + "The number of times MPI_Neighbor_allgatherv was called.", + "The number of times MPI_Test was called.", + "The number of times MPI_Testall was called.", + "The number of times MPI_Testany was called.", + "The number of times MPI_Testsome was called.", + "The number of times MPI_Wait was called.", + "The number of times MPI_Waitall was called.", + "The number of times MPI_Waitany was called.", + "The number of times MPI_Waitsome was called.", + "The number of times MPI_Barrier was called.", + "The number of times MPI_Ibarrier was called.", + "The number of times MPI_Wtick was called.", + "The number of times MPI_Wtime was called.", + "The number of times MPI_Cancel was called.", "The number of bytes received by the user through point-to-point communications. Note: Includes bytes transferred using internal RMA operations.", "The number of bytes received by MPI through collective, control, or other internal communications.", "The number of bytes sent by the user through point-to-point communications. Note: Includes bytes transferred using internal RMA operations.", @@ -299,16 +397,20 @@ void ompi_spc_fini() for(i = 0; i < OMPI_NUM_COUNTERS; i++) { if(attached_event[i]) { /* If this is a timer-based counter, we need to covert from cycles to usecs */ + if(recv_buffer[offset+i] == 0) + continue; if(timer_event[i]) SPC_CYCLES_TO_USECS(&recv_buffer[offset+i]); fprintf(stdout, "%s -> %lld\n", events[i].name, recv_buffer[offset+i]); - } else { - fprintf(stdout, "%s -> Disabled\n", events[i].name); } } fprintf(stdout, "\n"); offset += OMPI_NUM_COUNTERS; } + printf("###########################################################################\n"); + printf("NOTE: Any counters not shown here were either disabled or had a value of 0.\n"); + printf("###########################################################################\n"); + free(recv_buffer); free(send_buffer); } else { diff --git a/ompi/runtime/ompi_spc.h b/ompi/runtime/ompi_spc.h index 10499bf06ff..f4d60ba510e 100644 --- a/ompi/runtime/ompi_spc.h +++ b/ompi/runtime/ompi_spc.h @@ -49,18 +49,67 @@ /* This enumeration serves as event ids for the various events */ enum OMPI_COUNTERS{ OMPI_SEND, + OMPI_BSEND, + OMPI_RSEND, + OMPI_SSEND, OMPI_RECV, + OMPI_MRECV, OMPI_ISEND, + OMPI_IBSEND, + OMPI_IRSEND, + OMPI_ISSEND, OMPI_IRECV, OMPI_SENDRECV, OMPI_SENDRECV_REPLACE, + OMPI_PUT, + OMPI_RPUT, + OMPI_GET, + OMPI_RGET, + OMPI_PROBE, + OMPI_IPROBE, OMPI_BCAST, + OMPI_IBCAST, OMPI_REDUCE, + OMPI_IREDUCE, + OMPI_IREDUCE_SCATTER, + OMPI_IREDUCE_SCATTER_BLOCK, OMPI_ALLREDUCE, + OMPI_IALLREDUCE, + OMPI_SCAN, + OMPI_ISCAN, OMPI_SCATTER, + OMPI_SCATTERV, + OMPI_ISCATTER, + OMPI_ISCATTERV, OMPI_GATHER, + OMPI_GATHERV, + OMPI_IGATHER, OMPI_ALLTOALL, + OMPI_IALLTOALL, + OMPI_IALLTOALLV, + OMPI_IALLTOALLW, + OMPI_NEIGHBOR_ALLTOALL, + OMPI_NEIGHBOR_ALLTOALLV, + OMPI_NEIGHBOR_ALLTOALLW, OMPI_ALLGATHER, + OMPI_ALLGATHERV, + OMPI_IALLGATHER, + OMPI_IALLGATHERV, + OMPI_NEIGHBOR_ALLGATHER, + OMPI_NEIGHBOR_ALLGATHERV, + OMPI_TEST, + OMPI_TESTALL, + OMPI_TESTANY, + OMPI_TESTSOME, + OMPI_WAIT, + OMPI_WAITALL, + OMPI_WAITANY, + OMPI_WAITSOME, + OMPI_BARRIER, + OMPI_IBARRIER, + OMPI_WTICK, + OMPI_WTIME, + OMPI_CANCEL, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI, OMPI_BYTES_SENT_USER, From 778c5f4d8f662e2b9158ba60219cad8df371ce10 Mon Sep 17 00:00:00 2001 From: David Eberius Date: Thu, 1 Mar 2018 17:03:32 -0500 Subject: [PATCH 11/12] Fixed a renaming typo resulting from a rebase. --- ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index 7bfed24cc73..1930a646fae 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -314,14 +314,14 @@ mca_pml_ob1_recv_frag_t* check_cantmatch_for_match(mca_pml_ob1_comm_proc_t *proc) { mca_pml_ob1_recv_frag_t *frag = proc->frags_cant_match; - -#if SOFTWARE_EVENTS_ENABLE == 1 +#if SPC_ENABLE == 1 opal_timer_t timer = 0; #endif - SW_EVENT_TIMER_START(OMPI_OOS_MATCH_TIME, &timer); + + SPC_TIMER_START(OMPI_OOS_MATCH_TIME, &timer); if( (NULL != frag) && (frag->hdr.hdr_match.hdr_seq == proc->expected_sequence) ) { mca_pml_ob1_recv_frag_t* ret = remove_head_from_ordered_list(&proc->frags_cant_match); - SW_EVENT_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); + SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); return ret; } SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); @@ -396,7 +396,7 @@ void mca_pml_ob1_recv_frag_callback_match(mca_btl_base_module_t* btl, MCA_PML_OB1_RECV_FRAG_ALLOC(frag); MCA_PML_OB1_RECV_FRAG_INIT(frag, hdr, segments, num_segments, btl); append_frag_to_ordered_list(&proc->frags_cant_match, frag, proc->expected_sequence); - SW_EVENT_RECORD(OMPI_OUT_OF_SEQUENCE, 1); + SPC_RECORD(OMPI_OUT_OF_SEQUENCE, 1); OB1_MATCHING_UNLOCK(&comm->matching_lock); return; } From d07b45b10174c09ed2a23f9b8325f25c2860961e Mon Sep 17 00:00:00 2001 From: David Eberius Date: Wed, 7 Mar 2018 15:13:28 -0500 Subject: [PATCH 12/12] Fixed some of the copyright messages and removed user-level functions from the SPC code. Removed the OOS_MATCH_TIME counter. --- examples/Makefile.include | 2 +- examples/spc_example.c | 6 ++--- ompi/mca/pml/ob1/pml_ob1.c | 6 ----- ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 12 ++------- ompi/runtime/ompi_spc.c | 41 ++++++++++++++++++----------- ompi/runtime/ompi_spc.h | 3 +-- 6 files changed, 32 insertions(+), 38 deletions(-) diff --git a/examples/Makefile.include b/examples/Makefile.include index 85518a1fce3..ed9ace14088 100644 --- a/examples/Makefile.include +++ b/examples/Makefile.include @@ -58,4 +58,4 @@ EXTRA_DIST += \ examples/oshmem_symmetric_data.c \ examples/Hello.java \ examples/Ring.java \ - examples/spc_example.c + examples/spc_example.c diff --git a/examples/spc_example.c b/examples/spc_example.c index ff1d68fb3f7..b98b90f4f0d 100644 --- a/examples/spc_example.c +++ b/examples/spc_example.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2018 The University of Tennessee and The University - * of Tennessee Research Foundation. All rights - * reserved. + * Copyright (c) 2018 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. * * Simple example usage of SPCs through MPI_T. */ diff --git a/ompi/mca/pml/ob1/pml_ob1.c b/ompi/mca/pml/ob1/pml_ob1.c index c41eb78b008..56524892786 100644 --- a/ompi/mca/pml/ob1/pml_ob1.c +++ b/ompi/mca/pml/ob1/pml_ob1.c @@ -196,9 +196,6 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) mca_pml_ob1_recv_frag_t *frag, *next_frag; mca_pml_ob1_comm_proc_t* pml_proc; mca_pml_ob1_match_hdr_t* hdr; -#if SPC_ENABLE == 1 - opal_timer_t timer = 0; -#endif if (NULL == pml_comm) { return OMPI_ERR_OUT_OF_RESOURCE; @@ -254,8 +251,6 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) continue; } - SPC_TIMER_START(OMPI_OOS_MATCH_TIME, &timer); - if (((uint16_t)hdr->hdr_seq) == ((uint16_t)pml_proc->expected_sequence) ) { add_fragment_to_unexpected: @@ -281,7 +276,6 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) append_frag_to_ordered_list(&pml_proc->frags_cant_match, frag, pml_proc->expected_sequence); } - SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); } return OMPI_SUCCESS; } diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index 1930a646fae..8c6ec93b503 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -314,17 +314,9 @@ mca_pml_ob1_recv_frag_t* check_cantmatch_for_match(mca_pml_ob1_comm_proc_t *proc) { mca_pml_ob1_recv_frag_t *frag = proc->frags_cant_match; -#if SPC_ENABLE == 1 - opal_timer_t timer = 0; -#endif - SPC_TIMER_START(OMPI_OOS_MATCH_TIME, &timer); - if( (NULL != frag) && (frag->hdr.hdr_match.hdr_seq == proc->expected_sequence) ) { - mca_pml_ob1_recv_frag_t* ret = remove_head_from_ordered_list(&proc->frags_cant_match); - SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); - return ret; - } - SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer); + if( (NULL != frag) && (frag->hdr.hdr_match.hdr_seq == proc->expected_sequence) ) + return remove_head_from_ordered_list(&proc->frags_cant_match); return NULL; } diff --git a/ompi/runtime/ompi_spc.c b/ompi/runtime/ompi_spc.c index df8a30bca88..312347e20d5 100644 --- a/ompi/runtime/ompi_spc.c +++ b/ompi/runtime/ompi_spc.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2018 The University of Tennessee and The University - * of Tennessee Research Foundation. All rights - * reserved. + * Copyright (c) 2018 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. * * $COPYRIGHT$ * @@ -92,7 +92,6 @@ OMPI_DECLSPEC const char *counter_names[OMPI_NUM_COUNTERS] = { "OMPI_UNEXPECTED", "OMPI_OUT_OF_SEQUENCE", "OMPI_MATCH_TIME", - "OMPI_OOS_MATCH_TIME", "OMPI_UNEXPECTED_IN_QUEUE", "OMPI_OOS_IN_QUEUE", "OMPI_MAX_UNEXPECTED_IN_QUEUE", @@ -172,7 +171,6 @@ OMPI_DECLSPEC const char *counter_descriptions[OMPI_NUM_COUNTERS] = { "The number of messages that arrived as unexpected messages.", "The number of messages that arrived out of the proper sequence.", "The number of microseconds spent matching unexpected messages.", - "The number of microseconds spent matching out of sequence messages.", "The number of messages that are currently in the unexpected message queue(s) of an MPI process.", "The number of messages that are currently in the out of sequence message queue(s) of an MPI process.", "The maximum number of messages that the unexpected message queue(s) within an MPI process contained at once since the last reset of this counter. \ @@ -321,7 +319,7 @@ void ompi_spc_init() * ######################################################################## */ /* If this is a timer event, sent the corresponding timer_event entry to 1 */ - if(i == OMPI_MATCH_TIME || i == OMPI_OOS_MATCH_TIME) + if(i == OMPI_MATCH_TIME) timer_event[i] = 1; else timer_event[i] = 0; @@ -366,11 +364,19 @@ void ompi_spc_fini() if(!ompi_mpi_spc_dump_enabled) goto skip_dump; - int i, j, rank, world_size, offset; + int i, j, rank, world_size, offset, err; long long *recv_buffer, *send_buffer; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &world_size); + ompi_communicator_t *comm = &ompi_mpi_comm_world.comm; + + rank = ompi_comm_rank(comm); + world_size = ompi_comm_size(comm); + + /* Convert from cycles to usecs before sending */ + for(i = 0; i < OMPI_NUM_COUNTERS; i++) { + if(timer_event[i]) + SPC_CYCLES_TO_USECS(&events[i].value); + } /* Aggregate all of the information on rank 0 using MPI_Gather on MPI_COMM_WORLD */ if(rank == 0) { @@ -379,13 +385,19 @@ void ompi_spc_fini() for(i = 0; i < OMPI_NUM_COUNTERS; i++) { send_buffer[i] = events[i].value; } - MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); + err = comm->c_coll->coll_gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, + recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, + 0, comm, + comm->c_coll->coll_gather_module); } else { send_buffer = (long long*)malloc(OMPI_NUM_COUNTERS * sizeof(long long)); for(i = 0; i < OMPI_NUM_COUNTERS; i++) { send_buffer[i] = events[i].value; } - MPI_Gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, 0, MPI_COMM_WORLD); + err = comm->c_coll->coll_gather(send_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, + recv_buffer, OMPI_NUM_COUNTERS, MPI_LONG_LONG, + 0, comm, + comm->c_coll->coll_gather_module); } /* Once rank 0 has all of the information, print the aggregated counter values for each rank in order */ @@ -399,8 +411,6 @@ void ompi_spc_fini() /* If this is a timer-based counter, we need to covert from cycles to usecs */ if(recv_buffer[offset+i] == 0) continue; - if(timer_event[i]) - SPC_CYCLES_TO_USECS(&recv_buffer[offset+i]); fprintf(stdout, "%s -> %lld\n", events[i].name, recv_buffer[offset+i]); } } @@ -417,13 +427,12 @@ void ompi_spc_fini() free(send_buffer); } - MPI_Barrier(MPI_COMM_WORLD); + comm->c_coll->coll_barrier(comm, comm->c_coll->coll_barrier_module); skip_dump: if(rank == 0) free(events); #else - int rank; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); + int rank = ompi_comm_rank(&ompi_mpi_comm_world.comm); if(rank == 0) free(events); #endif diff --git a/ompi/runtime/ompi_spc.h b/ompi/runtime/ompi_spc.h index f4d60ba510e..a3edad5e743 100644 --- a/ompi/runtime/ompi_spc.h +++ b/ompi/runtime/ompi_spc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2018 The University of Tennessee and The University + * Copyright (c) 2018 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * @@ -119,7 +119,6 @@ enum OMPI_COUNTERS{ OMPI_UNEXPECTED, OMPI_OUT_OF_SEQUENCE, OMPI_MATCH_TIME, - OMPI_OOS_MATCH_TIME, OMPI_UNEXPECTED_IN_QUEUE, OMPI_OOS_IN_QUEUE, OMPI_MAX_UNEXPECTED_IN_QUEUE,