task execute, dispatch, reture and work grabbing events debugged
authorjjenista <jjenista>
Fri, 10 Sep 2010 19:44:11 +0000 (19:44 +0000)
committerjjenista <jjenista>
Fri, 10 Sep 2010 19:44:11 +0000 (19:44 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/coreprof/coreprof.h
Robust/src/Runtime/workschedule.c

index d5729c55bab283bdca387e3c8d9b88c4ff94430c..6f002a13b3a1280f92e70ae01975e14b59939f5c 100644 (file)
@@ -2379,6 +2379,10 @@ public class BuildCode {
 
     // initialize thread-local var to a non-zero, invalid address
     output.println("   seseCaller = (SESEcommon*) 0x2;");
+
+
+    output.println("   CP_LOGEVENT( CP_EVENTID_TASKEXECUTE, CP_EVENTTYPE_BEGIN );");
+
     HashSet<FlatNode> exitset=new HashSet<FlatNode>();
     exitset.add(seseExit);    
     generateCode(fsen.getNext(0), fm, null, exitset, output, true);
@@ -3570,7 +3574,7 @@ public class BuildCode {
     output.println("   {");
 
 
-    //output.println("CP_LOGEVENT( CP_EVENTID_TASKDISPATCH, CP_EVENTTYPE_BEGIN );");
+    output.println("CP_LOGEVENT( CP_EVENTID_TASKDISPATCH, CP_EVENTTYPE_BEGIN );");
 
     // set up the parent
     if( (state.MLP && fsen == mlpa.getMainSESE()) || 
@@ -4075,7 +4079,7 @@ public class BuildCode {
 //    output.println("     pthread_mutex_unlock( &(seseToIssue->common.lock) );");
 
 
-    //output.println("CP_LOGEVENT( CP_EVENTID_TASKDISPATCH, CP_EVENTTYPE_END );");
+    output.println("CP_LOGEVENT( CP_EVENTID_TASKDISPATCH, CP_EVENTTYPE_END );");
 
     output.println("   }");
     
@@ -4093,8 +4097,6 @@ 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();
 
@@ -4110,7 +4112,10 @@ public class BuildCode {
       return;
     }
 
+    output.println("   CP_LOGEVENT( CP_EVENTID_TASKEXECUTE, CP_EVENTTYPE_END );");
+
     output.println("   /* SESE exiting */");
+    output.println("   CP_LOGEVENT( CP_EVENTID_TASKRETIRE, CP_EVENTTYPE_BEGIN );");
     
     String com = paramsprefix+"->common";
 
@@ -4248,7 +4253,7 @@ public class BuildCode {
     output.println("   seseCaller = (SESEcommon*) 0x1;");    
 
 
-    //output.println("CP_LOGEVENT( CP_EVENTID_TASKRETIRE, CP_EVENTTYPE_END );");
+    output.println("   CP_LOGEVENT( CP_EVENTID_TASKRETIRE, CP_EVENTTYPE_END );");
   }
  
   public void generateFlatWriteDynamicVarNode( FlatMethod fm,  
index 97f5749b7dd94f0edfb1484bc2b65230c719f4fe..ad90a68b8f1f907a838a93e14fb0986d879edab4 100644 (file)
 #define CP_EVENTTYPE_ONEOFF 3
 
 // Event IDs
-#define CP_EVENTID_MAIN         0x04
-#define CP_EVENTID_RUNMALLOC    0x05
-#define CP_EVENTID_RUNFREE      0x06
-#define CP_EVENTID_TASKDISPATCH 0x07
-#define CP_EVENTID_TASKRETIRE   0x08
-#define CP_EVENTID_TASKSTALLVAR 0x09
-#define CP_EVENTID_TASKSTALLMEM 0x0a
+#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
 // Note: application-specific events (assigned
-// during code gen) start at 0x100
+// during code gen) start at 0x200
 
 
 
index 9375b4314f69d9f6037c2390e19ff854dbef2fca..305a2a4ebdd678ba4b174659e132fd9fbf9597c5 100644 (file)
@@ -63,6 +63,7 @@ void* workerMain( void* arg ) {
   void*       workUnit;
   WorkerData* myData = (WorkerData*) arg;
   int         oldState;
+  int         haveWork;
 
   // once-per-thread stuff
   CP_CREATE();
@@ -77,18 +78,25 @@ void* workerMain( void* arg ) {
   // then continue to process work
   while( 1 ) {
 
-    pthread_mutex_lock( &systemLockOut );
     // wait for work
-    if (headqi->next==NULL) {
-      pthread_mutex_unlock( &systemLockOut );
-      sched_yield();
-      continue;
+    CP_LOGEVENT( CP_EVENTID_WORKSCHEDGRAB, CP_EVENTTYPE_BEGIN );
+    haveWork = FALSE;
+    while( !haveWork ) {
+      pthread_mutex_lock( &systemLockOut );
+      if( headqi->next == NULL ) {
+        pthread_mutex_unlock( &systemLockOut );
+        sched_yield();
+        continue;
+      } else {
+        haveWork = TRUE;
+      }
     }
     struct QI * tmp=headqi;
     headqi = headqi->next;
     workUnit = headqi->value;
     pthread_mutex_unlock( &systemLockOut );
-    free(tmp);
+    free( tmp );
+    CP_LOGEVENT( CP_EVENTID_WORKSCHEDGRAB, CP_EVENTTYPE_END );
     
     pthread_mutex_lock(&gclistlock);
     threadcount++;