did something I shouldnt have, mixed changes for two different projects at once,...
authorjjenista <jjenista>
Mon, 9 Aug 2010 22:20:53 +0000 (22:20 +0000)
committerjjenista <jjenista>
Mon, 9 Aug 2010 22:20:53 +0000 (22:20 +0000)
Robust/src/Analysis/Disjoint/AllocSite.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/coreprof/coreprof.c
Robust/src/Runtime/coreprof/coreprof.h
Robust/src/Runtime/runtime.c
Robust/src/Runtime/runtime.h
Robust/src/Runtime/workschedule.c
Robust/src/buildscript

index 0e40e0d4f9878e0e449e990ff064259e216d1bd8..6589ecb52f985697d02a889c66f176f32da8f446 100644 (file)
@@ -104,6 +104,10 @@ public class AllocSite extends Canonical {
     return new Integer( uniqueIDcount );
   }
 
+  public int getUniqueAllocSiteID() {
+    return id;
+  }
+
   public String getDisjointAnalysisId() {
     return disjointId;
   }
index 5159f7ebbb051af5b165bed52e0f572ea66836b0..35bfc4f089d2a0e0fdf94b421c16bf846c33165a 100644 (file)
@@ -683,6 +683,7 @@ public class BuildCode {
     outclassdefs.println("  int type;");
     if(state.MLP || state.OOOJAVA ){
       outclassdefs.println("  int oid;");
+      outclassdefs.println("  int allocsite;");
     }
     if (state.EVENTMONITOR) {
       outclassdefs.println("  int objuid;");
@@ -1428,6 +1429,7 @@ public class BuildCode {
     classdefout.println("  int type;");
     if(state.MLP || state.OOOJAVA){
       classdefout.println("  int oid;");
+      classdefout.println("  int allocsite;");
     }
     if (state.EVENTMONITOR) {
       classdefout.println("  int objuid;");
@@ -2368,8 +2370,8 @@ public class BuildCode {
       ) {
        outmethod.println(  "      /* work scheduler works forever, explicitly exit */");
        if (state.COREPROF) {
-         outmethod.println("EXITPROFILER();");
-         outmethod.println("DUMPPROFILER();");
+         outmethod.println("CP_EXIT();");
+         outmethod.println("CP_DUMP();");
        }
        outmethod.println(  "      exit( 0 );");
       }
@@ -2780,7 +2782,7 @@ public class BuildCode {
         cp = oooa.getCodePlan(fn);
       }
 
-      if( cp != null ) {               
+      if( cp != null ) {
        
        FlatSESEEnterNode currentSESE = cp.getCurrentSESE();
        
@@ -2795,7 +2797,7 @@ public class BuildCode {
 
          output.println("   {");
          output.println("     SESEcommon* common = (SESEcommon*) "+pair+";");
-
+          //output.println("     CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_BEGIN );");
          output.println("     pthread_mutex_lock( &(common->lock) );");
          output.println("     while( common->doneExecuting == FALSE ) {");
          output.println("       pthread_cond_wait( &(common->doneCond), &(common->lock) );");
@@ -2804,7 +2806,7 @@ public class BuildCode {
 
          // copy things we might have stalled for        
          output.println("     "+pair.getSESE().getSESErecordName()+"* child = ("+
-                                pair.getSESE().getSESErecordName()+"*) "+pair+";");
+                         pair.getSESE().getSESErecordName()+"*) "+pair+";");
          
          Iterator<TempDescriptor> tdItr = cp.getCopySet( vst ).iterator();
          while( tdItr.hasNext() ) {
@@ -2819,6 +2821,7 @@ public class BuildCode {
                           " = child->"+vst.getAddrVar().getSafeSymbol()+";");
          }
 
+          //output.println("     CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_END );");
          output.println("   }");
        }
        
@@ -2831,6 +2834,7 @@ public class BuildCode {
          // otherwise the dynamic write nodes will have the local var up-to-date
          output.println("   {");
          output.println("     if( "+dynVar+"_srcSESE != NULL ) {");
+          //output.println("       CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_BEGIN );");
          output.println("       SESEcommon* common = (SESEcommon*) "+dynVar+"_srcSESE;");
          output.println("       psem_take( &(common->stallSem) );");
 
@@ -2842,19 +2846,19 @@ public class BuildCode {
          }
          
          TypeDescriptor type=dynVar.getType();
-      String typeStr;
-      if( type.isNull() ) {
-            typeStr = "void*";
-      } else if( type.isClass() || type.isArray() ) {
-            typeStr = "struct "+type.getSafeSymbol()+"*";
-      } else {
-            typeStr = type.getSafeSymbol();
-      }
+          String typeStr;
+          if( type.isNull() ) {
+            typeStr = "void*";
+          } else if( type.isClass() || type.isArray() ) {
+            typeStr = "struct "+type.getSafeSymbol()+"*";
+          } else {
+            typeStr = type.getSafeSymbol();
+          }
       
          output.println("       "+generateTemp( fmContext, dynVar, null )+
-                " = *(("+typeStr+"*) ("+
-                dynVar+"_srcSESE + "+dynVar+"_srcOffset));");
-         
+                         " = *(("+typeStr+"*) ("+
+                         dynVar+"_srcSESE + "+dynVar+"_srcOffset));");
+          //output.println("       CP_LOGEVENT( CP_EVENTID_TASKSTALLVAR, CP_EVENTTYPE_END );");
          output.println("     }");
          output.println("   }");
        }
@@ -2879,84 +2883,86 @@ public class BuildCode {
           output.println("   "+dynVar+"_srcSESE = NULL;");
        }
        
-         // eom
-    // handling stall site
-    if (state.OOOJAVA) {
-      Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(currentSESE);
-      if(graph!=null){
-        Set<Analysis.OoOJava.SESELock> seseLockSet = oooa.getLockMappings(graph);
-        Set<Analysis.OoOJava.WaitingElement> waitingElementSet =
-            graph.getStallSiteWaitingElementSet(fn, seseLockSet);
+        // eom
+        // handling stall site
+        if (state.OOOJAVA) {
+          Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(currentSESE);
+          if(graph!=null){
+            Set<Analysis.OoOJava.SESELock> seseLockSet = oooa.getLockMappings(graph);
+            Set<Analysis.OoOJava.WaitingElement> waitingElementSet =
+              graph.getStallSiteWaitingElementSet(fn, seseLockSet);
         
-        if(waitingElementSet.size()>0){
-          output.println("// stall on parent's stall sites ");
-          output.println("   {");
-          output.println("     REntry* rentry;");
+            if(waitingElementSet.size()>0){
+              output.println("// stall on parent's stall sites ");
+              output.println("   {");
+              output.println("     REntry* rentry;");
           
-          for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
-            Analysis.OoOJava.WaitingElement waitingElement = (Analysis.OoOJava.WaitingElement) iterator.next();
+              for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
+                Analysis.OoOJava.WaitingElement waitingElement = (Analysis.OoOJava.WaitingElement) iterator.next();
             
-            if( waitingElement.getStatus() >= ConflictNode.COARSE ){
-              output.println("     rentry=mlpCreateREntry("+ waitingElement.getStatus()+ ", seseCaller);");
-            }else{
-              output.println("     rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", seseCaller,  (void*)&" +generateTemp(fm,waitingElement.getTempDesc(),lb)+ ");");
-            }         
-            output.println("     psem_init( &(rentry->parentStallSem) );");
-            output.println("     rentry->queue=seseCaller->memoryQueueArray["+ waitingElement.getQueueID()+ "];");
-            output
-                .println("     if(ADDRENTRY(seseCaller->memoryQueueArray["+ waitingElement.getQueueID()
-                    + "],rentry)==NOTREADY){");
-            output.println("        psem_take( &(rentry->parentStallSem) );");
-            output.println("     }  ");
+                if( waitingElement.getStatus() >= ConflictNode.COARSE ){
+                  output.println("     rentry=mlpCreateREntry("+ waitingElement.getStatus()+ ", seseCaller);");
+                }else{
+                  output.println("     rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", seseCaller,  (void*)&" +generateTemp(fm,waitingElement.getTempDesc(),lb)+ ");");
+                }         
+                output.println("     psem_init( &(rentry->parentStallSem) );");
+                output.println("     rentry->queue=seseCaller->memoryQueueArray["+ waitingElement.getQueueID()+ "];");
+                output
+                  .println("     if(ADDRENTRY(seseCaller->memoryQueueArray["+ waitingElement.getQueueID()
+                           + "],rentry)==NOTREADY){");
+                //output.println("        CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );");
+                output.println("        psem_take( &(rentry->parentStallSem) );");
+                //output.println("        CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );");
+                output.println("     }  ");
+              }
+              output.println("   }");
+            }
           }
-          output.println("   }");
-        }
-      }
-    }else{
-       ParentChildConflictsMap conflictsMap = mlpa.getConflictsResults().get(fn);
-       if (conflictsMap != null) {
-               Set<Long> allocSet = conflictsMap.getAllocationSiteIDSetofStallSite();
-               if (allocSet.size() > 0) {
-                       FlatNode enclosingFlatNode=null;
-                       if( currentSESE.getIsCallerSESEplaceholder() && currentSESE.getParent()==null){
-                               enclosingFlatNode=currentSESE.getfmEnclosing();
-                       }else{
-                               enclosingFlatNode=currentSESE;
-                       }                                               
-                       ConflictGraph graph=mlpa.getConflictGraphResults().get(enclosingFlatNode);
-                       HashSet<SESELock> seseLockSet=mlpa.getConflictGraphLockMap().get(graph);
-                       Set<WaitingElement> waitingElementSet=graph.getStallSiteWaitingElementSet(conflictsMap, seseLockSet);
+        }else{
+          ParentChildConflictsMap conflictsMap = mlpa.getConflictsResults().get(fn);
+          if (conflictsMap != null) {
+            Set<Long> allocSet = conflictsMap.getAllocationSiteIDSetofStallSite();
+            if (allocSet.size() > 0) {
+              FlatNode enclosingFlatNode=null;
+              if( currentSESE.getIsCallerSESEplaceholder() && currentSESE.getParent()==null){
+                enclosingFlatNode=currentSESE.getfmEnclosing();
+              }else{
+                enclosingFlatNode=currentSESE;
+              }                                                
+              ConflictGraph graph=mlpa.getConflictGraphResults().get(enclosingFlatNode);
+              HashSet<SESELock> seseLockSet=mlpa.getConflictGraphLockMap().get(graph);
+              Set<WaitingElement> waitingElementSet=graph.getStallSiteWaitingElementSet(conflictsMap, seseLockSet);
                        
-                       if(waitingElementSet.size()>0){
-                               output.println("// stall on parent's stall sites ");
-                               output.println("   {");
-                               output.println("     REntry* rentry;");
+              if(waitingElementSet.size()>0){
+                output.println("// stall on parent's stall sites ");
+                output.println("   {");
+                output.println("     REntry* rentry;");
                                
-                               for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
-                                       WaitingElement waitingElement = (WaitingElement) iterator.next();
+                for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
+                  WaitingElement waitingElement = (WaitingElement) iterator.next();
                                        
-                                       if( waitingElement.getStatus() >= ConflictNode.COARSE ){
-                                               output.println("     rentry=mlpCreateREntry("+ waitingElement.getStatus()+ ", seseCaller);");
-                                       }else{
-                                               output.println("     rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", seseCaller,  (void*)&___locals___."+ waitingElement.getDynID() + ");");
-  //                                           output.println("     rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", seseCaller,  ___locals___."+ waitingElement.getDynID() + "->oid);");  
-                                       }                                       
-                                       output.println("     psem_init( &(rentry->parentStallSem) );");
-                                       output.println("     rentry->queue=seseCaller->memoryQueueArray["+ waitingElement.getQueueID()+ "];");
-                                       output
-                                                       .println("     if(ADDRENTRY(seseCaller->memoryQueueArray["+ waitingElement.getQueueID()
-                                                                       + "],rentry)==NOTREADY){");
-                                       output.println("        psem_take( &(rentry->parentStallSem) );");
-                                       output.println("     }  ");
-                               }
-                               output.println("   }");
-                       }
-               }
-       }       
+                  if( waitingElement.getStatus() >= ConflictNode.COARSE ){
+                    output.println("     rentry=mlpCreateREntry("+ waitingElement.getStatus()+ ", seseCaller);");
+                  }else{
+                    output.println("     rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", seseCaller,  (void*)&___locals___."+ waitingElement.getDynID() + ");");
+                    //                                         output.println("     rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", seseCaller,  ___locals___."+ waitingElement.getDynID() + "->oid);");  
+                  }                                    
+                  output.println("     psem_init( &(rentry->parentStallSem) );");
+                  output.println("     rentry->queue=seseCaller->memoryQueueArray["+ waitingElement.getQueueID()+ "];");
+                  output
+                    .println("     if(ADDRENTRY(seseCaller->memoryQueueArray["+ waitingElement.getQueueID()
+                             + "],rentry)==NOTREADY){");
+                  //output.println("        CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );");
+                  output.println("        psem_take( &(rentry->parentStallSem) );");
+                  //output.println("        CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );");
+                  output.println("     }  ");
+                }
+                output.println("   }");
+              }
+            }
+          }    
        }
-
-       
-      }     
+      }
     }
 
     switch(fn.kind()) {
@@ -3487,6 +3493,9 @@ public class BuildCode {
 
     output.println("   {");
 
+
+    //output.println("CP_LOGEVENT( CP_EVENTID_TASKDISPATCH, CP_EVENTTYPE_BEGIN );");
+
     // set up the parent
     if( (state.MLP && fsen == mlpa.getMainSESE()) || 
          (state.OOOJAVA && fsen == oooa.getMainSESE()) 
@@ -3956,6 +3965,10 @@ public class BuildCode {
     // release this SESE for siblings to update its dependencies or,
     // eventually, for it to mark itself finished
 //    output.println("     pthread_mutex_unlock( &(seseToIssue->common.lock) );");
+
+
+    //output.println("CP_LOGEVENT( CP_EVENTID_TASKDISPATCH, CP_EVENTTYPE_END );");
+
     output.println("   }");
     
   }
@@ -3972,6 +3985,8 @@ public class BuildCode {
       return;
     }
 
+    //output.println("CP_LOGEVENT( CP_EVENTID_TASKRETIRE, CP_EVENTTYPE_BEGIN );");
+
     // get the enter node for this exit that has meta data embedded
     FlatSESEEnterNode fsen = fsexn.getFlatEnter();
 
@@ -4123,7 +4138,9 @@ public class BuildCode {
     // data has been taken care of--set sese pointer to remember self over method
     // calls to a non-zero, invalid address
     output.println("   seseCaller = (SESEcommon*) 0x1;");    
-    
+
+
+    //output.println("CP_LOGEVENT( CP_EVENTID_TASKRETIRE, CP_EVENTTYPE_END );");
   }
  
   public void generateFlatWriteDynamicVarNode( FlatMethod fm,  
@@ -4726,7 +4743,7 @@ public class BuildCode {
        output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarrayglobal("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
       } else if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
          if(this.state.MLP || state.OOOJAVA){
-       output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray_oid("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+", oid);");
+            output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray_mlp("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+", oid, "+oooa.getDisjointAnalysis().getAllocationSiteFromFlatNew(fn).getUniqueAllocSiteID()+");");
        output.println("    oid += numWorkers;");
          }else{
     output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");                     
@@ -4739,7 +4756,7 @@ public class BuildCode {
        output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newglobal("+fn.getType().getClassDesc().getId()+");");
       } else if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
          if (this.state.MLP || state.OOOJAVA){
-       output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new_oid("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+", oid);");
+       output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new_mlp("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+", oid, "+oooa.getDisjointAnalysis().getAllocationSiteFromFlatNew(fn).getUniqueAllocSiteID()+");");
        output.println("    oid += numWorkers;");
          } else {
     output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+");");                     
index 3c5f876061707d4c21db21fad40cb05aada08938..a21e856ded04d7ebe71fcb5ad01bbc384fc84e7b 100644 (file)
@@ -8,10 +8,11 @@
 #include <stdlib.h>
 #include "mlp_lock.h"
 
-__thread struct coreprofmonitor * cp_events=NULL;
-struct coreprofmonitor * cp_eventlist=NULL;
-static volatile int cp_threadcount=0;
-__thread int cp_threadnum;
+__thread int                     cp_threadnum;
+__thread struct coreprofmonitor* cp_monitor     = NULL;
+         struct coreprofmonitor* cp_monitorList = NULL;
+static volatile int              cp_threadCount = 0;
+
 
 static inline int atomicinc(volatile int *lock) {
   int retval=1;
@@ -23,72 +24,118 @@ static inline int atomicinc(volatile int *lock) {
 }
 
 
-//Need to have global lock before calling this method
-void createprofiler() {
-  if (cp_events!=NULL)
+// Need to have global lock before calling this method
+void cp_create() {
+  if( cp_monitor != NULL )
     return;
-  struct coreprofmonitor *event=calloc(1, sizeof(struct coreprofmonitor));
-  //add new eventmonitor to list
-  struct coreprofmonitor *tmp;
 
-  //add ourself to the list
+  struct coreprofmonitor* monitor = 
+    calloc( 1, sizeof( struct coreprofmonitor ) );
+
+  struct coreprofmonitor* tmp;
+
+  // add ourself to the list
   do {
-    tmp=cp_eventlist;
-    event->next=tmp;
-  } while(CAS(&cp_eventlist, (INTPTR) tmp, (INTPTR) event)!=((INTPTR)tmp));
+    tmp           = cp_monitorList;
+    monitor->next = tmp;
+  } while( CAS( &cp_monitorList, 
+                (INTPTR) tmp, 
+                (INTPTR) monitor 
+                ) != ((INTPTR)tmp)
+           );
 
-  int ourcount=atomicinc(&cp_threadcount);
-  cp_threadnum=ourcount;
+  int ourcount = atomicinc( &cp_threadCount );
+  cp_threadnum = ourcount;
 
-  //point thread lock variable to eventmonitor
-  cp_events=event;
-  CPLOGEVENT(CP_MAIN, CP_BEGIN);
+  // point thread lock variable to event monitor
+  cp_monitor = monitor;
+  CP_LOGEVENT( CP_EVENTID_MAIN, CP_EVENTTYPE_BEGIN );
 }
 
-//Place to do shutdown stuff
-void exitprofiler() {
-  CPLOGEVENT(CP_MAIN, CP_END);
+// Place to do shutdown stuff
+void cp_exit() {
+  CP_LOGEVENT( CP_EVENTID_MAIN, CP_EVENTTYPE_END );
 }
 
-void cpwritedata(int fd, char * buffer, int count) {
-  int offset=0;
-  while(count>0) {
-    int size=write(fd, &buffer[offset], count);
-    offset+=size;
-    count-=size;
+void cp_writedata( int fd, char* buffer, int count ) {
+  int offset = 0;
+  while( count > 0 ) {
+    int size = write( fd, &buffer[offset], count );
+    offset += size;
+    count  -= size;
   }
 }
 
-void dumpprofiler() {
-  int fd=open("logdata",O_RDWR|O_CREAT,S_IRWXU);
-  int count=0;
-  struct coreprofmonitor * ptr=cp_eventlist;
-  int version=0;
-  //Write version number
-  cpwritedata(fd, (char *)&version, sizeof(int));
-  while(ptr!=NULL) {
+
+void cp_dump() {
+  
+  //int fdh   = open( "coreprof-head.dat", O_RDWR | O_CREAT, S_IRWXU );
+  //int fde   = open( "coreprof-evnt.dat", O_RDWR | O_CREAT, S_IRWXU );
+  //int fdt   = open( "coreprof-time.dat", O_RDWR | O_CREAT, S_IRWXU );
+  int fd    = open( "coreprof.dat", O_RDWR | O_CREAT, S_IRWXU );
+  int count = 0;
+  int i;
+
+  struct coreprofmonitor* monitor;
+
+  // WRITING HEADER
+
+  // Write version number
+  int version = 0;
+  cp_writedata( fd, 
+                (char*)&version, 
+                sizeof( int ) );
+
+  // check for overflow
+  monitor = cp_monitorList;
+  while( monitor != NULL ) {
     count++;
-    if (ptr->index>CPMAXEVENTS) {
-      printf("ERROR: EVENT COUNT EXCEEDED\n");
+    if( monitor->numEvents > CP_MAXEVENTS ) {
+      printf( "ERROR: EVENT COUNT EXCEEDED\n" );
     }
-    ptr=ptr->next;
+    monitor = monitor->next;
+  }
+
+  // Write the number of threads
+  cp_writedata( fd, 
+                (char*)&count, 
+                sizeof( int ) );
+
+  monitor = cp_monitorList;
+  while( monitor != NULL ) {
+
+    // Write the number of events for each thread
+    cp_writedata( fd, 
+                  (char*)&monitor->numEvents, 
+                  sizeof( int ) );
+
+    monitor = monitor->next;
   }
 
-  //Write the number of threads
-  cpwritedata(fd, (char *)&count, sizeof(int));
+  // END HEADER, BEGIN DATA
+
+  monitor = cp_monitorList;
+  while( monitor != NULL ) {
 
-  //Write the number of events for each thread
-  ptr=cp_eventlist;
-  while(ptr!=NULL) {
-    cpwritedata(fd, (char *)&ptr->index, sizeof(int));
-    ptr=ptr->next;
+    // Write the event IDs (index matches time below)
+    cp_writedata( fd, 
+                  (char*)monitor->events, 
+                  sizeof( unsigned int )*monitor->numEvents );
+
+    // Write the event timestamps (index matches above)
+    cp_writedata( fd, 
+                  (char*)monitor->logTimes_ms, 
+                  sizeof( long long )*monitor->numEvents );
+    monitor = monitor->next;
   }
 
-  //Dump the data
-  ptr=cp_eventlist;
-  while(ptr!=NULL) {
-    cpwritedata(fd, (char *) ptr->value, sizeof(int)*ptr->index);
-    ptr=ptr->next;
-  }  
-  close(fd);
+  close( fd );
+  //close( fde );
+  //close( fdt );
+}
+
+
+void cp_reportOverflow() {
+  printf( "ERROR: coreprof event overflow\n" ); 
+  exit( -1 );
 }
index bc50df185cc51664066e489dac352edd32a79a30..3e1ab41df3d505cf5465000277e283af87d2e050 100644 (file)
 #ifndef COREPROF_H
 #define COREPROF_H
+
+
 #ifndef COREPROF
+// Core Prof turned off
+
+#define CP_LOGEVENT( eventID, eventType ) ;
+#define CP_CREATE()                       ;
+#define CP_EXIT()                         ; 
+#define CP_DUMP()                         ;
+
 
-//Core Prof turned off
-#define CREATEPROFILER() ;
-#define EXITPROFILER() ;
-#define DUMPPROFILER() ;
-#define CPLOGEVENT(x,y) ;
 #else
+// Core Prof defined
+
 #include <stdlib.h>
 #include "runtime.h"
 
-//Core Prof defined
-#ifndef CPMAXEVENTS
-#define CPMAXEVENTS (1024*1024*128)
+
+#ifndef CP_MAXEVENTS
+#define CP_MAXEVENTS (1024*1024*128)
 #endif
-#define CREATEPROFILER() createprofiler();
-#define EXITPROFILER() exitprofiler();
-#define DUMPPROFILER() dumpprofiler();
 
-#define CPLOGEVENT(x,y) { cp_events->value[cp_events->index++]=((x<<CP_BASE_SHIFT)|y); \
-    CPLOGTIME                                                          \
-      }
 
+// MASK should be enough bits to mask
+// the values of the following event types
+// and BASESHIFT is for shifting IDs
+// past the type bits
+#define CP_EVENT_MASK       3
+#define CP_EVENT_BASESHIFT  2
 
-#define CP_BEGIN 0
-#define CP_END 1
-#define CP_EVENT 2
-#define CP_MASK 3
-#define CP_BASE_SHIFT 2
+#define CP_EVENTTYPE_BEGIN  0
+#define CP_EVENTTYPE_END    1
+#define CP_EVENTTYPE_ONEOFF 2
 
-#define CP_MAIN 0
-#define CP_RUNMALLOC 1
-#define CP_RUNFREE 1
+// Event IDs
+#define CP_EVENTID_MAIN         0
+#define CP_EVENTID_RUNMALLOC    1
+#define CP_EVENTID_RUNFREE      2
+#define CP_EVENTID_TASKDISPATCH 3
+#define CP_EVENTID_TASKRETIRE   4
+#define CP_EVENTID_TASKSTALLVAR 5
+#define CP_EVENTID_TASKSTALLMEM 6
 
-#define CPLOGTIME *((long long *)&cp_events->value[cp_events->index])=rdtsc(); \
-  cp_events->index+=2;
 
 struct coreprofmonitor {
-  int index;
-  struct coreprofmonitor * next;
-  unsigned int value[CPMAXEVENTS];
+  struct coreprofmonitor* next;
+  
+  // index for next empty slot in the following arrays
+  int          numEvents; 
+  unsigned int events     [CP_MAXEVENTS];
+  long long    logTimes_ms[CP_MAXEVENTS];
 };
 
-extern __thread int cp_threadnum;
-extern __thread struct coreprofmonitor * cp_events;
-extern struct coreprofmonitor * cp_eventlist;
-void createprofiler();
-void exitprofiler();
-void dumpprofiler();
-
-static inline void *cp_calloc(int size) {
-  CPLOGEVENT(CP_RUNMALLOC, CP_BEGIN);
-  void *mem=calloc(1,size);
-  CPLOGEVENT(CP_RUNMALLOC, CP_END);
+
+extern __thread int                     cp_threadnum;
+extern __thread struct coreprofmonitor* cp_monitor;
+extern          struct coreprofmonitor* cp_monitorList;
+
+
+#ifndef COREPROF_CHECKOVERFLOW
+// normal, no overflow check version
+#define CP_LOGEVENT( eventID, eventType ) { \
+  cp_monitor->events[cp_monitor->numEvents] = \
+    ((eventID<<CP_EVENT_BASESHIFT)|eventType); \
+  cp_monitor->logTimes_ms[cp_monitor->numEvents] = rdtsc(); \
+  cp_monitor->numEvents++; \
+}
+#else
+// check for event overflow, DEBUG ONLY!
+void cp_reportOverflow();
+#define CP_LOGEVENT( eventID, eventType ) { \
+  if( cp_monitor->numEvents == CP_MAXEVENTS ) \
+    { cp_reportOverflow(); }                  \
+  cp_monitor->events[cp_monitor->numEvents] = \
+    ((eventID<<CP_EVENT_BASESHIFT)|eventType); \
+  cp_monitor->logTimes_ms[cp_monitor->numEvents] = rdtsc(); \
+  cp_monitor->numEvents++; \
+}
+#endif
+
+
+#define CP_CREATE() cp_create();
+#define CP_EXIT()   cp_exit();
+#define CP_DUMP()   cp_dump();
+
+void cp_create();
+void cp_exit();
+void cp_dump();
+
+
+
+static inline void* cp_calloc( int size ) {
+  //CP_LOGEVENT( CP_EVENTID_RUNMALLOC, CP_EVENTTYPE_BEGIN );
+  void* mem = calloc( 1, size );
+  //CP_LOGEVENT( CP_EVENTID_RUNMALLOC, CP_EVENTTYPE_END );
   return mem;
 }
 
-static inline void cp_free(void *ptr) {
-  CPLOGEVENT(CP_RUNFREE, CP_BEGIN);
-  free(ptr);
-  CPLOGEVENT(CP_RUNFREE, CP_END);
+static inline void cp_free( void* ptr ) {
+  //CP_LOGEVENT( CP_EVENTID_RUNFREE, CP_EVENTTYPE_BEGIN );
+  free( ptr );
+  //CP_LOGEVENT( CP_EVENTID_RUNFREE, CP_EVENTTYPE_END );
 }
+
+
 #endif
 #endif
index 4feeb0a943f8d4458441b7a36a1418ad7c5abccf..8cf71847fe0b88bf6b65d88302967862a1846ae8 100644 (file)
@@ -639,9 +639,9 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t
 #if defined(PRECISE_GC)
 #ifdef MLP
 __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
-  return allocate_new_oid(ptr, type, 0);
+  return allocate_new_mlp(ptr, type, 0, 0);
 }
-__attribute__((malloc)) void * allocate_new_oid(void * ptr, int type, int oid) {
+__attribute__((malloc)) void * allocate_new_mlp(void * ptr, int type, int oid, int allocsite) {
 #else
 __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
 #endif
@@ -657,6 +657,7 @@ __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
 #endif
 #ifdef MLP
   v->oid=oid;
+  v->allocsite=allocsite;
 #endif
   return v;
 }
@@ -664,9 +665,9 @@ __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
 /* Array allocation function */
 #ifdef MLP
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
-  return allocate_newarray_oid(ptr, type, length, 0);
+  return allocate_newarray_mlp(ptr, type, length, 0, 0);
 }
- __attribute__((malloc)) struct ArrayObject * allocate_newarray_oid(void * ptr, int type, int length, int oid) {
+ __attribute__((malloc)) struct ArrayObject * allocate_newarray_mlp(void * ptr, int type, int length, int oid, int allocsite) {
 #else
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
 #endif
@@ -687,6 +688,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t
 #endif
 #ifdef MLP
   v->oid=oid;
+  v->allocsite=allocsite;
 #endif
   return v;
 }
index e1122152a6fe7659647e62a18043aba1dc4f2242..47b912833fc13679d10d5dd585c7054962697305 100644 (file)
@@ -63,9 +63,9 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr,
 #ifdef PRECISE_GC
 #include "garbage.h"
 #ifdef MLP
-__attribute__((malloc)) void * allocate_new_oid(void *, int type, int oid);
+__attribute__((malloc)) void * allocate_new_mlp(void *, int type, int oid, int allocsite);
 __attribute__((malloc)) void * allocate_new(void *, int type);
-__attribute__((malloc)) struct ArrayObject * allocate_newarray_oid(void *, int type, int length, int oid);
+__attribute__((malloc)) struct ArrayObject * allocate_newarray_mlp(void *, int type, int length, int oid, int allocsite);
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length);
 #else
 __attribute__((malloc)) void * allocate_new(void *, int type);
index f68f2a454d30c3cac46d15df770ab15fb9fd5bd4..82c57278c310998423f4b51a54ab59b7e8cfee63 100644 (file)
@@ -54,7 +54,7 @@ void* workerMain( void* arg ) {
   void* workUnit;
   WorkerData* myData = (WorkerData*) arg;
   //Start profiler
-  CREATEPROFILER();
+  CP_CREATE();
   
   oid=myData->id;
   // make sure init mlp once-per-thread stuff
@@ -102,14 +102,18 @@ void* workerMain( void* arg ) {
     }
     pthread_mutex_unlock(&gclistlock);
   }
-  EXITPROFILER();
+
+  CP_EXIT();
+
   return NULL;
 }
 
 void workScheduleInit( int numProcessors,
                        void(*func)(void*) ) {
   int i, status;
-  CREATEPROFILER();
+
+  CP_CREATE();
+
   pthread_mutex_init(&gclock, NULL);
   pthread_mutex_init(&gclistlock, NULL);
   pthread_cond_init(&gccond, NULL);
index 2ccc65ab57e13eb59160f35df3d40c88be962ebf..d503c66261e2c75b66353e821ba85a6df3e2a0f6 100755 (executable)
@@ -18,6 +18,7 @@ echo "-eventmonitor turn on transaction event trace recording"
 echo
 echo OOOJava options
 echo -coreprof turn on profiling API
+echo -coreprof-checkoverflow ONLY use for debugging event overflow
 echo "-ooojava <numberofcores> <maxseseage>"
 echo -ooodebug general OOOJava debugging messages
 echo -rcr turn on runtime conflict resolver
@@ -517,6 +518,10 @@ COREPROF=true
 JAVAOPTS="$JAVAOPTS -coreprof"
 EXTRAOPTIONS="$EXTRAOPTIONS -DCOREPROF -I$ROBUSTROOT/Runtime/coreprof"
 
+elif [[ $1 = '-coreprof-checkoverflow' ]]
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DCOREPROF_CHECKOVERFLOW"
+
 elif [[ $1 = '-mlp' ]]
 then
 MLP_ON=true