From: jjenista Date: Mon, 9 Aug 2010 22:20:53 +0000 (+0000) Subject: did something I shouldnt have, mixed changes for two different projects at once,... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d09512311b728139c0c7b559e30bdcb28390982d;p=IRC.git did something I shouldnt have, mixed changes for two different projects at once, hard to back out now so heres a commit and ill physically check with everyone for immediate broken environemnts. change 1, updating the coreprof system, in progress but stable for anyone not using coreprof and change 2, add an allocsite field to Objects in generated c code that is populated at allocation, stephen can use it, and maybe future ooojava subsystems, to tell what site an object was allocated at --- diff --git a/Robust/src/Analysis/Disjoint/AllocSite.java b/Robust/src/Analysis/Disjoint/AllocSite.java index 0e40e0d4..6589ecb5 100644 --- a/Robust/src/Analysis/Disjoint/AllocSite.java +++ b/Robust/src/Analysis/Disjoint/AllocSite.java @@ -104,6 +104,10 @@ public class AllocSite extends Canonical { return new Integer( uniqueIDcount ); } + public int getUniqueAllocSiteID() { + return id; + } + public String getDisjointAnalysisId() { return disjointId; } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 5159f7eb..35bfc4f0 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -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 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 seseLockSet = oooa.getLockMappings(graph); - Set waitingElementSet = - graph.getStallSiteWaitingElementSet(fn, seseLockSet); + // eom + // handling stall site + if (state.OOOJAVA) { + Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(currentSESE); + if(graph!=null){ + Set seseLockSet = oooa.getLockMappings(graph); + Set 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 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 seseLockSet=mlpa.getConflictGraphLockMap().get(graph); - Set waitingElementSet=graph.getStallSiteWaitingElementSet(conflictsMap, seseLockSet); + }else{ + ParentChildConflictsMap conflictsMap = mlpa.getConflictsResults().get(fn); + if (conflictsMap != null) { + Set 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 seseLockSet=mlpa.getConflictGraphLockMap().get(graph); + Set 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()+");"); diff --git a/Robust/src/Runtime/coreprof/coreprof.c b/Robust/src/Runtime/coreprof/coreprof.c index 3c5f8760..a21e856d 100644 --- a/Robust/src/Runtime/coreprof/coreprof.c +++ b/Robust/src/Runtime/coreprof/coreprof.c @@ -8,10 +8,11 @@ #include #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 ); } diff --git a/Robust/src/Runtime/coreprof/coreprof.h b/Robust/src/Runtime/coreprof/coreprof.h index bc50df18..3e1ab41d 100644 --- a/Robust/src/Runtime/coreprof/coreprof.h +++ b/Robust/src/Runtime/coreprof/coreprof.h @@ -1,66 +1,109 @@ #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 #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<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<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<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 diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index 4feeb0a9..8cf71847 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -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; } diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index e1122152..47b91283 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -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); diff --git a/Robust/src/Runtime/workschedule.c b/Robust/src/Runtime/workschedule.c index f68f2a45..82c57278 100644 --- a/Robust/src/Runtime/workschedule.c +++ b/Robust/src/Runtime/workschedule.c @@ -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); diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 2ccc65ab..d503c662 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -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 " 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