buildscript options to enable exaclty which coreprof events are needed, keeps instrum...
authorjjenista <jjenista>
Mon, 27 Sep 2010 22:03:37 +0000 (22:03 +0000)
committerjjenista <jjenista>
Mon, 27 Sep 2010 22:03:37 +0000 (22:03 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/coreprof/coreprof.c
Robust/src/Runtime/coreprof/coreprof.h
Robust/src/Runtime/workschedule.c
Robust/src/Tests/oooJava/poolalloc/makefile
Robust/src/buildscript

index ca23a7718bc68aae712e109c6a53fd080be6934c..dc1179414296723d1f54c5e52a488d9f70d8c528 100644 (file)
@@ -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<FlatNode> exitset=new HashSet<FlatNode>();
@@ -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");
     }
   }
  
index 25437ad56016802d2bfc657671cf654aef126e76..cc2a64f6b0ce273a10b4ae9e357feb6a73c599f1 100644 (file)
@@ -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 ) {
index ad90a68b8f1f907a838a93e14fb0986d879edab4..67f7ba859db3b12db07360018819153597b71440 100644 (file)
 // 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
 }
 
 
index 0d9aea038d193a8bb70908f04d4f94d763af6fe8..bdca1127ca252fcb5644e178fbda59d06fa4b158 100644 (file)
@@ -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++;
index 68d446445173074e969d7be35c6db9424f8f359d..e8a61b120f4fd552fb6e153c893e48af8039c373 100644 (file)
@@ -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
index cfebc7aedcaf30403549c447f1df1e05eef96ba3..469552caa7b24cb6284cc80c204a931ec9811797 100755 (executable)
@@ -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 <numberofcores> <maxseseage>"
 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 \