# HG changeset patch # User Nina Engelhardt # Date 1328798411 -3600 # Node ID 20358f56e498bb94cbce0687a5905daab6ec679c # Parent fe5ad5726e362543cc206020bed27a1a1f63503a fix coreloop recording bug and eliminate race condition on measurement-collecting list diff -r fe5ad5726e36 -r 20358f56e498 CoreLoop.c --- a/CoreLoop.c Fri Feb 03 17:32:48 2012 +0100 +++ b/CoreLoop.c Thu Feb 09 15:40:11 2012 +0100 @@ -79,6 +79,7 @@ if(errorCode){ printf("\nset affinity failure\n"); exit(0); } #ifdef MEAS__PERF_COUNTERS CounterHandler counterHandler = _VMSMasterEnv->counterHandler; + VirtProcr *lastVPBeforeMaster = NULL; #endif //Save the return address in the SwitchVP function @@ -91,7 +92,7 @@ if(currPr){ uint64 cycles,instrs; saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); - (*counterHandler)(CoreLoop_afterWork,currPr,cycles,instrs); + (*counterHandler)(Work_end,currPr->procrID,currPr->numTimesScheduled,currPr,cycles,instrs); } #endif //Get virtual processor from queue @@ -119,7 +120,11 @@ currPr = (VirtProcr *) readVMSQ( readyToAnimateQ ); #endif - if( currPr != NULL ) _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; + if( currPr != NULL ){ + _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; + //save last VP here + lastVPBeforeMaster = currPr; + } else { //============================= MEASUREMENT STUFF ===================== @@ -127,8 +132,17 @@ int32 startStamp, endStamp; saveLowTimeStampCountInto( startStamp ); #endif + #ifdef MEAS__PERF_COUNTERS + if(lastVPBeforeMaster){ + uint64 cycles,instrs; + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); + (*counterHandler)(AppResponderInvocation_start,lastVPBeforeMaster->procrID,lastVPBeforeMaster->numTimesScheduled,lastVPBeforeMaster,cycles,instrs); + lastVPBeforeMaster = NULL; + } + #endif //===================================================================== int tries = 0; int gotLock = 0; + //TODO: startinvocation time here while( currPr == NULL ) //if queue was empty, enter get masterLock loop { //queue was empty, so get master lock @@ -165,7 +179,7 @@ if(currPr){ uint64 cycles,instrs; saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); - (*counterHandler)(CoreLoop_beforeWork,currPr,cycles,instrs); + (*counterHandler)(Work_start,currPr->procrID,currPr->numTimesScheduled,currPr,cycles,instrs); } #endif switchToVP(currPr); //The VPs return in here diff -r fe5ad5726e36 -r 20358f56e498 MasterLoop.c --- a/MasterLoop.c Fri Feb 03 17:32:48 2012 +0100 +++ b/MasterLoop.c Thu Feb 09 15:40:11 2012 +0100 @@ -133,7 +133,7 @@ #ifdef MEAS__PERF_COUNTERS CounterHandler counterHandler = masterEnv->counterHandler; #endif - + // //Poll each slot's Done flag numSlotsFilled = 0; for( slotIdx = 0; slotIdx < NUM_SCHED_SLOTS; slotIdx++) @@ -152,10 +152,11 @@ saveLowTimeStampCountInto( startStamp1 ); #endif #ifdef MEAS__PERF_COUNTERS - VirtProcr p_sav = *(currSlot->procrAssignedToSlot); + int vpid = currSlot->procrAssignedToSlot->procrID; + int task = currSlot->procrAssignedToSlot->numTimesScheduled; uint64 cycles, instrs; saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); - (*counterHandler)(MasterLoop_beforeReqHdlr,&p_sav,cycles,instrs); + (*counterHandler)(AppResponder_start,vpid,task,currSlot->procrAssignedToSlot,cycles,instrs); #endif //============================================================ (*requestHandler)( currSlot->procrAssignedToSlot, semanticEnv ); @@ -171,7 +172,7 @@ //done with constraints check uint64 cycles2,instrs2; saveCyclesAndInstrs(thisCoresIdx,cycles2, instrs2); - (*counterHandler)(MasterLoop_afterReqHdlr,&p_sav,cycles2,instrs2); + (*counterHandler)(AppResponder_end,vpid,task,currSlot->procrAssignedToSlot,cycles2,instrs2); #endif //============================================================ } @@ -200,8 +201,8 @@ uint64 cycles; uint64 instrs; saveCyclesAndInstrs(thisCoresIdx,cycles,instrs); - (*counterHandler)(MasterLoop_beforeAssign,schedVirtPr,tmp_cycles,tmp_instrs); - (*counterHandler)(MasterLoop_afterAssign,schedVirtPr,cycles,instrs); + (*counterHandler)(Assigner_start,schedVirtPr->procrID,schedVirtPr->numTimesScheduled,schedVirtPr,tmp_cycles,tmp_instrs); + (*counterHandler)(Assigner_end,schedVirtPr->procrID,schedVirtPr->numTimesScheduled,schedVirtPr,cycles,instrs); #endif } } diff -r fe5ad5726e36 -r 20358f56e498 ProcrContext.c --- a/ProcrContext.c Fri Feb 03 17:32:48 2012 +0100 +++ b/ProcrContext.c Thu Feb 09 15:40:11 2012 +0100 @@ -27,7 +27,8 @@ newPr->initialData = initialData; newPr->requests = NULL; newPr->schedSlot = NULL; - + newPr->isMasterVP = FALSE; + newPr->isShutdownVP = FALSE; /* * Hardware dependent part */ diff -r fe5ad5726e36 -r 20358f56e498 VMS.c --- a/VMS.c Fri Feb 03 17:32:48 2012 +0100 +++ b/VMS.c Thu Feb 09 15:40:11 2012 +0100 @@ -149,6 +149,7 @@ //Q: should give masterVP core-specific info as its init data? masterVPs[ coreIdx ] = VMS__create_procr( (VirtProcrFnPtr)&masterLoop, (void*)masterEnv ); masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx; + masterVPs[ coreIdx ]->isMasterVP = TRUE; allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core _VMSMasterEnv->numMasterInARow[ coreIdx ] = 0; _VMSMasterEnv->workStealingGates[ coreIdx ] = NULL; @@ -440,7 +441,7 @@ //start work uint64 cycles,instrs; saveCyclesAndInstrs(animatingPr->coreAnimatedBy,cycles, instrs); - (*(_VMSMasterEnv->counterHandler))(Procr_suspend,animatingPr,cycles,instrs); + (*(_VMSMasterEnv->counterHandler))(HwResponderInvocation_start,animatingPr->procrID,animatingPr->numTimesScheduled,animatingPr,cycles,instrs); #endif //======================================================================= @@ -730,6 +731,7 @@ for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ ) { //Note, this is running in the master shutDownPr = VMS__create_procr( &endOSThreadFn, NULL ); + shutDownPr->isShutdownVP = TRUE; writeVMSQ( shutDownPr, _VMSMasterEnv->readyToAnimateQs[coreIdx] ); } #ifdef MEAS__PERF_COUNTERS diff -r fe5ad5726e36 -r 20358f56e498 VMS.h --- a/VMS.h Fri Feb 03 17:32:48 2012 +0100 +++ b/VMS.h Thu Feb 09 15:40:11 2012 +0100 @@ -86,7 +86,7 @@ // tradeoff amortizing master fixed overhead vs imbalance potential // when work-stealing, can make bigger, at risk of losing cache affinity -#define NUM_SCHED_SLOTS 1 +#define NUM_SCHED_SLOTS 5 #define MIN_WORK_UNIT_CYCLES 20000 @@ -129,7 +129,7 @@ typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); -typedef void (*CounterHandler) (int,VirtProcr*,uint64,uint64); +typedef void (*CounterHandler) (int,int,int,VirtProcr*,uint64,uint64); //============= Requests =========== // @@ -212,6 +212,8 @@ //CounterRecord** counter_history; //PrivDynArrayInfo* counter_history_array_info; #endif + int isMasterVP; + int isShutdownVP; //======================================== float64 createPtInSecs; //have space but don't use on some configs @@ -443,14 +445,15 @@ } while (0) enum eventType { - MasterLoop_beforeReqHdlr = 1, - MasterLoop_afterReqHdlr, - MasterLoop_beforeAssign, - MasterLoop_afterAssign, - CoreLoop_afterWork, - CoreLoop_beforeWork, - Procr_suspend, - MasterLoop_beforeNextAssign + DebugEvt = 0, + AppResponderInvocation_start, + AppResponder_start, + AppResponder_end, + Assigner_start, + Assigner_end, + Work_start, + Work_end, + HwResponderInvocation_start }; #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \