changes for using unique ID instead of obj address for the memory queue
authoryeom <yeom>
Tue, 4 May 2010 23:58:42 +0000 (23:58 +0000)
committeryeom <yeom>
Tue, 4 May 2010 23:58:42 +0000 (23:58 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/mlp_runtime.c
Robust/src/Runtime/mlp_runtime.h
Robust/src/Runtime/runtime.c
Robust/src/Runtime/runtime.h
Robust/src/Runtime/workschedule.c

index 85b4c1e3621342021235b1bd3e4286f18dd0e2d2..496f32937462cd8eaab7210084ca5ff2c89f73e4 100644 (file)
@@ -637,6 +637,7 @@ public class BuildCode {
     //Print out definition for array type
     outclassdefs.println("struct "+arraytype+" {");
     outclassdefs.println("  int type;");
+    outclassdefs.println("  int oid;");
     if (state.EVENTMONITOR) {
       outclassdefs.println("  int objuid;");
     }
@@ -979,6 +980,10 @@ public class BuildCode {
     outclassdefs.print("#endif\n");
 
     outclassdefs.print("int numprefetchsites = " + pa.prefetchsiteid + ";\n");
+    if(this.state.MLP){
+       outclassdefs.print("extern __thread int oid;\n");
+       outclassdefs.print("extern int numWorkers;\n");
+    }
 
     Iterator it=state.getClassSymbolTable().getDescriptorsIterator();
     cdarray=new ClassDescriptor[state.numClasses()];
@@ -1375,6 +1380,9 @@ public class BuildCode {
     /* Output class structure */
     classdefout.println("struct "+cn.getSafeSymbol()+" {");
     classdefout.println("  int type;");
+    if(state.MLP){
+      classdefout.println("  int oid;");
+    }
     if (state.EVENTMONITOR) {
       classdefout.println("  int objuid;");
     }
@@ -2778,7 +2786,8 @@ public class BuildCode {
                                        if( waitingElement.getStatus() >= ConflictNode.COARSE ){
                                                output.println("     rentry=mlpCreateREntry("+ waitingElement.getStatus()+ ", seseCaller);");
                                        }else{
-                                               output.println("     rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", seseCaller,  ___locals___."+ waitingElement.getDynID() + ");");       
+                                               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()+ "];");
@@ -3557,11 +3566,16 @@ public class BuildCode {
                                                                output.println("     pointer=seseToIssue->"+ waitingElement.getDynID()+"_srcSESE+seseToIssue->"+ waitingElement.getDynID()+"_srcOffset;");
                                                                output.println("     rentry=mlpCreateFineREntry("
                                                                                + waitingElement.getStatus()
-                                                                               + ", seseToIssue,  pointer );");                                                                
+                                                                               + ", seseToIssue,  pointer );");
+//                                                             output.println("     rentry=mlpCreateFineREntry("
+//                                                                             + waitingElement.getStatus()
+//                                                                             + ", seseToIssue, seseToIssue->"
+//                                                                             + waitingElement.getDynID() + "->oid);");
                                                        }else if(fsen.getStaticInVarSet().contains(td)){
                                                                // static in-var case
                                                                VariableSourceToken vst = fsen.getStaticInVarSrc(td);
                                                                if (vst != null) {
+                                                                       
                                                                        String srcId = "SESE_"
                                                                                        + vst.getSESE()
                                                                                                        .getPrettyIdentifier()
@@ -3576,12 +3590,21 @@ public class BuildCode {
                                                                        output.println("     rentry=mlpCreateFineREntry("
                                                                                        + waitingElement.getStatus()
                                                                                        + ", seseToIssue,  pointer );");                
+                                                                       
+//                                                                     output.println("     rentry=mlpCreateFineREntry("
+//                                                                                     + waitingElement.getStatus()
+//                                                                                     + ", seseToIssue, seseToIssue->"
+//                                                                                     + waitingElement.getDynID() + "->oid);");
                                                                }
                                                        }else{
                                                                output.println("     rentry=mlpCreateFineREntry("
                                                                                + waitingElement.getStatus()
                                                                                + ", seseToIssue,  (void*)&seseToIssue->"
                                                                                + waitingElement.getDynID() + ");");
+//                                                             output.println("     rentry=mlpCreateFineREntry("
+//                                                                             + waitingElement.getStatus()
+//                                                                             + ", seseToIssue, seseToIssue->"
+//                                                                             + waitingElement.getDynID() + "->oid);");
                                                        }
                                                }
                                                output
@@ -4382,7 +4405,12 @@ public class BuildCode {
       if (fn.isGlobal()&&(state.DSM||state.SINGLETM)) {
        output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarrayglobal("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
       } else if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
-       output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
+         if(this.state.MLP){
+       output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray_oid("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+", oid);");
+       output.println("    oid += numWorkers;");
+         }else{
+    output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");                     
+         }
       } else {
        output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
       }
@@ -4390,7 +4418,12 @@ public class BuildCode {
       if (fn.isGlobal()&&(state.DSM||state.SINGLETM)) {
        output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newglobal("+fn.getType().getClassDesc().getId()+");");
       } else if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
-       output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+");");
+         if (this.state.MLP){
+       output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new_oid("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+", oid);");
+       output.println("    oid += numWorkers;");
+         } else {
+    output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+");");                     
+         }
       } else {
        output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+fn.getType().getClassDesc().getId()+");");
       }
index 7d6a72845639b80ab9eff37d1e47165d8edcbf54..7302fc7bf50597725526ad0dbaf2625d947945f0 100644 (file)
@@ -7,6 +7,8 @@
 #include "mem.h"
 #include "mlp_runtime.h"
 #include "workschedule.h"
+#include "methodheaders.h"
+
 
 
 /*
@@ -52,6 +54,10 @@ REntry* mlpCreateFineREntry(int type, void* seseToIssue, void* dynID){
   newREntry->type=type;
   newREntry->seseRec=seseToIssue;
   newREntry->pointer=dynID;
+  if((*newREntry->pointer)!=0){// make sure it is not unresolved address.
+    struct ___Object___ * obj=(struct ___Object___*)((unsigned INTPTR)*newREntry->pointer);
+    newREntry->oid=obj->oid;
+  }
   return newREntry;
 }
 
@@ -267,7 +273,8 @@ int ADDTABLE(MemoryQueue *q, REntry *r) {
     return NOTREADY;
   }
   BinItem * val;
-  int key=generateKey((unsigned int)(unsigned INTPTR)*(r->pointer));
+  //int key=generateKey((unsigned int)(unsigned INTPTR)*(r->pointer));  
+  int key=generateKey(r->oid);
   do {  
     val=(BinItem*)0x1;       
     BinElement* bin=table->array[key];
@@ -288,7 +295,8 @@ int ADDTABLE(MemoryQueue *q, REntry *r) {
 int ADDTABLEITEM(Hashtable* table, REntry* r, int inc){
  
   BinItem * val;
-  int key=generateKey((unsigned int)(unsigned INTPTR)*(r->pointer));
+  //  int key=generateKey((unsigned int)(unsigned INTPTR)*(r->pointer));
+  int key=generateKey(r->oid);
   do {  
     val=(BinItem*)0x1;       
     BinElement* bin=table->array[key];
@@ -564,7 +572,8 @@ RETIREHASHTABLE(MemoryQueue *q, REntry *r) {
 }
 
 RETIREBIN(Hashtable *T, REntry *r, BinItem *b) {
-  int key=generateKey((unsigned int)(unsigned INTPTR)*(r->pointer));
+  //  int key=generateKey((unsigned int)(unsigned INTPTR)*(r->pointer));
+  int key=generateKey(r->oid);
   if(isFineRead(r)) {
     atomic_dec(&b->total);
   }
@@ -792,6 +801,9 @@ resolvePointer(REntry* rentry){
          break;
        }
        removeItem(val,head);
+       //now, address is resolved. update OID field.
+       struct ___Object___ * obj=(struct ___Object___*)((unsigned INTPTR)*rentry->pointer);
+       rentry->oid=obj->oid;
        if(ADDTABLEITEM(table, rentry, FALSE)==READY){
          resolveDependencies(rentry);
        }
index 7cf08a4c27dfc84cd638bdc8756dc60c28f8ee91..e415fce3c6ae331feb121aecf3aa3ae3b7f081d8 100644 (file)
@@ -58,6 +58,7 @@ typedef struct REntry_t{
   psemaphore parentStallSem;
   void* seseRec;
   INTPTR* pointer;
+  int oid;
 } REntry;
 
 typedef struct MemoryQueueItem_t {
index 038e80b32646e19eedfc581b1cfad1a559f06070..3c6b39119f00da0225114bfa59a482938ae3ef3f 100644 (file)
@@ -593,7 +593,14 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t
 
 #ifndef STM
 #if defined(PRECISE_GC)
+#ifdef MLP
 __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
+  return allocate_new_oid(ptr, type, 0);
+}
+__attribute__((malloc)) void * allocate_new_oid(void * ptr, int type, int oid) {
+#else
+__attribute__((malloc)) void * allocate_new(void * ptr, int type) {
+#endif
   struct ___Object___ * v=(struct ___Object___ *) mygcmalloc((struct garbagelist *) ptr, classsize[type]);
   v->type=type;
 #ifdef THREADS
@@ -603,13 +610,22 @@ __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
 #endif
 #ifdef OPTIONAL
   v->fses=0;
+#endif
+#ifdef MLP
+  v->oid=oid;
 #endif
   return v;
 }
 
 /* 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);
+}
+ __attribute__((malloc)) struct ArrayObject * allocate_newarray_oid(void * ptr, int type, int length, int oid) {
+#else
+__attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
+#endif
   struct ArrayObject * v=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+length*classsize[type]);
   v->type=type;
   if (length<0) {
@@ -624,6 +640,9 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t
 #endif
 #ifdef OPTIONAL
   v->fses=0;
+#endif
+#ifdef MLP
+  v->oid=oid;
 #endif
   return v;
 }
index 02ef5503674f0c1dbb341f856a93e635106571d5..6c8257a7b36a1c26e051bad1c733382224f4547a 100644 (file)
@@ -62,8 +62,15 @@ __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(void *, int type);
+__attribute__((malloc)) struct ArrayObject * allocate_newarray_oid(void *, int type, int length, int oid);
+__attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length);
+#else
 __attribute__((malloc)) void * allocate_new(void *, int type);
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
+#endif
 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
 #elif defined MULTICORE_GC
index 451b8a2d0e6483f0c950408f03ab157e9c65dcc2..d0c4efc36a8963d3b920b7a3b3308eccd452f317 100644 (file)
@@ -28,6 +28,11 @@ typedef struct workerData_t {
 } workerData;
 */
 
+typedef struct workerData_t{
+  pthread_t workerThread;
+  int id;
+} WorkerData;
+
 
 static pthread_mutex_t systemLockIn;
 static pthread_mutex_t systemLockOut;
@@ -38,8 +43,7 @@ static pthread_mutex_t systemLockOut;
 
 
 // implementation internal data
-static int             numWorkers;
-//static workerData*     workerDataArray;
+static WorkerData*     workerDataArray;
 static pthread_t*      workerArray;
 
 static int systemStarted = 0;
@@ -52,6 +56,7 @@ static void(*workFunc)(void*);
 
 static pthread_cond_t  workAvailCond  = PTHREAD_COND_INITIALIZER;
 
+int             numWorkers;
 
 int threadcount;
 pthread_mutex_t gclock;
@@ -62,6 +67,8 @@ extern struct listitem * list;
 extern __thread struct listitem litem;
 extern __thread SESEcommon* seseCommon;
 
+__thread int oid;
+
 /*
 struct QI {
   struct QI * next;
@@ -170,6 +177,8 @@ void* workerMain( void* arg ) {
 void* workerMain( void* arg ) {
   
   void* workUnit;
+  WorkerData* myData = (WorkerData*) arg;
+  oid=myData->id;
 
   // make sure init mlp once-per-thread stuff
   //pthread_once( &mlpOnceObj, mlpInitOncePerThread );
@@ -178,7 +187,7 @@ void* workerMain( void* arg ) {
 
   // then continue to process work
   while( 1 ) {
-
+   
     /*
     while(1){
       if(pthread_mutex_trylock(&systemLock)==0){
@@ -221,7 +230,7 @@ void* workerMain( void* arg ) {
     list=&litem;
     seseCommon=(SESEcommon*)workUnit;   
     pthread_mutex_unlock(&gclistlock);
-    
+
     workFunc( workUnit );
     
     pthread_mutex_lock(&gclistlock);
@@ -310,10 +319,17 @@ void workScheduleInit( int numProcessors,
   status = pthread_mutex_init( &systemLockIn, NULL );
   status = pthread_mutex_init( &systemLockOut, NULL );
 
-  workerArray = RUNMALLOC( sizeof( pthread_t ) * numWorkers );
+  //workerArray = RUNMALLOC( sizeof( pthread_t ) * numWorkers );
+  workerDataArray = RUNMALLOC( sizeof( WorkerData ) * numWorkers );
 
-  for( i = 0; i < numWorkers; ++i ) {    
-    status = pthread_create( &(workerArray[i]), NULL, workerMain, NULL );
+  for( i = 0; i < numWorkers; ++i ) {   
+    workerDataArray[i].id=i+2;
+    status = pthread_create( &(workerDataArray[i].workerThread), 
+                             NULL,
+                             workerMain,
+                             (void*) &(workerDataArray[i])
+                           );
+    //status = pthread_create( &(workerArray[i]), NULL, workerMain, NULL );
     if( status != 0 ) { printf( "Error\n" ); exit( -1 ); }
 
     // yield and let all workers get to the beginx3
@@ -370,10 +386,14 @@ void workScheduleSubmit( void* workUnit ) {
 void workScheduleBegin() {
   
   int i;  
-  workerMain(NULL);
+  WorkerData *workerData = RUNMALLOC( sizeof( WorkerData ) );
+  workerData->id=1;
+  // workerMain(NULL);
+  workerMain(workerData);
 
   // tell all workers to begin
   for( i = 0; i < numWorkers; ++i ) {
-    pthread_join( workerArray[i], NULL );
+    //pthread_join( workerArray[i], NULL );
+    pthread_join( workerDataArray[i].workerThread, NULL );
   }
 }