Skip to content

Commit 481ad71

Browse files
author
David Eberius
committed
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.
1 parent 196a308 commit 481ad71

30 files changed

+320
-368
lines changed

configure.ac

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,15 @@ AC_ARG_ENABLE(spc,
292292
[Enable software-based performance counters capability (default: disabled)]))
293293
if test "$enable_spc" = "yes"; then
294294
AC_MSG_RESULT([yes])
295-
SOFTWARE_EVENTS_ENABLE=1
295+
SPC_ENABLE=1
296296
else
297297
AC_MSG_RESULT([no])
298-
SOFTWARE_EVENTS_ENABLE=0
298+
SPC_ENABLE=0
299299
fi
300-
AC_DEFINE_UNQUOTED([SOFTWARE_EVENTS_ENABLE],
301-
[$SOFTWARE_EVENTS_ENABLE],
300+
AC_DEFINE_UNQUOTED([SPC_ENABLE],
301+
[$SPC_ENABLE],
302302
[If the software-based performance counters capability should be enabled.])
303-
AM_CONDITIONAL(SOFTWARE_EVENTS_ENABLE, test "$SOFTWARE_EVENTS_ENABLE" = "1")
303+
AM_CONDITIONAL(SPC_ENABLE, test "$SPC_ENABLE" = "1")
304304

305305
AS_IF([test "$enable_spc" != "no"], [project_spc_amc=true], [project_spc_amc=false])
306306

ompi/mca/pml/ob1/pml_ob1.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "opal_stdint.h"
3737
#include "opal/mca/btl/btl.h"
3838
#include "opal/mca/btl/base/base.h"
39-
#include "ompi/runtime/ompi_software_events.h"
39+
#include "ompi/runtime/ompi_spc.h"
4040

4141
#include "ompi/mca/pml/pml.h"
4242
#include "ompi/mca/pml/base/base.h"
@@ -196,7 +196,9 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm)
196196
mca_pml_ob1_recv_frag_t *frag, *next_frag;
197197
mca_pml_ob1_comm_proc_t* pml_proc;
198198
mca_pml_ob1_match_hdr_t* hdr;
199-
opal_timer_t usecs = 0;
199+
#if SPC_ENABLE == 1
200+
opal_timer_t timer = 0;
201+
#endif
200202

201203
if (NULL == pml_comm) {
202204
return OMPI_ERR_OUT_OF_RESOURCE;
@@ -266,7 +268,7 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm)
266268
* situation as the cant_match is only checked when a new fragment is received from
267269
* the network.
268270
*/
269-
SW_EVENT_TIMER_START(OMPI_OOS_MATCH_TIME, &usecs);
271+
SPC_TIMER_START(OMPI_OOS_MATCH_TIME, &timer);
270272
OPAL_LIST_FOREACH(frag, &pml_proc->frags_cant_match, mca_pml_ob1_recv_frag_t) {
271273
hdr = &frag->hdr.hdr_match;
272274
/* If the message has the next expected seq from that proc... */
@@ -276,7 +278,7 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm)
276278
opal_list_remove_item(&pml_proc->frags_cant_match, (opal_list_item_t*)frag);
277279
goto add_fragment_to_unexpected;
278280
}
279-
SW_EVENT_TIMER_STOP(OMPI_OOS_MATCH_TIME, &usecs);
281+
SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer);
280282
} else {
281283
opal_list_append( &pml_proc->frags_cant_match, (opal_list_item_t*)frag );
282284
}

ompi/mca/pml/ob1/pml_ob1_isend.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "pml_ob1_sendreq.h"
2929
#include "pml_ob1_recvreq.h"
3030
#include "ompi/peruse/peruse-internal.h"
31-
#include "ompi/runtime/ompi_software_events.h"
31+
#include "ompi/runtime/ompi_spc.h"
3232

3333
/**
3434
* 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,
121121
size, MCA_BTL_NO_ORDER, MCA_BTL_DES_FLAGS_PRIORITY | MCA_BTL_DES_FLAGS_BTL_OWNERSHIP,
122122
MCA_PML_OB1_HDR_TYPE_MATCH, NULL);
123123

124-
if(OPAL_LIKELY(rc == OPAL_SUCCESS)){
125-
if(tag >= 0){
126-
SW_EVENT_RECORD(OMPI_BYTES_SENT_USER, size);
127-
}
128-
else{
129-
SW_EVENT_RECORD(OMPI_BYTES_SENT_MPI, size);
130-
}
124+
if(OPAL_LIKELY(rc == OPAL_SUCCESS)) {
125+
SPC_USER_OR_MPI(tag, (long long)size, OMPI_BYTES_SENT_USER, OMPI_BYTES_SENT_MPI);
131126
}
132127

133128
if (count > 0) {

ompi/mca/pml/ob1/pml_ob1_recvfrag.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include "ompi/mca/pml/pml.h"
4040
#include "ompi/peruse/peruse-internal.h"
4141
#include "ompi/memchecker.h"
42-
#include "ompi/runtime/ompi_software_events.h"
42+
#include "ompi/runtime/ompi_spc.h"
4343

4444
#include "pml_ob1.h"
4545
#include "pml_ob1_comm.h"
@@ -180,20 +180,19 @@ match_one(mca_btl_base_module_t *btl,
180180
static inline mca_pml_ob1_recv_frag_t* check_cantmatch_for_match(mca_pml_ob1_comm_proc_t *proc)
181181
{
182182
mca_pml_ob1_recv_frag_t *frag = NULL;
183-
#if SOFTWARE_EVENTS_ENABLE == 1
183+
#if SPC_ENABLE == 1
184184
opal_timer_t timer = 0;
185185
#endif
186-
187-
SW_EVENT_TIMER_START(OMPI_OOS_MATCH_TIME, &timer);
186+
SPC_TIMER_START(OMPI_OOS_MATCH_TIME, &timer);
188187

189188
frag = (mca_pml_ob1_recv_frag_t*)opal_list_get_first(&proc->frags_cant_match);
190189
if( (opal_list_get_end(&proc->frags_cant_match) != (opal_list_item_t*)frag) &&
191190
(frag->hdr.hdr_match.hdr_seq == proc->expected_sequence) ) {
192191
opal_list_remove_item(&proc->frags_cant_match, (opal_list_item_t*)frag);
193-
SW_EVENT_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer);
192+
SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer);
194193
return frag;
195194
}
196-
SW_EVENT_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer);
195+
SPC_TIMER_STOP(OMPI_OOS_MATCH_TIME, &timer);
197196
return NULL;
198197
}
199198

@@ -263,7 +262,7 @@ void mca_pml_ob1_recv_frag_callback_match(mca_btl_base_module_t* btl,
263262
if(OPAL_UNLIKELY(((uint16_t) hdr->hdr_seq) != ((uint16_t) proc->expected_sequence))) {
264263
append_frag_to_ordered_list(&proc->frags_cant_match, btl,
265264
hdr, segments, num_segments, NULL);
266-
SW_EVENT_RECORD(OMPI_OUT_OF_SEQUENCE, 1);
265+
SPC_RECORD(OMPI_OUT_OF_SEQUENCE, 1);
267266
OB1_MATCHING_UNLOCK(&comm->matching_lock);
268267
return;
269268
}
@@ -324,9 +323,8 @@ void mca_pml_ob1_recv_frag_callback_match(mca_btl_base_module_t* btl,
324323
&iov_count,
325324
&bytes_received );
326325
match->req_bytes_received = bytes_received;
327-
328-
SW_EVENT_USER_OR_MPI(match->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
329-
326+
SPC_USER_OR_MPI(match->req_recv.req_base.req_tag, (long long)bytes_received,
327+
OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
330328
/*
331329
* Unpacking finished, make the user buffer unaccessable again.
332330
*/
@@ -651,10 +649,10 @@ match_one(mca_btl_base_module_t *btl,
651649
mca_pml_ob1_comm_proc_t *proc,
652650
mca_pml_ob1_recv_frag_t* frag)
653651
{
654-
#if SOFTWARE_EVENTS_ENABLE == 1
652+
#if SPC_ENABLE == 1
655653
opal_timer_t timer = 0;
656654
#endif
657-
SW_EVENT_TIMER_START(OMPI_MATCH_TIME, &timer);
655+
SPC_TIMER_START(OMPI_MATCH_TIME, &timer);
658656

659657
mca_pml_ob1_recv_request_t *match;
660658
mca_pml_ob1_comm_t *comm = (mca_pml_ob1_comm_t *)comm_ptr->c_pml_comm;
@@ -693,28 +691,23 @@ match_one(mca_btl_base_module_t *btl,
693691
num_segments);
694692
/* this frag is already processed, so we want to break out
695693
of the loop and not end up back on the unexpected queue. */
696-
SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &timer);
697-
694+
SPC_TIMER_STOP(OMPI_MATCH_TIME, &timer);
698695
return NULL;
699696
}
700697

701698
PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_MSG_MATCH_POSTED_REQ,
702699
&(match->req_recv.req_base), PERUSE_RECV);
703-
SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &timer);
704-
700+
SPC_TIMER_STOP(OMPI_MATCH_TIME, &timer);
705701
return match;
706702
}
707703

708704
/* if no match found, place on unexpected queue */
709705
append_frag_to_list(&proc->unexpected_frags, btl, hdr, segments,
710706
num_segments, frag);
711-
712-
SW_EVENT_RECORD(OMPI_UNEXPECTED, 1);
713-
707+
SPC_RECORD(OMPI_UNEXPECTED, 1);
714708
PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_INSERT_IN_UNEX_Q, comm_ptr,
715709
hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV);
716-
SW_EVENT_TIMER_STOP(OMPI_MATCH_TIME, &timer);
717-
710+
SPC_TIMER_STOP(OMPI_MATCH_TIME, &timer);
718711
return NULL;
719712
} while(true);
720713
}

ompi/mca/pml/ob1/pml_ob1_recvreq.c

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "opal/mca/mpool/mpool.h"
3131
#include "opal/util/arch.h"
32-
#include "ompi/runtime/ompi_software_events.h"
32+
#include "ompi/runtime/ompi_spc.h"
3333
#include "ompi/mca/pml/pml.h"
3434
#include "ompi/mca/bml/bml.h"
3535
#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
199199
if (OPAL_LIKELY(0 < rdma_size)) {
200200

201201
/* check completion status */
202-
203202
OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, rdma_size);
204-
SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)rdma_size, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
205-
203+
SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)rdma_size,
204+
OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
206205
if (recv_request_pml_complete_check(recvreq) == false &&
207206
recvreq->req_rdma_offset < recvreq->req_send_offset) {
208207
/* schedule additional rdma operations */
@@ -246,8 +245,7 @@ int mca_pml_ob1_recv_request_ack_send_btl(
246245
des->des_cbfunc = mca_pml_ob1_recv_ctl_completion;
247246

248247
rc = mca_bml_base_send(bml_btl, des, MCA_PML_OB1_HDR_TYPE_ACK);
249-
SW_EVENT_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)size);
250-
248+
SPC_RECORD(OMPI_BYTES_RECEIVED_MPI, (long long)size);
251249
if( OPAL_LIKELY( rc >= 0 ) ) {
252250
return OMPI_SUCCESS;
253251
}
@@ -380,7 +378,8 @@ static void mca_pml_ob1_rget_completion (mca_btl_base_module_t* btl, struct mca_
380378
} else {
381379
/* is receive request complete */
382380
OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, frag->rdma_length);
383-
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);
381+
SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)frag->rdma_length,
382+
OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
384383
/* TODO: re-add order */
385384
mca_pml_ob1_send_fin (recvreq->req_recv.req_base.req_proc,
386385
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)
436435

437436
/* send rdma request to peer */
438437
rc = mca_bml_base_send (bml_btl, ctl, MCA_PML_OB1_HDR_TYPE_PUT);
439-
440438
/* Increment counter for bytes_put even though they probably haven't all been received yet */
441-
SW_EVENT_RECORD(OMPI_BYTES_PUT, frag->rdma_length);
442-
439+
SPC_RECORD(OMPI_BYTES_PUT, frag->rdma_length);
443440
if (OPAL_UNLIKELY(rc < 0)) {
444441
mca_bml_base_free (bml_btl, ctl);
445442
return rc;
@@ -481,10 +478,8 @@ int mca_pml_ob1_recv_request_get_frag (mca_pml_ob1_rdma_frag_t *frag)
481478
rc = mca_bml_base_get (bml_btl, frag->local_address, frag->remote_address, local_handle,
482479
(mca_btl_base_registration_handle_t *) frag->remote_handle, frag->rdma_length,
483480
0, MCA_BTL_NO_ORDER, mca_pml_ob1_rget_completion, frag);
484-
485481
/* Increment counter for bytes_get even though they probably haven't all been received yet */
486-
SW_EVENT_RECORD(OMPI_BYTES_GET, frag->rdma_length);
487-
482+
SPC_RECORD(OMPI_BYTES_GET, frag->rdma_length);
488483
if( OPAL_UNLIKELY(OMPI_SUCCESS > rc) ) {
489484
return mca_pml_ob1_recv_request_get_frag_failed (frag, OMPI_ERR_OUT_OF_RESOURCE);
490485
}
@@ -540,8 +535,8 @@ void mca_pml_ob1_recv_request_progress_frag( mca_pml_ob1_recv_request_t* recvreq
540535
);
541536

542537
OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received);
543-
SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
544-
538+
SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received,
539+
OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
545540
/* check completion status */
546541
if(recv_request_pml_complete_check(recvreq) == false &&
547542
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,
619614
des->des_cbfunc(NULL, NULL, des, 0);
620615

621616
OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received);
622-
SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
623-
617+
SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received,
618+
OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
624619
/* check completion status */
625620
if(recv_request_pml_complete_check(recvreq) == false &&
626621
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
834829
recvreq->req_recv.req_base.req_datatype);
835830
);
836831
OPAL_THREAD_ADD_FETCH_SIZE_T(&recvreq->req_bytes_received, bytes_received);
837-
SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
832+
SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received,
833+
OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
838834
}
839835
/* check completion status */
840836
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
905901
* for this request.
906902
*/
907903
recvreq->req_bytes_received += bytes_received;
908-
909-
SW_EVENT_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received, OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
910-
904+
SPC_USER_OR_MPI(recvreq->req_recv.req_base.req_tag, (long long)bytes_received,
905+
OMPI_BYTES_RECEIVED_USER, OMPI_BYTES_RECEIVED_MPI);
911906
recv_request_pml_complete(recvreq);
912907
}
913908

0 commit comments

Comments
 (0)