# HG changeset patch # User Merten Sach # Date 1324062021 -3600 # Node ID d1dd9e6ee72c95c274e8e6e6bfec3bc43d2cfc76 # Parent cb7277bac14787a038847c603f518f726cf81015 VMS preprocessor definitions moved to VMS_defs.h and changes to measurement diff -r cb7277bac147 -r d1dd9e6ee72c CoreLoop.c --- a/CoreLoop.c Thu Oct 06 16:25:59 2011 +0200 +++ b/CoreLoop.c Fri Dec 16 20:00:21 2011 +0100 @@ -16,7 +16,7 @@ #include #include -void *terminateCoreLoop(VirtProcr *currPr); +void *terminateCoreLoop(VirtProcr *currVP); /*This is the loop that runs in the OS Thread pinned to each core *Get virt procr from queue, @@ -35,10 +35,12 @@ { ThdParams *coreLoopThdParams; int thisCoresIdx; - VirtProcr *currPr; - VMSQueueStruc *readyToAnimateQ; - cpu_set_t coreMask; //has 1 in bit positions of allowed cores + VirtProcr *currVP; + VMSQueueStruc *readyToAnimateQ; + cpu_set_t coreMask; //has 1 in bit positions of allowed cores int errorCode; + TSCountLowHigh endSusp; + uint64 numCycles; //work-stealing struc on stack to prevent false-sharing in cache-line volatile GateStruc gate; @@ -101,16 +103,16 @@ while( gate.gateClosed ) /*busy wait*/; } - currPr = (VirtProcr *) readVMSQ( readyToAnimateQ ); + currVP = (VirtProcr *) readVMSQ( readyToAnimateQ ); //Set the coreloop's progress, so stealer can see it has made it out // of the protected area gate.exitProgress = gate.preGateProgress; #else - currPr = (VirtProcr *) readVMSQ( readyToAnimateQ ); + currVP = (VirtProcr *) readVMSQ( readyToAnimateQ ); #endif - if( currPr != NULL ) _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; + if( currVP != NULL ) _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; else { //============================= MEASUREMENT STUFF ===================== @@ -120,14 +122,14 @@ #endif //===================================================================== int tries = 0; int gotLock = 0; - while( currPr == NULL ) //if queue was empty, enter get masterLock loop + while( currVP == NULL ) //if queue was empty, enter get masterLock loop { //queue was empty, so get master lock gotLock = __sync_bool_compare_and_swap(&(_VMSMasterEnv->masterLock), UNLOCKED, LOCKED ); if( gotLock ) { //run own MasterVP -- jmps to coreLoops startPt when done - currPr = _VMSMasterEnv->masterVPs[thisCoresIdx]; + currVP = _VMSMasterEnv->masterVPs[thisCoresIdx]; if( _VMSMasterEnv->numMasterInARow[thisCoresIdx] > 1000 ) { DEBUG( dbgB2BMaster,"Many back to back MasterVPs\n"); pthread_yield(); @@ -152,17 +154,33 @@ } - switchToVP(currPr); //The VPs return in here + switchToVP(currVP); //enter "Fn" to resume a VP -- comes back at VP suspend flushRegisters(); + //=================== Meas ======================= + //A TSC is stored in VP first thing inside wrapper-lib + //Now, measures cycles from there to here + //Master and Plugin will add this value to other trace-seg measures + #ifdef MEAS__TIME_2011_SYS + saveTSCLowHigh(endSusp); + numCycles = endSusp.longVal - currVP->startSusp.longVal; + //sanity check (400K is about 20K iters) + if( numCycles < 400000 ) + { currVP->totalSuspCycles += numCycles; + currVP->numGoodSusp++; + } + //only used if currVP == MasterVP + _VMSMasterEnv->startMaster.longVal = endSusp.longVal; + #endif + //================================================== }//CoreLoop } void * -terminateCoreLoop(VirtProcr *currPr){ +terminateCoreLoop(VirtProcr *currVP){ //first free shutdown VP that jumped here -- it first restores the - // coreloop's stack, so addr of currPr in stack frame is still correct - VMS__dissipate_procr( currPr ); + // coreloop's stack, so addr of currVP in stack frame is still correct + VMS__dissipate_procr( currVP ); pthread_exit( NULL ); } @@ -177,7 +195,7 @@ void * coreLoop_Seq( void *paramsIn ) { - VirtProcr *currPr; + VirtProcr *currVP; VMSQueueStruc *readyToAnimateQ; ThdParams *coreLoopThdParams; @@ -196,19 +214,19 @@ //_VMSWorkQ must be a global, static volatile var, so not kept in reg, // which forces reloading the pointer after each jmp to this point readyToAnimateQ = _VMSMasterEnv->readyToAnimateQs[thisCoresIdx]; - currPr = (VirtProcr *) readVMSQ( readyToAnimateQ ); - if( currPr == NULL ) + currVP = (VirtProcr *) readVMSQ( readyToAnimateQ ); + if( currVP == NULL ) { if( _VMSMasterEnv->numMasterInARow[thisCoresIdx] > 1000 ) { printf("too many back to back MasterVP\n"); exit(1); } _VMSMasterEnv->numMasterInARow[thisCoresIdx] += 1; - currPr = _VMSMasterEnv->masterVPs[thisCoresIdx]; + currVP = _VMSMasterEnv->masterVPs[thisCoresIdx]; } else _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; - switchToVP( currPr ); + switchToVP( currVP ); flushRegisters(); } } diff -r cb7277bac147 -r d1dd9e6ee72c MasterLoop.c --- a/MasterLoop.c Thu Oct 06 16:25:59 2011 +0200 +++ b/MasterLoop.c Fri Dec 16 20:00:21 2011 +0100 @@ -16,7 +16,7 @@ //=========================================================================== void inline stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *readyToAnimateQ, - VirtProcr *masterPr ); + VirtProcr *masterVP ); //=========================================================================== @@ -84,44 +84,34 @@ void *semanticEnv; int32 thisCoresIdx; - VirtProcr *masterPr; - volatile VirtProcr *volatileMasterPr; + VirtProcr *masterVP; + volatile VirtProcr *volatilemasterVP; - volatileMasterPr = animatingPr; - masterPr = (VirtProcr*)volatileMasterPr; //used to force re-define after jmp - - //First animation of each MasterVP will in turn animate this part - // of setup code.. (VP creator sets up the stack as if this function - // was called normally, but actually get here by jmp) - //So, setup values about stack ptr, jmp pt and all that - //masterPr->nextInstrPt = &&masterLoopStartPt; - - - //Note, got rid of writing the stack and frame ptr up here, because - // only one - // core can ever animate a given MasterVP, so don't need to communicate - // new frame and stack ptr to the MasterVP storage before a second - // version of that MasterVP can get animated on a different core. - //Also got rid of the busy-wait. - + volatilemasterVP = animatingPr; + masterVP = (VirtProcr*)volatilemasterVP; //used to force re-define after jmp + + //====================== Measurement ===================== + TSCountLowHigh endMaster; + uint64 numCycles; + //========================================================== //masterLoopStartPt: - while(1){ + while(1){ //switch to core_loop and back to here is at end of loop - //============================= MEASUREMENT STUFF ======================== - #ifdef MEAS__TIME_MASTER - //Total Master time includes one coreloop time -- just assume the core - // loop time is same for Master as for AppVPs, even though it may be - // smaller due to higher predictability of the fixed jmp. - saveLowTimeStampCountInto( masterPr->startMasterTSCLow ); - #endif - //======================================================================== + //============================= MEASUREMENT STUFF ======================= + #ifdef MEAS__TIME_MASTER + //Total Master time includes one coreloop time -- just assume the core + // loop time is same for Master as for AppVPs, even though it may be + // smaller due to higher predictability of the fixed jmp. + saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); + #endif + //======================================================================= masterEnv = (MasterEnv*)_VMSMasterEnv; //GCC may optimize so doesn't always re-define from frame-storage - masterPr = (VirtProcr*)volatileMasterPr; //just to make sure after jmp - thisCoresIdx = masterPr->coreAnimatedBy; + masterVP = (VirtProcr*)volatilemasterVP; //just to make sure after jmp + thisCoresIdx = masterVP->coreAnimatedBy; readyToAnimateQ = masterEnv->readyToAnimateQs[thisCoresIdx]; schedSlots = masterEnv->allSchedSlots[thisCoresIdx]; @@ -132,6 +122,7 @@ //Poll each slot's Done flag numSlotsFilled = 0; + Meas_startMasterLoop for( slotIdx = 0; slotIdx < NUM_SCHED_SLOTS; slotIdx++) { currSlot = schedSlots[ slotIdx ]; @@ -142,22 +133,9 @@ currSlot->needsProcrAssigned = TRUE; //process requests from slave to master - //====================== MEASUREMENT STUFF =================== - #ifdef MEAS__TIME_PLUGIN - int32 startStamp1, endStamp1; - saveLowTimeStampCountInto( startStamp1 ); - #endif - //============================================================ + Meas_startReqHdlr (*requestHandler)( currSlot->procrAssignedToSlot, semanticEnv ); - //====================== MEASUREMENT STUFF =================== - #ifdef MEAS__TIME_PLUGIN - saveLowTimeStampCountInto( endStamp1 ); - addIntervalToHist( startStamp1, endStamp1, - _VMSMasterEnv->reqHdlrLowTimeHist ); - addIntervalToHist( startStamp1, endStamp1, - _VMSMasterEnv->reqHdlrHighTimeHist ); - #endif - //============================================================ + Meas_endReqHdlr } if( currSlot->needsProcrAssigned ) { //give slot a new virt procr @@ -174,25 +152,36 @@ } } } - + Meas_endMasterLoop #ifdef USE_WORK_STEALING //If no slots filled, means no more work, look for work to steal. if( numSlotsFilled == 0 ) - { gateProtected_stealWorkInto( currSlot, readyToAnimateQ, masterPr ); + { gateProtected_stealWorkInto( currSlot, readyToAnimateQ, masterVP ); } #endif - #ifdef MEAS__TIME_MASTER - saveLowTimeStampCountInto( masterPr->endMasterTSCLow ); - #endif - masterSwitchToCoreLoop(animatingPr); + //=================== Meas ======================= + #ifdef MEAS__TIME_MASTER + saveLowTimeStampCountInto( masterVP->endMasterTSCLow ); + #endif + #ifdef MEAS__TIME_2011_SYS + //Take meas here, to get cycles since entered Master + saveTSCLowHigh(endMaster); + numCycles = endMaster.longVal - _VMSMasterEnv->startMaster.longVal; + + if( numCycles < 200000 ) //sanity check against swap thd out) + { masterEnv->totalMasterCycles += numCycles; + masterEnv->numMasterAnimations++; + } + #endif + //================================================== + masterSwitchToCoreLoop(animatingPr); //"finishes" when switch back to Master flushRegisters(); }//MasterLoop - } @@ -202,14 +191,14 @@ */ void inline stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *readyToAnimateQ, - VirtProcr *masterPr ) + VirtProcr *masterVP ) { VirtProcr *stolenPr; int32 coreIdx, i; VMSQueueStruc *currQ; stolenPr = NULL; - coreIdx = masterPr->coreAnimatedBy; + coreIdx = masterVP->coreAnimatedBy; for( i = 0; i < NUM_CORES -1; i++ ) { if( coreIdx >= NUM_CORES -1 ) @@ -306,7 +295,7 @@ void inline gateProtected_stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *myReadyToAnimateQ, - VirtProcr *masterPr ) + VirtProcr *masterVP ) { VirtProcr *stolenPr; int32 coreIdx, i, haveAVictim, gotLock; @@ -319,7 +308,7 @@ //see if any other cores have work available to steal haveAVictim = FALSE; - coreIdx = masterPr->coreAnimatedBy; + coreIdx = masterVP->coreAnimatedBy; for( i = 0; i < NUM_CORES -1; i++ ) { if( coreIdx >= NUM_CORES -1 ) diff -r cb7277bac147 -r d1dd9e6ee72c ProcrContext.h --- a/ProcrContext.h Thu Oct 06 16:25:59 2011 +0200 +++ b/ProcrContext.h Fri Dec 16 20:00:21 2011 +0100 @@ -20,7 +20,7 @@ void startVirtProcrFn(); -void *asmTerminateCoreLoop(VirtProcr *currPr); +void *asmTerminateCoreLoop(VirtProcr *currVP); #define flushRegisters() \ asm volatile ("":::"%rbx", "%r12", "%r13","%r14","%r15") diff -r cb7277bac147 -r d1dd9e6ee72c VMS.c --- a/VMS.c Thu Oct 06 16:25:59 2011 +0200 +++ b/VMS.c Fri Dec 16 20:00:21 2011 +0100 @@ -100,7 +100,8 @@ //Make the master env, which holds everything else - _VMSMasterEnv = malloc( sizeof(MasterEnv) ); + _VMSMasterEnv = malloc( sizeof(MasterEnv) ); + memset( _VMSMasterEnv, 0, sizeof(MasterEnv) ); //Very first thing put into the master env is the free-list, seeded // with a massive initial chunk of memory. @@ -681,6 +682,7 @@ //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&printHist ); //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&saveHistToFile); //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, &freeHistExt ); +/* #ifdef MEAS__TIME_PLUGIN printHist( _VMSMasterEnv->reqHdlrLowTimeHist ); saveHistToFile( _VMSMasterEnv->reqHdlrLowTimeHist ); @@ -712,6 +714,7 @@ freeSchedSlots( allSchedSlots[ coreIdx ] ); } #endif + */ #ifdef MEAS__TIME_STAMP_SUSP printHist( _VMSMasterEnv->pluginTimeHist ); for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) @@ -770,3 +773,15 @@ exit(1); } +//======================= Measurement ======================= +#ifdef MEAS__TIME_2011_SYS +uint64 +VMS__give_num_plugin_cycles() + { return _VMSMasterEnv->totalPluginCycles; + } + +uint32 +VMS__give_num_plugin_animations() + { return _VMSMasterEnv->numPluginAnimations; + } +#endif diff -r cb7277bac147 -r d1dd9e6ee72c VMS.h --- a/VMS.h Thu Oct 06 16:25:59 2011 +0200 +++ b/VMS.h Fri Dec 16 20:00:21 2011 +0100 @@ -20,96 +20,19 @@ #include #include - -//=============================== Debug =================================== +//============= #defines =========== // -//When SEQUENTIAL is defined, VMS does sequential exe in the main thread -// It still does co-routines and all the mechanisms are the same, it just -// has only a single thread and animates VPs one at a time -//#define SEQUENTIAL - -//#define USE_WORK_STEALING - -//turns on the probe-instrumentation in the application -- when not -// defined, the calls to the probe functions turn into comments -#define STATS__ENABLE_PROBES -//#define TURN_ON_DEBUG_PROBES - -//These defines turn types of bug messages on and off -// be sure debug messages are un-commented (next block of defines) -#define dbgAppFlow TRUE /* Top level flow of application code -- general*/ -#define dbgProbes FALSE /* for issues inside probes themselves*/ -#define dbgB2BMaster FALSE /* in coreloop, back to back master VPs*/ -#define dbgRqstHdlr FALSE /* in request handler code*/ - -//Comment or un- the substitute half to turn on/off types of debug message -#define DEBUG( bool, msg) \ -// if( bool){ printf(msg); fflush(stdin);} -#define DEBUG1( bool, msg, param) \ -// if(bool){printf(msg, param); fflush(stdin);} -#define DEBUG2( bool, msg, p1, p2) \ -// if(bool) {printf(msg, p1, p2); fflush(stdin);} - -#define ERROR(msg) printf(msg); -#define ERROR1(msg, param) printf(msg, param); -#define ERROR2(msg, p1, p2) printf(msg, p1, p2); - -//=========================== STATS ======================= - - //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and - // compiled-in that saves the low part of the time stamp count just before - // suspending a processor and just after resuming that processorsrc/VPThread_lib/VMS/VMS.h:322: warning: previous declaration of ‘VMS__create_procr’ was here. It is - // saved into a field added to VirtProcr. Have to sanity-check for - // rollover of low portion into high portion. -//#define MEAS__TIME_STAMP_SUSP -//#define MEAS__TIME_MASTER -#define MEAS__TIME_PLUGIN -#define MEAS__TIME_MALLOC -//#define MEAS__TIME_MASTER_LOCK -#define MEAS__NUM_TIMES_TO_RUN 100000 - - //For code that calculates normalization-offset between TSC counts of - // different cores. -#define NUM_TSC_ROUND_TRIPS 10 - - -//========================= Hardware related Constants ===================== - //This value is the number of hardware threads in the shared memory - // machine -//#define NUM_CORES 8 - - // tradeoff amortizing master fixed overhead vs imbalance potential - // when work-stealing, can make bigger, at risk of losing cache affinity -#define NUM_SCHED_SLOTS 5 - -#define MIN_WORK_UNIT_CYCLES 20000 - -#define MASTERLOCK_RETRIES 10000 - - // stack size in virtual processors created -#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ - - // memory for VMS__malloc -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */ - -#define CACHE_LINE 64 -#define PAGE_SIZE 4096 - - -//============================== - -#define SUCCESS 0 - -#define writeVMSQ writePrivQ -#define readVMSQ readPrivQ -#define makeVMSQ makeVMSPrivQ -#define numInVMSQ numInPrivQ -#define VMSQueueStruc PrivQueueStruc +#include "VMS_defs.h" //=========================================================================== typedef unsigned long long TSCount; +typedef union + { uint32 lowHigh[2]; + uint64 longVal; + } +TSCountLowHigh; typedef struct _SchedSlot SchedSlot; typedef struct _VMSReqst VMSReqst; @@ -194,14 +117,19 @@ void *dataRetFromReq;//values returned from plugin to VP go here //=========== MEASUREMENT STUFF ========== - #ifdef MEAS__TIME_STAMP_SUSP - unsigned int preSuspTSCLow; - unsigned int postSuspTSCLow; - #endif - #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/ - unsigned int startMasterTSCLow;USE_GNU - unsigned int endMasterTSCLow; - #endif + #ifdef MEAS__TIME_STAMP_SUSP + uint32 preSuspTSCLow; + uint32 postSuspTSCLow; + #endif + #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/ + uint32 startMasterTSCLow;USE_GNU + uint32 endMasterTSCLow; + #endif + #ifdef MEAS__TIME_2011_SYS + TSCountLowHigh startSusp; + uint64 totalSuspCycles; + uint32 numGoodSusp; + #endif //======================================== float64 createPtInSecs; //have space but don't use on some configs @@ -239,25 +167,36 @@ int32 numProcrsCreated; //gives ordering to processor creation //=========== MEASUREMENT STUFF ============= - IntervalProbe **intervalProbes; - PrivDynArrayInfo *dynIntervalProbesInfo; - HashTable *probeNameHashTbl; - int32 masterCreateProbeID; - float64 createPtInSecs; - Histogram **measHists; - PrivDynArrayInfo *measHistsInfo; - #ifdef MEAS__TIME_PLUGIN - Histogram *reqHdlrLowTimeHist; - Histogram *reqHdlrHighTimeHist; - #endif - #ifdef MEAS__TIME_MALLOC - Histogram *mallocTimeHist; - Histogram *freeTimeHist; - #endif - #ifdef MEAS__TIME_MASTER_LOCK - Histogram *masterLockLowTimeHist; - Histogram *masterLockHighTimeHist; - #endif + IntervalProbe **intervalProbes; + PrivDynArrayInfo *dynIntervalProbesInfo; + HashTable *probeNameHashTbl; + int32 masterCreateProbeID; + float64 createPtInSecs; + Histogram **measHists; + PrivDynArrayInfo *measHistsInfo; + #ifdef MEAS__TIME_PLUGIN + Histogram *reqHdlrLowTimeHist; + Histogram *reqHdlrHighTimeHist; + #endif + #ifdef MEAS__TIME_MALLOC + Histogram *mallocTimeHist; + Histogram *freeTimeHist; + #endif + #ifdef MEAS__TIME_MASTER_LOCK + Histogram *masterLockLowTimeHist; + Histogram *masterLockHighTimeHist; + #endif + #ifdef MEAS__TIME_2011_SYS + TSCountLowHigh startMaster; + uint64 totalMasterCycles; + uint32 numMasterAnimations; + TSCountLowHigh startReqHdlr; + uint64 totalPluginCycles; + uint32 numPluginAnimations; + uint64 cyclesTillStartMasterLoop; + TSCountLowHigh endMasterLoop; + #endif + //========================================== } MasterEnv; @@ -281,7 +220,7 @@ void * coreLoop( void *paramsIn ); //standard PThreads fn prototype void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype -void masterLoop( void *initData, VirtProcr *masterPr ); +void masterLoop( void *initData, VirtProcr *masterVP ); typedef struct @@ -378,202 +317,17 @@ VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv, ResumePrFnPtr resumePrFnPtr ); -//======================== STATS ====================== +//======================== MEASUREMENT ====================== +uint64 +VMS__give_num_plugin_cycles(); +uint32 +VMS__give_num_plugin_animations(); -//===== RDTSC wrapper ===== //Also runs with x86_64 code -#define saveTimeStampCountInto(low, high) \ - asm volatile("RDTSC; \ - movl %%eax, %0; \ - movl %%edx, %1;" \ - /* outputs */ : "=m" (low), "=m" (high)\ - /* inputs */ : \ - /* clobber */ : "%eax", "%edx" \ - ); - -#define saveLowTimeStampCountInto(low) \ - asm volatile("RDTSC; \ - movl %%eax, %0;" \ - /* outputs */ : "=m" (low) \ - /* inputs */ : \ - /* clobber */ : "%eax", "%edx" \ - ); - -//==================== -#define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ - makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \ - _VMSMasterEnv->measHists[idx] = \ - makeFixedBinHist( numBins, startVal, binWidth, name ); - - -#define MEAS__SUB_CREATE /*turn on/off subtraction of create from plugin*/ - -#ifdef VPTHREAD - -//VPThread -#define createHistIdx 1 -#define mutexLockHistIdx 2 -#define mutexUnlockHistIdx 3 -#define condWaitHistIdx 4 -#define condSignalHistIdx 5 - -#define MakeTheMeasHists() \ - _VMSMasterEnv->measHistsInfo = \ - makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ - makeAMeasHist( createHistIdx, "create", 250, 0, 100 ) \ - makeAMeasHist( mutexLockHistIdx, "mutex_lock", 50, 0, 100 ) \ - makeAMeasHist( mutexUnlockHistIdx, "mutex_unlock", 50, 0, 100 ) \ - makeAMeasHist( condWaitHistIdx, "cond_wait", 50, 0, 100 ) \ - makeAMeasHist( condSignalHistIdx, "cond_signal", 50, 0, 100 ) - -#endif - - -#ifdef VCILK - -//VCilk -#define spawnHistIdx 1 -#define syncHistIdx 2 - -#define MakeTheMeasHists() \ - _VMSMasterEnv->measHistsInfo = \ - makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ - makeAMeasHist( spawnHistIdx, "Spawn", 50, 0, 200 ) \ - makeAMeasHist( syncHistIdx, "Sync", 50, 0, 200 ) - - -#endif - -#ifdef SSR - -//SSR -#define SendFromToHistIdx 1 -#define SendOfTypeHistIdx 2 -#define ReceiveFromToHistIdx 3 -#define ReceiveOfTypeHistIdx 4 - -#define MakeTheMeasHists() \ - _VMSMasterEnv->measHistsInfo = \ - makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ - makeAMeasHist( SendFromToHistIdx, "SendFromTo", 50, 0, 100 ) \ - makeAMeasHist( SendOfTypeHistIdx, "SendOfType", 50, 0, 100 ) \ - makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \ - makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 ) - -#endif - -//=========================================================================== -//VPThread - - -#define Meas_startCreate \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endCreate \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ createHistIdx ] ); - -#define Meas_startMutexLock \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endMutexLock \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ mutexLockHistIdx ] ); - -#define Meas_startMutexUnlock \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endMutexUnlock \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ mutexUnlockHistIdx ] ); - -#define Meas_startCondWait \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endCondWait \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ condWaitHistIdx ] ); - -#define Meas_startCondSignal \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endCondSignal \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ condSignalHistIdx ] ); - -//=========================================================================== -// VCilk -#define Meas_startSpawn \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endSpawn \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ spawnHistIdx ] ); - -#define Meas_startSync \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endSync \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ syncHistIdx ] ); - -//=========================================================================== -// SSR -#define Meas_startSendFromTo \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endSendFromTo \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ SendFromToHistIdx ] ); - -#define Meas_startSendOfType \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endSendOfType \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ SendOfTypeHistIdx ] ); - -#define Meas_startReceiveFromTo \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endReceiveFromTo \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ ReceiveFromToHistIdx ] ); - -#define Meas_startReceiveOfType \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endReceiveOfType \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); - -//===== #include "ProcrContext.h" #include "probes.h" #include "vutilities.h" - +#include "../VMS_lang_specific_defines.h" #endif /* _VMS_H */ diff -r cb7277bac147 -r d1dd9e6ee72c VMS_defs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VMS_defs.h Fri Dec 16 20:00:21 2011 +0100 @@ -0,0 +1,291 @@ +/* + * Copyright 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _VMS_DEFS_H +#define _VMS_DEFS_H +#define _GNU_SOURCE + + +//=============================== Debug =================================== +// +//When SEQUENTIAL is defined, VMS does sequential exe in the main thread +// It still does co-routines and all the mechanisms are the same, it just +// has only a single thread and animates VPs one at a time +//#define SEQUENTIAL + +//#define USE_WORK_STEALING + +//turns on the probe-instrumentation in the application -- when not +// defined, the calls to the probe functions turn into comments +#define STATS__ENABLE_PROBES +//#define TURN_ON_DEBUG_PROBES + +//These defines turn types of bug messages on and off +// be sure debug messages are un-commented (next block of defines) +#define dbgAppFlow TRUE /* Top level flow of application code -- general*/ +#define dbgProbes FALSE /* for issues inside probes themselves*/ +#define dbgB2BMaster FALSE /* in coreloop, back to back master VPs*/ +#define dbgRqstHdlr FALSE /* in request handler code*/ + +//Comment or un- the substitute half to turn on/off types of debug message +#define DEBUG( bool, msg) \ +// if( bool){ printf(msg); fflush(stdin);} +#define DEBUG1( bool, msg, param) \ +// if(bool){printf(msg, param); fflush(stdin);} +#define DEBUG2( bool, msg, p1, p2) \ +// if(bool) {printf(msg, p1, p2); fflush(stdin);} + +#define ERROR(msg) printf(msg); +#define ERROR1(msg, param) printf(msg, param); +#define ERROR2(msg, p1, p2) printf(msg, p1, p2); + +//=========================== MEASUREMENT ======================= + +#define MEAS__TIME_2011_SYS +//define this if any MEAS__... below are +//#define MAKE_HISTS_FOR_MEASUREMENTS + //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and + // compiled-in that saves the low part of the time stamp count just before + // suspending a processor and just after resuming that processor. It is + // saved into a field added to VirtProcr. Have to sanity-check for + // rollover of low portion into high portion. +//#define MEAS__TIME_STAMP_SUSP +//#define MEAS__TIME_MASTER +//#define MEAS__TIME_PLUGIN +//#define MEAS__TIME_MALLOC +//#define MEAS__TIME_MASTER_LOCK + + //For code that calculates normalization-offset between TSC counts of + // different cores. +//#define NUM_TSC_ROUND_TRIPS 10 + + +//========================= Hardware related Constants ===================== + //This value is the number of hardware threads in the shared memory + // machine +//#define NUM_CORES 8 + + // tradeoff amortizing master fixed overhead vs imbalance potential + // when work-stealing, can make bigger, at risk of losing cache affinity +#define NUM_SCHED_SLOTS 5 + +#define MIN_WORK_UNIT_CYCLES 20000 + +#define MASTERLOCK_RETRIES 10000 + + // stack size in virtual processors created +#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ + + // memory for VMS__malloc +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */ + +#define CACHE_LINE 64 +#define PAGE_SIZE 4096 + + +//============================== + +#define SUCCESS 0 + +#define writeVMSQ writePrivQ +#define readVMSQ readPrivQ +#define makeVMSQ makeVMSPrivQ +#define numInVMSQ numInPrivQ +#define VMSQueueStruc PrivQueueStruc + + +//============================ MEASUREMENT ========================== +// +//===== RDTSC wrapper ===== //Also runs with x86_64 code +#define saveTSCLowHigh(lowHighIn) \ + asm volatile("RDTSC; \ + movl %%eax, %0; \ + movl %%edx, %1;" \ + /* outputs */ : "=m" (lowHighIn.lowHigh[0]), "=m" (lowHighIn.lowHigh[1])\ + /* inputs */ : \ + /* clobber */ : "%eax", "%edx" \ + ); + +#define saveTimeStampCountInto(low, high) \ + asm volatile("RDTSC; \ + movl %%eax, %0; \ + movl %%edx, %1;" \ + /* outputs */ : "=m" (low), "=m" (high)\ + /* inputs */ : \ + /* clobber */ : "%eax", "%edx" \ + ); + +#define saveLowTimeStampCountInto(low) \ + asm volatile("RDTSC; \ + movl %%eax, %0;" \ + /* outputs */ : "=m" (low) \ + /* inputs */ : \ + /* clobber */ : "%eax", "%edx" \ + ); +//===== +#ifdef MEAS__TIME_PLUGIN + +#define Meas_startReqHdlr \ + int32 startStamp1, endStamp1; \ + saveLowTimeStampCountInto( startStamp1 ); + +#define Meas_endReqHdlr \ + saveLowTimeStampCountInto( endStamp1 ); \ + addIntervalToHist( startStamp1, endStamp1, \ + _VMSMasterEnv->reqHdlrLowTimeHist ); \ + addIntervalToHist( startStamp1, endStamp1, \ + _VMSMasterEnv->reqHdlrHighTimeHist ); + +#elif defined MEAS__TIME_2011_SYS +#define Meas_startMasterLoop \ + TSCountLowHigh startStamp1, endStamp1; \ + saveTSCLowHigh( endStamp1 ); \ + _VMSMasterEnv->cyclesTillStartMasterLoop = \ + endStamp1.longVal - masterVP->startSusp.longVal; + +#define Meas_startReqHdlr \ + saveTSCLowHigh( startStamp1 ); \ + _VMSMasterEnv->startReqHdlr.longVal = startStamp1.longVal; + +#define Meas_endReqHdlr + +#define Meas_endMasterLoop \ + saveTSCLowHigh( startStamp1 ); \ + _VMSMasterEnv->endMasterLoop.longVal = startStamp1.longVal; + +#else +#define Meas_startMasterLoop +#define Meas_startReqHdlr +#define Meas_endReqHdlr +#define Meas_endMasterLoop +#endif + +//============== Histogram stuff -- used in measurements ========== +// +// +#ifdef MAKE_HISTS_FOR_MEASUREMENTS +#define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ + makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \ + _VMSMasterEnv->measHists[idx] = \ + makeFixedBinHist( numBins, startVal, binWidth, name ); +#else +#define makeAMeasHist( idx, name, numBins, startVal, binWidth ) +#endif + + +#define MEAS__SUB_CREATE /*turn on/off subtraction of create from plugin*/ + + +//==================== Language-specific Measurement Stuff =================== +// +// MOVE THESE into ../VMS_lang_specific_defines.h +// +// + + +//TODO: Move these to ../VMS_language_specific_defines for that language +// and wrap them in #ifdef MEAS__... the way have for Vthread + +#ifdef VCILK + +//VCilk +#define spawnHistIdx 1 +#define syncHistIdx 2 + +#define MakeTheMeasHists() \ + _VMSMasterEnv->measHistsInfo = \ + makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ + makeAMeasHist( spawnHistIdx, "Spawn", 50, 0, 200 ) \ + makeAMeasHist( syncHistIdx, "Sync", 50, 0, 200 ) + + +#endif + +#ifdef SSR + +//SSR +#define SendFromToHistIdx 1 +#define SendOfTypeHistIdx 2 +#define ReceiveFromToHistIdx 3 +#define ReceiveOfTypeHistIdx 4 + +#define MakeTheMeasHists() \ + _VMSMasterEnv->measHistsInfo = \ + makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ + makeAMeasHist( SendFromToHistIdx, "SendFromTo", 50, 0, 100 ) \ + makeAMeasHist( SendOfTypeHistIdx, "SendOfType", 50, 0, 100 ) \ + makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \ + makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 ) + +#endif + +//=========================================================================== +//VPThread + +// already moved + +//=========================================================================== +// VCilk +#define Meas_startSpawn \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); \ + +#define Meas_endSpawn \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp, \ + _VMSMasterEnv->measHists[ spawnHistIdx ] ); + +#define Meas_startSync \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); \ + +#define Meas_endSync \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp, \ + _VMSMasterEnv->measHists[ syncHistIdx ] ); + +//=========================================================================== +// SSR +#define Meas_startSendFromTo \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); \ + +#define Meas_endSendFromTo \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp, \ + _VMSMasterEnv->measHists[ SendFromToHistIdx ] ); + +#define Meas_startSendOfType \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); \ + +#define Meas_endSendOfType \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp, \ + _VMSMasterEnv->measHists[ SendOfTypeHistIdx ] ); + +#define Meas_startReceiveFromTo \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); \ + +#define Meas_endReceiveFromTo \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp, \ + _VMSMasterEnv->measHists[ ReceiveFromToHistIdx ] ); + +#define Meas_startReceiveOfType \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); \ + +#define Meas_endReceiveOfType \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp, \ + _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); + +#endif /* _VMS_DEFS_H */ +