//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;");
}
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()];
/* 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;");
}
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()+ "];");
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()
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
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)+");");
}
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()+");");
}
#include "mem.h"
#include "mlp_runtime.h"
#include "workschedule.h"
+#include "methodheaders.h"
+
/*
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;
}
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];
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];
}
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);
}
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);
}
psemaphore parentStallSem;
void* seseRec;
INTPTR* pointer;
+ int oid;
} REntry;
typedef struct MemoryQueueItem_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
#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) {
#endif
#ifdef OPTIONAL
v->fses=0;
+#endif
+#ifdef MLP
+ v->oid=oid;
#endif
return v;
}
#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
} workerData;
*/
+typedef struct workerData_t{
+ pthread_t workerThread;
+ int id;
+} WorkerData;
+
static pthread_mutex_t systemLockIn;
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;
static pthread_cond_t workAvailCond = PTHREAD_COND_INITIALIZER;
+int numWorkers;
int threadcount;
pthread_mutex_t gclock;
extern __thread struct listitem litem;
extern __thread SESEcommon* seseCommon;
+__thread int oid;
+
/*
struct QI {
struct QI * next;
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 );
// then continue to process work
while( 1 ) {
-
+
/*
while(1){
if(pthread_mutex_trylock(&systemLock)==0){
list=&litem;
seseCommon=(SESEcommon*)workUnit;
pthread_mutex_unlock(&gclistlock);
-
+
workFunc( workUnit );
pthread_mutex_lock(&gclistlock);
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
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 );
}
}