From cdea68dccef3f661306a944784726178b166f5ae Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 27 Sep 2010 22:03:37 +0000 Subject: [PATCH] buildscript options to enable exaclty which coreprof events are needed, keeps instrumentation overhead at minimum, will help for new events to imrpove SOR --- Robust/src/IR/Flat/BuildCode.java | 52 ++++++++++---- Robust/src/Runtime/coreprof/coreprof.c | 4 ++ Robust/src/Runtime/coreprof/coreprof.h | 76 +++++++++++++++++---- Robust/src/Runtime/workschedule.c | 8 ++- Robust/src/Tests/oooJava/poolalloc/makefile | 27 ++++++-- Robust/src/buildscript | 16 ++++- 6 files changed, 147 insertions(+), 36 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index ca23a771..dc117941 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -2410,7 +2410,9 @@ public class BuildCode { } if( state.COREPROF ) { + output.println("#ifdef CP_EVENTID_TASKEXECUTE"); output.println(" CP_LOGEVENT( CP_EVENTID_TASKEXECUTE, CP_EVENTTYPE_BEGIN );"); + output.println("#endif"); } HashSet exitset=new HashSet(); @@ -2887,7 +2889,9 @@ public class BuildCode { output.println(" SESEcommon* common = (SESEcommon*) "+pair+";"); if( state.COREPROF ) { - //output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_BEGIN );"); + output.println("#ifdef CP_EVENTID_TASKSTALLVAR"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_BEGIN );"); + output.println("#endif"); } output.println(" pthread_mutex_lock( &(common->lock) );"); output.println(" while( common->doneExecuting == FALSE ) {"); @@ -2909,7 +2913,9 @@ public class BuildCode { " = child->"+vst.getAddrVar().getSafeSymbol()+";"); } if( state.COREPROF ) { - //output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_END );"); + output.println("#ifdef CP_EVENTID_TASKSTALLVAR"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_END );"); + output.println("#endif"); } output.println(" }"); } @@ -2925,7 +2931,9 @@ public class BuildCode { output.println(" if( "+dynVar+"_srcSESE != NULL ) {"); output.println(" SESEcommon* common = (SESEcommon*) "+dynVar+"_srcSESE;"); if( state.COREPROF ) { - //output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_BEGIN );"); + output.println("#ifdef CP_EVENTID_TASKSTALLVAR"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_BEGIN );"); + output.println("#endif"); } output.println(" psem_take( &(common->stallSem) );"); @@ -2950,7 +2958,9 @@ public class BuildCode { " = *(("+typeStr+"*) ("+ dynVar+"_srcSESE + "+dynVar+"_srcOffset));"); if( state.COREPROF ) { - //output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_END );"); + output.println("#ifdef CP_EVENTID_TASKSTALLVAR"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_END );"); + output.println("#endif"); } output.println(" }"); output.println(" }"); @@ -3042,11 +3052,15 @@ public class BuildCode { output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID() + "],rentry)==NOTREADY){"); if( state.COREPROF ) { - //output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );"); + output.println("#ifdef CP_EVENTID_TASKSTALLMEM"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );"); + output.println("#endif"); } output.println(" psem_take( &(rentry->parentStallSem) );"); if( state.COREPROF ) { - //output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );"); + output.println("#ifdef CP_EVENTID_TASKSTALLMEM"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );"); + output.println("#endif"); } output.println(" } "); @@ -3093,11 +3107,15 @@ public class BuildCode { .println(" if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID() + "],rentry)==NOTREADY){"); if( state.COREPROF ) { - //output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );"); + output.println("#ifdef CP_EVENTID_TASKSTALLMEM"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );"); + output.println("#endif"); } output.println(" psem_take( &(rentry->parentStallSem) );"); if( state.COREPROF ) { - //output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );"); + output.println("#ifdef CP_EVENTID_TASKSTALLMEM"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );"); + output.println("#endif"); } output.println(" } "); } @@ -3638,7 +3656,9 @@ public class BuildCode { output.println(" {"); if( state.COREPROF ) { - output.println("CP_LOGEVENT( CP_EVENTID_TASKDISPATCH, CP_EVENTTYPE_BEGIN );"); + output.println("#ifdef CP_EVENTID_TASKDISPATCH"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKDISPATCH, CP_EVENTTYPE_BEGIN );"); + output.println("#endif"); } // before doing anything, lock your own record and increment the running children @@ -4144,7 +4164,9 @@ public class BuildCode { // output.println(" pthread_mutex_unlock( &(seseToIssue->common.lock) );"); if( state.COREPROF ) { - output.println("CP_LOGEVENT( CP_EVENTID_TASKDISPATCH, CP_EVENTTYPE_END );"); + output.println("#ifdef CP_EVENTID_TASKDISPATCH"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKDISPATCH, CP_EVENTTYPE_END );"); + output.println("#endif"); } output.println(" }"); @@ -4179,13 +4201,17 @@ public class BuildCode { } if( state.COREPROF ) { + output.println("#ifdef CP_EVENTID_TASKEXECUTE"); output.println(" CP_LOGEVENT( CP_EVENTID_TASKEXECUTE, CP_EVENTTYPE_END );"); + output.println("#endif"); } output.println(" /* SESE exiting */"); if( state.COREPROF ) { + output.println("#ifdef CP_EVENTID_TASKRETIRE"); output.println(" CP_LOGEVENT( CP_EVENTID_TASKRETIRE, CP_EVENTTYPE_BEGIN );"); + output.println("#endif"); } String com = paramsprefix+"->common"; @@ -4341,11 +4367,11 @@ public class BuildCode { // destroy this task's mempool if it is not a leaf task - output.println( "#ifndef OOO_DISABLE_TASKMEMPOOL" ); if( !fsen.getIsLeafSESE() ) { + output.println( "#ifndef OOO_DISABLE_TASKMEMPOOL" ); output.println(" pooldestroy( runningSESE->taskRecordMemPool );"); + output.println( "#endif" ); } - output.println( "#endif" ); // if this is not the Main sese (which has no parent) then return @@ -4365,7 +4391,9 @@ public class BuildCode { output.println(" runningSESE = (SESEcommon*) 0x1;"); if( state.COREPROF ) { + output.println("#ifdef CP_EVENTID_TASKRETIRE"); output.println(" CP_LOGEVENT( CP_EVENTID_TASKRETIRE, CP_EVENTTYPE_END );"); + output.println("#endif"); } } diff --git a/Robust/src/Runtime/coreprof/coreprof.c b/Robust/src/Runtime/coreprof/coreprof.c index 25437ad5..cc2a64f6 100644 --- a/Robust/src/Runtime/coreprof/coreprof.c +++ b/Robust/src/Runtime/coreprof/coreprof.c @@ -54,12 +54,16 @@ void cp_create() { // point thread lock variable to event monitor cp_monitor = monitor; +#ifdef CP_EVENTID_MAIN CP_LOGEVENT( CP_EVENTID_MAIN, CP_EVENTTYPE_BEGIN ); +#endif } // Place to do shutdown stuff void cp_exit() { +#ifdef CP_EVENTID_MAIN CP_LOGEVENT( CP_EVENTID_MAIN, CP_EVENTTYPE_END ); +#endif } void cp_writedata( int fd, char* buffer, int count ) { diff --git a/Robust/src/Runtime/coreprof/coreprof.h b/Robust/src/Runtime/coreprof/coreprof.h index ad90a68b..67f7ba85 100644 --- a/Robust/src/Runtime/coreprof/coreprof.h +++ b/Robust/src/Runtime/coreprof/coreprof.h @@ -26,23 +26,61 @@ // the values of the following event types // and BASESHIFT is for shifting IDs // past the type bits +#define CP_EVENTTYPE_BEGIN 0x1 +#define CP_EVENTTYPE_END 0x2 +#define CP_EVENTTYPE_ONEOFF 0x3 + #define CP_EVENT_MASK 3 #define CP_EVENT_BASESHIFT 8 -#define CP_EVENTTYPE_BEGIN 1 -#define CP_EVENTTYPE_END 2 -#define CP_EVENTTYPE_ONEOFF 3 - -// Event IDs -#define CP_EVENTID_MAIN 0x04 -#define CP_EVENTID_RUNMALLOC 0x10 -#define CP_EVENTID_RUNFREE 0x11 -#define CP_EVENTID_WORKSCHEDGRAB 0x20 -#define CP_EVENTID_TASKDISPATCH 0x30 -#define CP_EVENTID_TASKEXECUTE 0x31 -#define CP_EVENTID_TASKRETIRE 0x32 -#define CP_EVENTID_TASKSTALLVAR 0x40 -#define CP_EVENTID_TASKSTALLMEM 0x41 + +// Event IDs, only those enabled explicitly as a build option +// will be defined and included in the compilation +#ifdef cpe_main +#define CP_EVENTID_MAIN 0x04 +#endif + +#ifdef cpe_runmalloc +#define CP_EVENTID_RUNMALLOC 0x10 +#endif + +#ifdef cpe_runfree +#define CP_EVENTID_RUNFREE 0x11 +#endif + +#ifdef cpe_count_poolalloc +#define CP_EVENTID_COUNT_POOLALLOC 0x15 +#endif + +#ifdef cpe_count_poolreuse +#define CP_EVENTID_COUNT_POOLREUSE 0x16 +#endif + +#ifdef cpe_workschedgrab +#define CP_EVENTID_WORKSCHEDGRAB 0x20 +#endif + +#ifdef cpe_taskdispatch +#define CP_EVENTID_TASKDISPATCH 0x30 +#endif + +#ifdef cpe_taskexecute +#define CP_EVENTID_TASKEXECUTE 0x31 +#endif + +#ifdef cpe_taskretire +#define CP_EVENTID_TASKRETIRE 0x32 +#endif + +#ifdef cpe_taskstallvar +#define CP_EVENTID_TASKSTALLVAR 0x40 +#endif + +#ifdef cpe_taskstallmem +#define CP_EVENTID_TASKSTALLMEM 0x41 +#endif + + // Note: application-specific events (assigned // during code gen) start at 0x200 @@ -99,16 +137,24 @@ void cp_reportOverflow(); static inline void* cp_calloc( int size ) { - CP_LOGEVENT( CP_EVENTID_RUNMALLOC, CP_EVENTTYPE_BEGIN ); +#ifdef CP_EVENTID_RUNMALLOC + CP_LOGEVENT( CP_EVENTID_RUNMALLOC, CP_EVENTTYPE_BEGIN ); +#endif void* mem = calloc( 1, size ); +#ifdef CP_EVENTID_RUNMALLOC CP_LOGEVENT( CP_EVENTID_RUNMALLOC, CP_EVENTTYPE_END ); +#endif return mem; } static inline void cp_free( void* ptr ) { +#ifdef CP_EVENTID_RUNFREE CP_LOGEVENT( CP_EVENTID_RUNFREE, CP_EVENTTYPE_BEGIN ); +#endif free( ptr ); +#ifdef CP_EVENTID_RUNFREE CP_LOGEVENT( CP_EVENTID_RUNFREE, CP_EVENTTYPE_END ); +#endif } diff --git a/Robust/src/Runtime/workschedule.c b/Robust/src/Runtime/workschedule.c index 0d9aea03..bdca1127 100644 --- a/Robust/src/Runtime/workschedule.c +++ b/Robust/src/Runtime/workschedule.c @@ -81,7 +81,9 @@ void* workerMain( void* arg ) { while( 1 ) { // wait for work - //CP_LOGEVENT( CP_EVENTID_WORKSCHEDGRAB, CP_EVENTTYPE_BEGIN ); +#ifdef CP_EVENTID_WORKSCHEDGRAB + CP_LOGEVENT( CP_EVENTID_WORKSCHEDGRAB, CP_EVENTTYPE_BEGIN ); +#endif haveWork = FALSE; while( !haveWork ) { pthread_mutex_lock( &systemLockOut ); @@ -98,7 +100,9 @@ void* workerMain( void* arg ) { workUnit = headqi->value; pthread_mutex_unlock( &systemLockOut ); free( tmp ); - //CP_LOGEVENT( CP_EVENTID_WORKSCHEDGRAB, CP_EVENTTYPE_END ); +#ifdef CP_EVENTID_WORKSCHEDGRAB + CP_LOGEVENT( CP_EVENTID_WORKSCHEDGRAB, CP_EVENTTYPE_END ); +#endif pthread_mutex_lock(&gclistlock); threadcount++; diff --git a/Robust/src/Tests/oooJava/poolalloc/makefile b/Robust/src/Tests/oooJava/poolalloc/makefile index 68d44644..e8a61b12 100644 --- a/Robust/src/Tests/oooJava/poolalloc/makefile +++ b/Robust/src/Tests/oooJava/poolalloc/makefile @@ -4,20 +4,39 @@ SOURCE_FILES=test.java BUILDSCRIPT=../../../buildscript -USEOOO= -ooojava 24 2 -ooodebug -BSFLAGS= -64bit -mainclass $(PROGRAM) -heapsize-mb 1024 -garbagestats -noloop -nooptimize -coreprof -coreprof-checkoverflow -coreprof -coreprof-eventwords 1024*1024*128 -debug #-ooodebug-disable-task-mem-pool +COREPROFOVERFLOW= -coreprof-checkoverflow +USECOREPROF= -coreprof $(COREPROFOVERFLOW) \ + -coreprof-eventwords 1024*1024*128 \ + -coreprof-enable cpe_main \ + -coreprof-enable cpe_runmalloc \ + -coreprof-enable cpe_runfree \ + -coreprof-enable cpe_count_poolalloc \ + -coreprof-enable cpe_count_poolreuse \ + -coreprof-enable cpe_workschedgrab \ + -coreprof-enable cpe_taskdispatch \ + -coreprof-enable cpe_taskexecute \ + -coreprof-enable cpe_taskretire +# -coreprof-enable cpe_taskstallvar \ +# -coreprof-enable cpe_taskstallmem + + DISJOINT= -disjoint -disjoint-k 1 -enable-assertions #-disjoint-desire-determinism +USEOOO= $(DISJOINT) -ooojava 24 2 -ooodebug $(USECOREPROF) + +BSFLAGS= -64bit -mainclass $(PROGRAM) -heapsize-mb 1024 -garbagestats -noloop -nooptimize -debug #-ooodebug-disable-task-mem-pool + + all: ooo remakec: - $(BUILDSCRIPT) -nojava $(USEOOO) $(BSFLAGS) $(DISJOINT) -o $(PROGRAM)p $(SOURCE_FILES) -builddir par + $(BUILDSCRIPT) -nojava $(USEOOO) $(BSFLAGS) -o $(PROGRAM)p $(SOURCE_FILES) -builddir par single: $(BUILDSCRIPT) $(BSFLAGS) -thread -o $(PROGRAM)s -builddir sing $(SOURCE_FILES) ooo: - $(BUILDSCRIPT) $(USEOOO) $(BSFLAGS) $(DISJOINT) -o $(PROGRAM)p -builddir par $(SOURCE_FILES) + $(BUILDSCRIPT) $(USEOOO) $(BSFLAGS) -o $(PROGRAM)p -builddir par $(SOURCE_FILES) clean: rm -f $(PROGRAM)p.bin $(PROGRAM)s.bin diff --git a/Robust/src/buildscript b/Robust/src/buildscript index cfebc7ae..469552ca 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -17,9 +17,11 @@ echo "-numa numa aware" echo "-eventmonitor turn on transaction event trace recording" echo echo OOOJava options -echo -coreprof turn on profiling API -echo -coreprof-eventwords NUM space in words/thread for coreprof events -echo -coreprof-checkoverflow ONLY use for debugging event overflow +echo -coreprof, turn on profiling API +echo -coreprof-eventwords NUM, space in words/thread for coreprof events +echo -coreprof-checkoverflow, ONLY use for debugging event overflow +echo -coreprof-enable EVENTNAME, only enable desired events to reduce overhead +echo EVENTNAME can be: cpe_main, cpe_runmalloc, cpe_runfree, cpe_count_poolalloc, cpe_count_poolreuse, cpe_workschedgrab, cpe_taskdispatch, cpe_taskexecute, cpe_taskretire, cpe_taskstallvar, cpe_taskstallmem echo "-ooojava " echo -ooodebug general OOOJava debugging messages echo -ooodebug-disable-task-mem-pool this is a tricky module, disable for simpler runtime @@ -568,6 +570,11 @@ elif [[ $1 = '-coreprof-checkoverflow' ]] then EXTRAOPTIONS="$EXTRAOPTIONS -DCOREPROF_CHECKOVERFLOW" +elif [[ $1 = '-coreprof-enable' ]] +then +EXTRAOPTIONS="$EXTRAOPTIONS -D$2" +shift + elif [[ $1 = '-mlp' ]] then MLP_ON=true @@ -1208,6 +1215,9 @@ then EXTRAOPTIONS="$EXTRAOPTIONS -ldmalloc -DDMALLOC" fi +echo Compiling C... +echo EXTRAOPTIONS=$EXTRAOPTIONS + if $ASSEMBLY then gcc -S $INCLUDES $EXTRAOPTIONS -DPRECISE_GC \ -- 2.34.1