# HG changeset patch # User Some Random Person # Date 1331189630 28800 # Node ID a18539c0bc37cf9d4a1f12b60b1272f67e79e3e1 # Parent 0c83ea8adefce64c0b749801f9066ae4f837bc8c Moved defines and probes into own directories diff -r 0c83ea8adefc -r a18539c0bc37 CoreLoop.c --- a/CoreLoop.c Sun Mar 04 14:26:35 2012 -0800 +++ b/CoreLoop.c Wed Mar 07 22:53:50 2012 -0800 @@ -32,11 +32,11 @@ coreLoop( void *paramsIn ) { ThdParams *coreLoopThdParams; - int thisCoresIdx; - SlaveVP *currSlv; - VMSQueueStruc *readyToAnimateQ; + int32 thisCoresIdx, currSlotIdx; + SlaveVP *currVP; + SchedSlot *currSlot, **schedSlots; cpu_set_t coreMask; //has 1 in bit positions of allowed cores - int errorCode; + int32 errorCode; //work-stealing struc on stack to prevent false-sharing in cache-line volatile GateStruc gate; @@ -77,52 +77,41 @@ if(errorCode){ printf("\nset affinity failure\n"); exit(0); } - //Save the return address in the SwitchSlv function - saveCoreLoopReturnAddr((void**)&(_VMSMasterEnv->coreLoopReturnPt)); + //Save return addr from stack into master-env for use later + recordCoreLoopReturnLabelAddr((void**)&(_VMSMasterEnv->coreLoopReturnPt)); + currSlotIdx = 0; //start at slot 0, go up until one empty, then do master while(1){ - //Get virtual processor from queue - //The Q 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]; + schedSlots = _VMSMasterEnv->allSchedSlots[thisCoresIdx]; - #ifdef USE_WORK_STEALING - //Alg for work-stealing designed to make common case fast. Comment - // in stealer code explains. - gate.preGateProgress++; - if( gate.gateClosed ) - { //now, set coreloop's progress, so stealer can see that core loop - // has made it into the waiting area. - gate.waitProgress = gate.preGateProgress; - while( gate.gateClosed ) /*busy wait*/; + if( currSlotIdx >= NUM_SCHED_SLOTS ) goto switchToMaster; + + currSlot = schedSlots[ currSlotIdx ]; + + if( ! currSlot->needsSlaveAssigned ) //slot does have slave assigned + { _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; //reset B2B master count + currSlotIdx ++; + currVP = currSlot->slaveAssignedToSlot; } - - currSlv = (SlaveVP *) 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 - currSlv = (SlaveVP *) readVMSQ( readyToAnimateQ ); - #endif - - if( currSlv != NULL ) _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; - else + else //slot is empty, so switch to master { + switchToMaster: + currSlotIdx = 0; //switch to master, so start over at slot 0 + currVP = NULL; + MEAS__Capture_Pre_Master_Lock_Point; int tries = 0; int gotLock = 0; - while( currSlv == NULL ) //if queue was empty, enter get masterLock loop - { //queue was empty, so get master lock - + while( currVP == NULL ) //keep going until get master lock + { gotLock = __sync_bool_compare_and_swap(&(_VMSMasterEnv->masterLock), UNLOCKED, LOCKED ); if( gotLock ) { //run own MasterVP -- jmps to coreLoops startPt when done - currSlv = _VMSMasterEnv->masterVPs[thisCoresIdx]; - if( _VMSMasterEnv->numMasterInARow[thisCoresIdx] > 1000 ) + currVP = _VMSMasterEnv->masterVPs[thisCoresIdx]; + if( _VMSMasterEnv->numMasterInARow[thisCoresIdx] > 10 ) { DEBUG( dbgB2BMaster,"Many back to back MasterVPs\n"); pthread_yield(); } @@ -130,14 +119,14 @@ break; //end while -- have a Slv to animate now } - tries++; //if too many, means master on other core taking too long + tries++; //if too many, means master on other core taking too long if( tries > MASTERLOCK_RETRIES ) { tries = 0; pthread_yield(); } } MEAS__Capture_Post_Master_Lock_Point; } - switchToSlv(currSlv); //The Slvs return in here + switchToSlv(currVP); //Slave suspend makes core "return" from this call flushRegisters(); }//CoreLoop } @@ -147,13 +136,13 @@ terminateCoreLoop(SlaveVP *currSlv){ //first free shutdown Slv that jumped here -- it first restores the // coreloop's stack, so addr of currSlv in stack frame is still correct - VMS_int__dissipate_SlaveVP( currSlv ); + VMS_int__dissipate_slaveVP( currSlv ); pthread_exit( NULL ); } -#ifdef SEQUENTIAL +#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE //=========================================================================== /*This sequential version is exact same as threaded, except doesn't do the @@ -173,7 +162,7 @@ thisCoresIdx = 0; //Save the return address in the SwitchSlv function - saveCoreLoopReturnAddr(&(_VMSMasterEnv->coreLoopReturnPt)); + recordCoreLoopReturnLabelAddr(&(_VMSMasterEnv->coreLoopReturnPt)); while(1){ diff -r 0c83ea8adefc -r a18539c0bc37 Defines/VMS_defs__DEBUG.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Defines/VMS_defs__DEBUG.h Wed Mar 07 22:53:50 2012 -0800 @@ -0,0 +1,35 @@ +/* + * Copyright 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _VMS_DEFS_DEBUG_H +#define _VMS_DEFS_DEBUG_H +#define _GNU_SOURCE + +/* + */ +#ifdef DEBUG__TURN_ON_DEBUG_MSGS + #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);} +#else + #define DEBUG( bool, msg) + #define DEBUG1( bool, msg, param) + #define DEBUG2( bool, msg, p1, p2) +#endif + +//============================= ERROR MSGs ============================ +#define ERROR(msg) printf(msg); +#define ERROR1(msg, param) printf(msg, param); +#define ERROR2(msg, p1, p2) printf(msg, p1, p2); + +//=========================================================================== +#endif /* _VMS_DEFS_H */ + diff -r 0c83ea8adefc -r a18539c0bc37 Defines/VMS_defs__HW_constants.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Defines/VMS_defs__HW_constants.h Wed Mar 07 22:53:50 2012 -0800 @@ -0,0 +1,51 @@ +/* + * Copyright 2012 OpenSourceStewardshipFoundation + * Licensed under BSD + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _VMS_HW_SPEC_DEFS_H +#define _VMS_HW_SPEC_DEFS_H +#define _GNU_SOURCE + + +//========================= Hardware related Constants ===================== + //This value is the number of hardware threads in the shared memory + // machine +#define NUM_CORES 4 + + // tradeoff amortizing master fixed overhead vs imbalance potential + // when work-stealing, can make bigger, at risk of losing cache affinity +#define NUM_SCHED_SLOTS 3 + +#define MIN_WORK_UNIT_CYCLES 20000 + +#define MASTERLOCK_RETRIES 100 + + // stack size in virtual processors created +#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ + + // memory for VMS_WL__malloc +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x40000000 /* 1G */ + + //Frequency of TS counts -- have to do tests to verify + //NOTE: turn off (in BIOS) TURBO-BOOST and SPEED-STEP else won't be const +#define TSCOUNT_FREQ 3180000000 + +#define CACHE_LINE_SZ 256 +#define PAGE_SIZE 4096 + +//To prevent false-sharing, aligns a variable to a cache-line boundary. +//No need to use for local vars because those are never shared between cores +#define __align_to_cacheline__ __attribute__ ((aligned(CACHE_LINE_SZ))) + +//aligns a pointer to cacheline. The memory area has to contain at least +//CACHE_LINE_SZ bytes more then needed +#define __align_address(ptr) ((void*)(((uintptr_t)(ptr))&((uintptr_t)(~0x0FF)))) + +//=========================================================================== + +#endif /* _VMS_DEFS_H */ + diff -r 0c83ea8adefc -r a18539c0bc37 Defines/VMS_defs__MEAS.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Defines/VMS_defs__MEAS.h Wed Mar 07 22:53:50 2012 -0800 @@ -0,0 +1,318 @@ +/* + * Copyright 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _VMS_DEFS_MEAS_H +#define _VMS_DEFS_MEAS_H +#define _GNU_SOURCE + +//================== Macros define types of meas want ===================== +// +/*Generic measurement macro -- has name-space collision potential, which + * compiler will catch.. so only use one pair inside a given set of + * curly braces. + */ +//TODO: finish generic capture interval in hist +enum histograms + { generic1 + }; + #define MEAS__Capture_Pre_Point \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); + + #define MEAS__Capture_Post_Point( histName ) \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->histName ); + + + + +//================== Macros define types of meas want ===================== + +#ifdef MEAS__TURN_ON_SUSP_MEAS + #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ + uint32 preSuspTSCLow; \ + uint32 postSuspTSCLow; + + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ + Histogram *suspLowTimeHist; \ + Histogram *suspHighTimeHist; + + #define MEAS__Make_Meas_Hists_for_Susp_Meas \ + _VMSMasterEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "master_low_time_hist");\ + _VMSMasterEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "master_high_time_hist"); + + //record time stamp: compare to time-stamp recorded below + #define MEAS__Capture_Pre_Susp_Point \ + saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); + + //NOTE: only take low part of count -- do sanity check when take diff + #define MEAS__Capture_Post_Susp_Point \ + saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ + _VMSMasterEnv->suspLowTimeHist ); \ + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ + _VMSMasterEnv->suspHighTimeHist ); + + #define MEAS__Print_Hists_for_Susp_Meas \ + printHist( _VMSMasterEnv->pluginTimeHist ); + +#else + #define MEAS__Insert_Susp_Meas_Fields_into_Slave + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_Susp_Meas + #define MEAS__Capture_Pre_Susp_Point + #define MEAS__Capture_Post_Susp_Point + #define MEAS__Print_Hists_for_Susp_Meas +#endif + +#ifdef MEAS__TURN_ON_MASTER_MEAS + #define MEAS__Insert_Master_Meas_Fields_into_Slave \ + uint32 startMasterTSCLow; \ + uint32 endMasterTSCLow; + + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ + Histogram *masterLowTimeHist; \ + Histogram *masterHighTimeHist; + + #define MEAS__Make_Meas_Hists_for_Master_Meas \ + _VMSMasterEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "master_low_time_hist");\ + _VMSMasterEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "master_high_time_hist"); + + //Total Master time includes one coreloop time -- just assume the core + // loop time is same for Master as for AppSlvs, even though it may be + // smaller due to higher predictability of the fixed jmp. + #define MEAS__Capture_Pre_Master_Point\ + saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); + + #define MEAS__Capture_Post_Master_Point \ + saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ + _VMSMasterEnv->masterLowTimeHist ); \ + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ + _VMSMasterEnv->masterHighTimeHist ); + + #define MEAS__Print_Hists_for_Master_Meas \ + printHist( _VMSMasterEnv->pluginTimeHist ); + +#else + #define MEAS__Insert_Master_Meas_Fields_into_Slave + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_Master_Meas + #define MEAS__Capture_Pre_Master_Point + #define MEAS__Capture_Post_Master_Point + #define MEAS__Print_Hists_for_Master_Meas +#endif + + +#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ + Histogram *masterLockLowTimeHist; \ + Histogram *masterLockHighTimeHist; + + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ + _VMSMasterEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ + "master lock low time hist");\ + _VMSMasterEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ + "master lock high time hist"); + + #define MEAS__Capture_Pre_Master_Lock_Point \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); + + #define MEAS__Capture_Post_Master_Lock_Point \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp,\ + _VMSMasterEnv->masterLockLowTimeHist ); \ + addIntervalToHist( startStamp, endStamp,\ + _VMSMasterEnv->masterLockHighTimeHist ); + + #define MEAS__Print_Hists_for_Master_Lock_Meas \ + printHist( _VMSMasterEnv->masterLockLowTimeHist ); \ + printHist( _VMSMasterEnv->masterLockHighTimeHist ); + +#else + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas + #define MEAS__Capture_Pre_Master_Lock_Point + #define MEAS__Capture_Post_Master_Lock_Point + #define MEAS__Print_Hists_for_Master_Lock_Meas +#endif + + +#ifdef MEAS__TURN_ON_MALLOC_MEAS + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ + Histogram *mallocTimeHist; \ + Histogram *freeTimeHist; + + #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ + _VMSMasterEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ + "malloc_time_hist");\ + _VMSMasterEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ + "free_time_hist"); + + #define MEAS__Capture_Pre_Malloc_Point \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); + + #define MEAS__Capture_Post_Malloc_Point \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp,\ + _VMSMasterEnv->mallocTimeHist ); + + #define MEAS__Capture_Pre_Free_Point \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); + + #define MEAS__Capture_Post_Free_Point \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp,\ + _VMSMasterEnv->freeTimeHist ); + + #define MEAS__Print_Hists_for_Malloc_Meas \ + printHist( _VMSMasterEnv->mallocTimeHist ); \ + saveHistToFile( _VMSMasterEnv->mallocTimeHist ); \ + printHist( _VMSMasterEnv->freeTimeHist ); \ + saveHistToFile( _VMSMasterEnv->freeTimeHist ); \ + freeHistExt( _VMSMasterEnv->mallocTimeHist ); \ + freeHistExt( _VMSMasterEnv->freeTimeHist ); + +#else + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_Malloc_Meas + #define MEAS__Capture_Pre_Malloc_Point + #define MEAS__Capture_Post_Malloc_Point + #define MEAS__Capture_Pre_Free_Point + #define MEAS__Capture_Post_Free_Point + #define MEAS__Print_Hists_for_Malloc_Meas +#endif + + +#ifdef MEAS__TURN_ON_SYSTEM_MEAS + #define MEAS__Insert_System_Meas_Fields_into_Slave \ + TSCountLowHigh startSusp; \ + uint64 totalSuspCycles; \ + uint32 numGoodSusp; + + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ + TSCountLowHigh startMaster; \ + uint64 totalMasterCycles; \ + uint32 numMasterAnimations; \ + TSCountLowHigh startReqHdlr; \ + uint64 totalPluginCycles; \ + uint32 numPluginAnimations; \ + uint64 cyclesTillStartMasterLoop; \ + TSCountLowHigh endMasterLoop; + +#else + #define MEAS__Insert_System_Meas_Fields_into_Slave + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv +#endif + + +#ifdef MEAS__TURN_ON_PLUGIN_MEAS + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ + Histogram *reqHdlrLowTimeHist; \ + Histogram *reqHdlrHighTimeHist; + + #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ + _VMSMasterEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "plugin_low_time_hist");\ + _VMSMasterEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "plugin_high_time_hist"); + + #define MEAS__startReqHdlr \ + int32 startStamp1, endStamp1; \ + saveLowTimeStampCountInto( startStamp1 ); + + #define MEAS__endReqHdlr \ + saveLowTimeStampCountInto( endStamp1 ); \ + addIntervalToHist( startStamp1, endStamp1, \ + _VMSMasterEnv->reqHdlrLowTimeHist ); \ + addIntervalToHist( startStamp1, endStamp1, \ + _VMSMasterEnv->reqHdlrHighTimeHist ); + + #define MEAS__Print_Hists_for_Plugin_Meas \ + printHist( _VMSMasterEnv->reqHdlrLowTimeHist ); \ + saveHistToFile( _VMSMasterEnv->reqHdlrLowTimeHist ); \ + printHist( _VMSMasterEnv->reqHdlrHighTimeHist ); \ + saveHistToFile( _VMSMasterEnv->reqHdlrHighTimeHist ); \ + freeHistExt( _VMSMasterEnv->reqHdlrLowTimeHist ); \ + freeHistExt( _VMSMasterEnv->reqHdlrHighTimeHist ); +#else + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_Plugin_Meas + #define MEAS__startReqHdlr + #define MEAS__endReqHdlr + #define MEAS__Print_Hists_for_Plugin_Meas + +#endif + + +#ifdef MEAS__TURN_ON_SYSTEM_MEAS + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv + + #define MEAS__startMasterLoop \ + TSCountLowHigh startStamp1, endStamp1; \ + saveTSCLowHigh( endStamp1 ); \ + _VMSMasterEnv->cyclesTillStartMasterLoop = \ + endStamp1.longVal - masterVP->startSusp.longVal; + + #define MEAS__endMasterLoop \ + saveTSCLowHigh( startStamp1 ); \ + _VMSMasterEnv->endMasterLoop.longVal = startStamp1.longVal; + +#else + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_System_Meas + #define MEAS__startMasterLoop_forSys + #define MEAS__endMasterLoop_forSys + #define MEAS__startReqHdlr_forSys + #define MEAS__endReqHdlr_forSys + #define MEAS__Print_Hists_for_System_Meas +#endif + + +//Experiment in two-step macros -- if doesn't work, insert each separately +#define MEAS__Insert_Meas_Fields_into_Slave \ + MEAS__Insert_Susp_Meas_Fields_into_Slave \ + MEAS__Insert_Master_Meas_Fields_into_Slave \ + MEAS__Insert_System_Meas_Fields_into_Slave + + +//====================== Histogram Macros -- Create ======================== +// +// + +//The language implementation should include a definition of this macro, +// which creates all the histograms the language uses to collect measurements +// of plugin operation -- so, if the language didn't define it, must +// define it here (as empty), to avoid compile error +#ifndef MEAS__Make_Meas_Hists_for_Language +#define MEAS__Make_Meas_Hists_for_Language +#endif + + +#ifdef MEAS__TURN_ON_MAKE_HISTS + #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 + +//============================== Probes =================================== + + +//=========================================================================== +#endif /* _VMS_DEFS_H */ + diff -r 0c83ea8adefc -r a18539c0bc37 Defines/VMS_defs__lang_specific.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Defines/VMS_defs__lang_specific.h Wed Mar 07 22:53:50 2012 -0800 @@ -0,0 +1,110 @@ +/* + * Copyright 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _VMS_LANG_SPEC_DEFS_H +#define _VMS_LANG_SPEC_DEFS_H + + + +//=================== Language-specific Measurement Stuff =================== +// +//TODO: move these into the language implementation directories +// + + +//=========================================================================== +//VCilk + +#ifdef VCILK + +#define spawnHistIdx 1 //note: starts at 1 +#define syncHistIdx 2 + +#define MEAS__Make_Meas_Hists_for_Language() \ + _VMSMasterEnv->measHistsInfo = \ + makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ + makeAMeasHist( spawnHistIdx, "Spawn", 50, 0, 200 ) \ + makeAMeasHist( syncHistIdx, "Sync", 50, 0, 200 ) + + +#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 ] ); +#endif + +//=========================================================================== +// SSR + +#ifdef SSR + +#define SendFromToHistIdx 1 //note: starts at 1 +#define SendOfTypeHistIdx 2 +#define ReceiveFromToHistIdx 3 +#define ReceiveOfTypeHistIdx 4 + +#define MEAS__Make_Meas_Hists_for_Language() \ + _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 ) + +#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 /* SSR */ + +#endif /* _VMS_DEFS_H */ + diff -r 0c83ea8adefc -r a18539c0bc37 Defines/VMS_defs__main.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Defines/VMS_defs__main.h Wed Mar 07 22:53:50 2012 -0800 @@ -0,0 +1,41 @@ +/* + * Copyright 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _VMS_DEFS_MAIN_H +#define _VMS_DEFS_MAIN_H +#define _GNU_SOURCE + +//=========================== VMS-wide defs =============================== + +#define SUCCESS 0 + + //only after macro-expansion are the defs of writePrivQ, aso looked up + // so these defs can be at the top, and writePrivQ defined later on.. +#define writeVMSQ writePrivQ +#define readVMSQ readPrivQ +#define makeVMSQ makePrivQ +#define numInVMSQ numInPrivQ +#define VMSQueueStruc PrivQueueStruc + + +/*The language should re-define this, but need a default in case it doesn't*/ +#ifndef _LANG_NAME_ +#define _LANG_NAME_ "" +#endif + +//====================== Hardware Constants ============================ +#include "VMS_defs__HW_constants.h" + +//====================== Debug, Meas, etc defines ====================== +#include "VMS_defs__turn_on_and_off.h" +#include "VMS_defs__DEBUG.h" +#include "VMS_defs__MEAS.h" + +//=========================================================================== +#endif /* */ + diff -r 0c83ea8adefc -r a18539c0bc37 Defines/VMS_defs__turn_on_and_off.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Defines/VMS_defs__turn_on_and_off.h Wed Mar 07 22:53:50 2012 -0800 @@ -0,0 +1,75 @@ +/* + * Copyright 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _VMS_DEFS_TURN_ON_AND_OFF_H +#define _VMS_DEFS_TURN_ON_AND_OFF_H +#define _GNU_SOURCE + +//====================== Turn Debug things on and off ===================== +/*When DEBUG__TURN_ON_SEQUENTIAL_MODE 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 Slvs one at a time + */ +//#define DEBUG__TURN_ON_SEQUENTIAL_MODE + + +/*turns on the probe-instrumentation in the application -- when not + * defined, the calls to the probe functions turn into comments + */ +//#define DEBUG__TURN_ON_DEBUG_MSGS +//#define DEBUG__TURN_ON_ERROR_MSGS + +/*These defines turn types of bug messages on and off + */ +#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 Slvs*/ +#define dbgRqstHdlr FALSE /* in request handler code*/ + + +//================== Turn Probe Things on and off ==================== +/*Probes are used in the application as a cheap, convenient, and fast way + * to collect statistics. Define this to enable them, else the probe + * statements in the application code all turn into empty whitespace + * in the pre-processor + */ +//#define PROBES__TURN_ON_STATS_PROBES + +/*When PROBES__TURN_ON_STATS_PROBES is defined, turn on one of these to choose + * what kind of measurement the probes store + */ +//#define PROBES__USE_TSC_PROBES +#define PROBES__USE_TIME_OF_DAY_PROBES +//#define PROBES__USE_PERF_CTR_PROBES + + +//============== Turn Internal Measurement Things on and off =============== + +//#define MEAS__TURN_ON_SUSP_MEAS +//#define MEAS__TURN_ON_MASTER_MEAS +//#define MEAS__TURN_ON_MASTER_LOCK_MEAS +//#define MEAS__TURN_ON_MALLOC_MEAS +//#define MEAS__TURN_ON_PLUGIN_MEAS +//#define MEAS__TURN_ON_SYSTEM_MEAS + + /*turn on/off subtraction of create measurements from plugin meas*/ +//#define MEAS__TURN_ON_EXCLUDE_CREATION_TIME + + +//=================== Turn on or off system options ======================= +// +/*Defining SYS__TURN_ON_WORK_STEALING causes the core controller behavior + * to change. When it detects too many back-to-back masters, then it + * searches the other core controllers, looking for work it can steal from + * them. + */ +//#define SYS__TURN_ON_WORK_STEALING + +//=========================================================================== +#endif /* */ + diff -r 0c83ea8adefc -r a18539c0bc37 MasterLoop.c --- a/MasterLoop.c Sun Mar 04 14:26:35 2012 -0800 +++ b/MasterLoop.c Wed Mar 07 22:53:50 2012 -0800 @@ -83,7 +83,7 @@ void *semanticEnv; int32 thisCoresIdx; - SlaveVP *masterVP; + SlaveVP *masterVP; volatile SlaveVP *volatileMasterVP; volatileMasterVP = animatingSlv; @@ -118,7 +118,7 @@ schedSlots = masterEnv->allSchedSlots[thisCoresIdx]; requestHandler = masterEnv->requestHandler; - slaveAssigner = masterEnv->slaveAssigner; + slaveAssigner = masterEnv->slaveAssigner; semanticEnv = masterEnv->semanticEnv; @@ -133,23 +133,12 @@ currSlot->workIsDone = FALSE; currSlot->needsSlaveAssigned = TRUE; - //process requests from slave to master - //====================== MEASUREMENT STUFF =================== - #ifdef MEAS__TURN_ON_PLUGIN_MEAS - int32 startStamp1, endStamp1; - saveLowTimeStampCountInto( startStamp1 ); - #endif - //============================================================ + MEAS__startReqHdlr; + + //process the requests made by the slave (held inside slave struc) (*requestHandler)( currSlot->slaveAssignedToSlot, semanticEnv ); - //====================== MEASUREMENT STUFF =================== - #ifdef MEAS__TURN_ON_PLUGIN_MEAS - saveLowTimeStampCountInto( endStamp1 ); - addIntervalToHist( startStamp1, endStamp1, - _VMSMasterEnv->reqHdlrLowTimeHist ); - addIntervalToHist( startStamp1, endStamp1, - _VMSMasterEnv->reqHdlrHighTimeHist ); - #endif - //============================================================ + + MEAS__endReqHdlr; } if( currSlot->needsSlaveAssigned ) { //give slot a new Slv @@ -158,17 +147,15 @@ if( schedSlaveVP != NULL ) { currSlot->slaveAssignedToSlot = schedSlaveVP; - schedSlaveVP->schedSlot = currSlot; + schedSlaveVP->schedSlot = currSlot; currSlot->needsSlaveAssigned = FALSE; numSlotsFilled += 1; - - writeVMSQ( schedSlaveVP, readyToAnimateQ ); } } } - #ifdef USE_WORK_STEALING + #ifdef SYS__TURN_ON_WORK_STEALING //If no slots filled, means no more work, look for work to steal. if( numSlotsFilled == 0 ) { gateProtected_stealWorkInto( currSlot, readyToAnimateQ, masterVP ); diff -r 0c83ea8adefc -r a18539c0bc37 Probes/probes.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Probes/probes.c Wed Mar 07 22:53:50 2012 -0800 @@ -0,0 +1,301 @@ +/* + * Copyright 2010 OpenSourceStewardshipFoundation + * + * Licensed under BSD + */ + +#include +#include +#include + +#include "VMS.h" + + + +//==================== Probes ================= +/* + * In practice, probe operations are called from the app, from inside slaves + * -- so have to be sure each probe is single-Slv owned, and be sure that + * any place common structures are modified it's done inside the master. + * So -- the only place common structures are modified is during creation. + * after that, all mods are to individual instances. + * + * Thniking perhaps should change the semantics to be that probes are + * attached to the virtual processor -- and then everything is guaranteed + * to be isolated -- except then can't take any intervals that span Slvs, + * and would have to transfer the probes to Master env when Slv dissipates.. + * gets messy.. + * + * For now, just making so that probe creation causes a suspend, so that + * the dynamic array in the master env is only modified from the master + * + */ + +//============================ Helpers =========================== +inline void +doNothing() + { + } + + +IntervalProbe * +create_generic_probe( char *nameStr, SlaveVP *animSlv ) + { + VMSSemReq reqData; + + reqData.reqType = createProbe; + reqData.nameStr = nameStr; + + VMS_WL__send_VMSSem_request( &reqData, animSlv ); + + return animSlv->dataRetFromReq; + } + +/*Use this version from outside VMS -- it uses external malloc, and modifies + * dynamic array, so can't be animated in a slave Slv + */ +IntervalProbe * +ext__create_generic_probe( char *nameStr ) + { IntervalProbe *newProbe; + int32 nameLen; + + newProbe = malloc( sizeof(IntervalProbe) ); + nameLen = strlen( nameStr ); + newProbe->nameStr = malloc( nameLen ); + memcpy( newProbe->nameStr, nameStr, nameLen ); + newProbe->hist = NULL; + newProbe->schedChoiceWasRecorded = FALSE; + newProbe->probeID = + addToDynArray( newProbe, _VMSMasterEnv->dynIntervalProbesInfo ); + + return newProbe; + } + +//============================ Fns def in header ======================= + +int32 +VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ) + { IntervalProbe *newProbe; + + newProbe = create_generic_probe( nameStr, animSlv ); + + return newProbe->probeID; + } + +int32 +VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, + float64 binWidth, char *nameStr, SlaveVP *animSlv ) + { IntervalProbe *newProbe; + + newProbe = create_generic_probe( nameStr, animSlv ); + +#ifdef PROBES__USE_TIME_OF_DAY_PROBES + DblHist *hist; + hist = makeDblHistogram( numBins, startValue, binWidth ); +#else + Histogram *hist; + hist = makeHistogram( numBins, startValue, binWidth ); +#endif + newProbe->hist = hist; + return newProbe->probeID; + } + + +int32 +VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv) + { IntervalProbe *newProbe; + struct timeval *startStamp; + float64 startSecs; + + newProbe = create_generic_probe( nameStr, animSlv ); + newProbe->endSecs = 0; + + + gettimeofday( &(newProbe->startStamp), NULL); + + //turn into a double + startStamp = &(newProbe->startStamp); + startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); + newProbe->startSecs = startSecs; + + return newProbe->probeID; + } + +int32 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ) + { IntervalProbe *newProbe; + struct timeval *startStamp; + float64 startSecs; + + newProbe = ext__create_generic_probe( nameStr ); + newProbe->endSecs = 0; + + gettimeofday( &(newProbe->startStamp), NULL); + + //turn into a double + startStamp = &(newProbe->startStamp); + startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); + newProbe->startSecs = startSecs; + + return newProbe->probeID; + } + + +/*Only call from inside master or main startup/shutdown thread + */ +void +VMS_impl__free_probe( IntervalProbe *probe ) + { if( probe->hist != NULL ) freeDblHist( probe->hist ); + if( probe->nameStr != NULL) VMS_int__free( probe->nameStr ); + VMS_int__free( probe ); + } + + +void +VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ) + { IntervalProbe *probe; + + //TODO: fix this To be in Master -- race condition + probe = _VMSMasterEnv->intervalProbes[ probeID ]; + + addValueIntoTable(probe->nameStr, probe, _VMSMasterEnv->probeNameHashTbl); + } + + +IntervalProbe * +VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ) + { + //TODO: fix this To be in Master -- race condition + return getValueFromTable( probeName, _VMSMasterEnv->probeNameHashTbl ); + } + + +/*Everything is local to the animating procr, so no need for request, do + * work locally, in the anim Slv + */ +void +VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animatingSlv ) + { IntervalProbe *probe; + + probe = _VMSMasterEnv->intervalProbes[ probeID ]; + probe->schedChoiceWasRecorded = TRUE; + probe->coreNum = animatingSlv->coreAnimatedBy; + probe->slaveID = animatingSlv->procrID; + probe->slaveCreateSecs = animatingSlv->createPtInSecs; + } + +/*Everything is local to the animating procr, so no need for request, do + * work locally, in the anim Slv + */ +void +VMS_impl__record_interval_start_in_probe( int32 probeID ) + { IntervalProbe *probe; + + DEBUG( dbgProbes, "record start of interval\n" ) + probe = _VMSMasterEnv->intervalProbes[ probeID ]; + + //record *start* point as last thing, after lookup +#ifdef PROBES__USE_TIME_OF_DAY_PROBES + gettimeofday( &(probe->startStamp), NULL); +#else #ifdef PROBES__USE_TSC_PROBES + probe->startStamp = getTSCount(); +#endif + } + + +/*Everything is local to the animating procr, except the histogram, so do + * work locally, in the anim Slv -- may lose a few histogram counts + * + *This should be safe to run inside SlaveVP + */ +void +VMS_impl__record_interval_end_in_probe( int32 probeID ) + { IntervalProbe *probe; + + //Record first thing -- before looking up the probe to store it into +#ifdef PROBES__USE_TIME_OF_DAY_PROBES + struct timeval endStamp, interval; + gettimeofday( &(endStamp), NULL); +#endif +#ifdef PROBES__USE_TSC_PROBES + TSCount endStamp, interval; + endStamp = getTSCount(); +#endif +#ifdef PROBES__USE_PERF_CTR_PROBES + +#endif + + probe = _VMSMasterEnv->intervalProbes[ probeID ]; + +#ifdef PROBES__USE_TIME_OF_DAY_PROBES + if( probe->hist != NULL ) + { interval = probe->endStamp - probe->startStamp; + addToDblHist( interval.tv_sec + interval.tv_usec/1000000.0, probe->hist ); + } +#endif +#ifdef PROBES__USE_TSC_PROBES + if( probe->hist != NULL ) + { interval = probe->endStamp - probe->startStamp; + //Sanity check for TSC counter overflow: if sane, add to histogram + if( interval < probe->hist->endOfRange * 10 ) + addToHist( interval, probe->hist ); + } +#endif +#ifdef PROBES__USE_PERF_CTR_PROBES + +#endif + + DEBUG( dbgProbes, "record end of interval\n" ) + } + + +void +print_probe_helper( IntervalProbe *probe ) + { + printf( "\nprobe: %s, ", probe->nameStr ); + + + if( probe->schedChoiceWasRecorded ) + { printf( "coreNum: %d, procrID: %d, procrCreated: %0.6f | ", + probe->coreNum, probe->slaveID, probe->slaveCreateSecs ); + } + + if( probe->endSecs == 0 ) //just a single point in time + { + printf( " time point: %.6f\n", + probe->startSecs - _VMSMasterEnv->createPtInSecs ); + } + else if( probe->hist == NULL ) //just an interval + { + printf( " startSecs: %.6f interval: %.6f\n", + (probe->startSecs - _VMSMasterEnv->createPtInSecs), probe->interval); + } + else //a full histogram of intervals + { + printDblHist( probe->hist ); + } + } + +//TODO: change so pass around pointer to probe instead of its array-index.. +// will eliminate chance for timing of resize to cause problems with the +// lookup -- even though don't think it actually can cause problems.. +// there's no need to pass index around -- have hash table for names, and +// only need it once, then have ptr to probe.. the thing about enum the +// index and use that as name is clunky in practice -- just hash. +void +VMS_impl__print_stats_of_probe( int32 probeID ) + { IntervalProbe *probe; + + probe = _VMSMasterEnv->intervalProbes[ probeID ]; + + print_probe_helper( probe ); + } + + +void +VMS_impl__print_stats_of_all_probes() + { + forAllInDynArrayDo( _VMSMasterEnv->dynIntervalProbesInfo, + &VMS_impl__print_stats_of_probe ); + fflush( stdout ); + } diff -r 0c83ea8adefc -r a18539c0bc37 Probes/probes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Probes/probes.h Wed Mar 07 22:53:50 2012 -0800 @@ -0,0 +1,179 @@ +/* + * Copyright 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PROBES_H +#define _PROBES_H +#define _GNU_SOURCE + +#include "../VMS_primitive_data_types.h" + +#include + +/*Note on order of include files: + * This file relies on #defines that appear in other files, which must come + * first in the #include sequence.. + */ + + +/*Use these aliases in application code*/ +#define VMS_App__record_time_point_into_new_probe VMS_WL__record_time_point_into_new_probe +#define VMS_App__create_single_interval_probe VMS_WL__create_single_interval_probe +#define VMS_App__create_histogram_probe VMS_WL__create_histogram_probe +#define VMS_App__index_probe_by_its_name VMS_WL__index_probe_by_its_name +#define VMS_App__get_probe_by_name VMS_WL__get_probe_by_name +#define VMS_App__record_sched_choice_into_probe VMS_WL__record_sched_choice_into_probe +#define VMS_App__record_interval_start_in_probe VMS_WL__record_interval_start_in_probe +#define VMS_App__record_interval_end_in_probe VMS_WL__record_interval_end_in_probe +#define VMS_App__print_stats_of_probe VMS_WL__print_stats_of_probe +#define VMS_App__print_stats_of_all_probes VMS_WL__print_stats_of_all_probes + + +//========================== +#ifdef PROBES__USE_TSC_PROBES + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ + TSCount startStamp; \ + TSCount endStamp; \ + TSCount interval; \ + Histogram *hist; /*if left NULL, then is single interval probe*/ +#endif +#ifdef PROBES__USE_TIME_OF_DAY_PROBES + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ + struct timeval startStamp; \ + struct timeval endStamp; \ + float64 startSecs; \ + float64 endSecs; \ + float64 interval; \ + DblHist *hist; /*if NULL, then is single interval probe*/ +#endif +#ifdef PROBES__USE_PERF_CTR_PROBES + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ + int64 startStamp; \ + int64 endStamp; \ + int64 interval; \ + Histogram *hist; /*if left NULL, then is single interval probe*/ +#endif + +//typedef struct _IntervalProbe IntervalProbe; -- is in VMS.h +struct _IntervalProbe + { + char *nameStr; + int32 probeID; + + int32 schedChoiceWasRecorded; + int32 coreNum; + int32 slaveID; + float64 slaveCreateSecs; + PROBES__Insert_timestamps_and_intervals_into_probe_struct; + }; + +//=========================== NEVER USE THESE ========================== +/*NEVER use these in any code!! These are here only for use in the macros + * defined in this file!! + */ +int32 +VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ); + +int32 +VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, + float64 binWidth, char *nameStr, SlaveVP *animSlv ); + +int32 +VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv); + +int32 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); + +void +VMS_impl__free_probe( IntervalProbe *probe ); + +void +VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ); + +IntervalProbe * +VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ); + +void +VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animSlv ); + +void +VMS_impl__record_interval_start_in_probe( int32 probeID ); + +void +VMS_impl__record_interval_end_in_probe( int32 probeID ); + +void +VMS_impl__print_stats_of_probe( int32 probeID ); + +void +VMS_impl__print_stats_of_all_probes(); + + +//======================== Probes ============================= +// +// Use macros to allow turning probes off with a #define switch +// This means probes have zero impact on performance when off +//============================================================= + +#ifdef PROBES__TURN_ON_STATS_PROBES + #define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) \ + VMS_impl__record_time_point_in_new_probe( nameStr, animSlv ) + + #define VMS_ext__record_time_point_into_new_probe( nameStr ) \ + VMS_ext_impl__record_time_point_into_new_probe( nameStr ) + + #define VMS_WL__create_single_interval_probe( nameStr, animSlv ) \ + VMS_impl__create_single_interval_probe( nameStr, animSlv ) + + #define VMS_WL__create_histogram_probe( numBins, startValue, \ + binWidth, nameStr, animSlv ) \ + VMS_impl__create_histogram_probe( numBins, startValue, \ + binWidth, nameStr, animSlv ) + #define VMS_int__free_probe( probe ) \ + VMS_impl__free_probe( probe ) + + #define VMS_WL__index_probe_by_its_name( probeID, animSlv ) \ + VMS_impl__index_probe_by_its_name( probeID, animSlv ) + + #define VMS_WL__get_probe_by_name( probeID, animSlv ) \ + VMS_impl__get_probe_by_name( probeName, animSlv ) + + #define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) \ + VMS_impl__record_sched_choice_into_probe( probeID, animSlv ) + + #define VMS_WL__record_interval_start_in_probe( probeID ) \ + VMS_impl__record_interval_start_in_probe( probeID ) + + #define VMS_WL__record_interval_end_in_probe( probeID ) \ + VMS_impl__record_interval_end_in_probe( probeID ) + + #define VMS_WL__print_stats_of_probe( probeID ) \ + VMS_impl__print_stats_of_probe( probeID ) + + #define VMS_WL__print_stats_of_all_probes() \ + VMS_impl__print_stats_of_all_probes() + + +#else + #define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) 0 /* do nothing */ + #define VMS_ext__record_time_point_into_new_probe( nameStr ) 0 /* do nothing */ + #define VMS_WL__create_single_interval_probe( nameStr, animSlv ) 0 /* do nothing */ + #define VMS_WL__create_histogram_probe( numBins, startValue, \ + binWidth, nameStr, animSlv ) \ + 0 /* do nothing */ + #define VMS_WL__index_probe_by_its_name( probeID, animSlv ) /* do nothing */ + #define VMS_WL__get_probe_by_name( probeID, animSlv ) NULL /* do nothing */ + #define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) /* do nothing */ + #define VMS_WL__record_interval_start_in_probe( probeID ) /* do nothing */ + #define VMS_WL__record_interval_end_in_probe( probeID ) /* do nothing */ + #define VMS_WL__print_stats_of_probe( probeID ) ; /* do nothing */ + #define VMS_WL__print_stats_of_all_probes() ;/* do nothing */ + +#endif /* defined PROBES__TURN_ON_STATS_PROBES */ + +#endif /* _PROBES_H */ + diff -r 0c83ea8adefc -r a18539c0bc37 README_Code_Overview.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README_Code_Overview.txt Wed Mar 07 22:53:50 2012 -0800 @@ -0,0 +1,18 @@ + +This file is intended to help those new to VMS to find their way around the code. + +Some observations: +-] VMS.h is the top header file, and is the root of a tree of #includes that pulls in all the other headers + +-] Defines directory contains all the header files that hold #define statements + +-] VMS has several kinds of function, grouped according to what kind of code should call them: VMS_App_.. for applications to call, VMS_WL_.. for wrapper-library code to call, VMS_PI_.. for plugin code to call, and VMS_int_.. for VMS to use internally. Sometimes VMS_int_ functions are called from the wrapper library or plugin, but this should only be done by programmers who have gained an in-depth knowledge of VMS's implementation and understand that VMS_int_ functions are not protected for concurrent use.. + +-] VMS has its own version of malloc, unfortunately, which is due to the system malloc breaking when the stack-pointer register is manipulated, which VMS must. The VMS form of malloc must be used in code that runs inside the VMS system, especially all application code that uses a VMS-based language. However, mallocs performed in the main thread, outside the VMS-language program, cannot use VMS malloc.. this presents some issues crossing the boundary.. + +-] VMS has many macros used in the code.. either for measurements or debug.. all measurement, debug, and statistics gathering statements can be turned on or off with a compiler switch. All compiler switches for doing this are found in Defines/VMS_defs__turn_on_and_off.h. The rest of the files in Defines directory contain the macro definitions, hardware constants, and any other #define statements. + +-] The best way to learn VMS is to turn on DEBUG__TURN_ON_SEQUENTIAL_MODE, which allows using a normal debugger while sequentially going through both application code and VMS internals. Setting breakpoints at various spots in the code is a good way to see the VMS system in operation. + +-] VMS has several "VMS primitives" implemented with assembly code. The net effect of these assembly functions is to perform the switching between application code and the VMS system. + diff -r 0c83ea8adefc -r a18539c0bc37 VMS.h --- a/VMS.h Sun Mar 04 14:26:35 2012 -0800 +++ b/VMS.h Wed Mar 07 22:53:50 2012 -0800 @@ -20,15 +20,11 @@ #include #include -#ifndef _LANG_NAME_ -#define _LANG_NAME_ "" -#endif - //================= Defines: included from separate files ================= // // Note: ALL defines are in other files, none are in here // -#include "VMS_defs__main.h" +#include "Defines/VMS_defs__main.h" //================================ Typedefs ================================= @@ -111,7 +107,7 @@ * assembly code to fail -- hard-codes offsets of fields */ struct _SlaveVP - { int procrID; //for debugging -- count up each time create + { int procrID; //each slave given a unique ID int coreAnimatedBy; void *startOfStack; void *stackPtr; @@ -125,8 +121,8 @@ SchedSlot *schedSlot; VMSReqst *requests; - void *semanticData; //this livesUSE_GNU here for the life of Slv - void *dataRetFromReq;//values returned from plugin to Slv go here + void *semanticData; //this is live for the life of Slv + void *dataRetFromReq;//Used to return vals from plugin to Wrapper Lib //=========== MEASUREMENT STUFF ========== MEAS__Insert_Meas_Fields_into_Slave; @@ -147,8 +143,8 @@ RequestHandler requestHandler; SchedSlot ***allSchedSlots; - VMSQueueStruc **readyToAnimateQs; - SlaveVP **masterVPs; + VMSQueueStruc **readyToAnimateQs; + SlaveVP **masterVPs; void *semanticEnv; void *OSEventStruc; //for future, when add I/O to BLIS @@ -288,21 +284,23 @@ #define VMS_PI__create_slaveVP VMS_int__create_slaveVP #define VMS_WL__create_slaveVP VMS_int__create_slaveVP + //Use this to create processor inside entry point & other places outside + // the VMS system boundary (IE, don't animate with a SlaveVP or MasterVP) +SlaveVP * +VMS_ext__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam ); + +inline SlaveVP * +VMS_int__create_slaveVP_helper( SlaveVP *newSlv, TopLevelFnPtr fnPtr, + void *dataParam, void *stackLocs ); + inline void VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr, void *dataParam); -#define VMS_PI__point_slaveVP_to_Fn VMS_int__point_slaveVP_to_Fn -#define VMS_WL__point_slaveVP_to_Fn VMS_int__point_slaveVP_to_Fn void -VMS_int__dissipate_SlaveVP( SlaveVP *slaveToDissipate ); -#define VMS_PI__dissipate_SlaveVP VMS_int__dissipateSlaveVP -//From WL, dissipate a SlaveVP by sending a request - - //Use this to create processor inside entry point & other places outside - // the VMS system boundary (IE, not run in slave nor Master) -SlaveVP * -VMS_ext__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam ); +VMS_int__dissipate_slaveVP( SlaveVP *slaveToDissipate ); +#define VMS_PI__dissipate_slaveVP VMS_int__dissipate_slaveVP +//WL: dissipate a SlaveVP by sending a request void VMS_ext__dissipate_slaveVP( SlaveVP *slaveToDissipate ); @@ -355,8 +353,14 @@ VMS_WL__give_num_plugin_animations(); -#include "probes.h" -#include "vutilities.h" +//========================= Utilities ======================= +inline char * +VMS_int__strDup( char *str ); + +//========================= Probes ======================= +#include "Probes/probes.h" + +//================================================ #endif /* _VMS_H */ diff -r 0c83ea8adefc -r a18539c0bc37 VMS__HW_dependent.c --- a/VMS__HW_dependent.c Sun Mar 04 14:26:35 2012 -0800 +++ b/VMS__HW_dependent.c Wed Mar 07 22:53:50 2012 -0800 @@ -11,6 +11,10 @@ * jumps to it. So, set the resumeInstrPtr to the helper-assembly. *No need to save registers on old stack frame, because there's no old * animator state to return to + * + *This was factored into separate function because it's used stand-alone in + * some wrapper-libraries (but only "int" version, to warn users to check + * carefully that it's safe) */ inline void VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr, @@ -45,4 +49,5 @@ // suspend will save processor's stack and frame into slave slaveVP->stackPtr = slaveVP->startOfStack; slaveVP->framePtr = slaveVP->startOfStack; - } \ No newline at end of file + } + diff -r 0c83ea8adefc -r a18539c0bc37 VMS__HW_dependent.h --- a/VMS__HW_dependent.h Sun Mar 04 14:26:35 2012 -0800 +++ b/VMS__HW_dependent.h Wed Mar 07 22:53:50 2012 -0800 @@ -11,7 +11,7 @@ #define _GNU_SOURCE void -saveCoreLoopReturnAddr(void **returnAddress); +recordCoreLoopReturnLabelAddr(void **returnAddress); void switchToSlv(SlaveVP *nextSlave); @@ -31,10 +31,6 @@ #define flushRegisters() \ asm volatile ("":::"%rbx", "%r12", "%r13","%r14","%r15") -inline SlaveVP * -create_slaveVP_helper( SlaveVP *newSlv, TopLevelFnPtr fnPtr, - void *dataParam, void *stackLocs ); - void VMS_int__save_return_into_ptd_to_loc_then_do_ret(void *ptdToLoc); diff -r 0c83ea8adefc -r a18539c0bc37 VMS__HW_dependent.s --- a/VMS__HW_dependent.s Sun Mar 04 14:26:35 2012 -0800 +++ b/VMS__HW_dependent.s Wed Mar 07 22:53:50 2012 -0800 @@ -6,7 +6,7 @@ //Save return label address for the coreLoop to pointer //Arguments: Pointer to variable holding address .globl saveCoreLoopReturnAddr -saveCoreLoopReturnAddr: +recordCoreLoopReturnLabelAddr: movq $coreLoopReturn, %rcx #load label address movq %rcx, (%rdi) #save address to pointer ret @@ -21,8 +21,8 @@ movq (%rsp) , %rax #get top-level function's addr from stack jmp *%rax #jump to the top-level function -//Switches form CoreLoop to Slv ether a normal Slv or the Master Loop -//switch to Slv's stack and frame ptr then jump to Slv fn +//Switches form CoreLoop to either a normal Slv VP or the Master VP +//switch to VP's stack and frame ptr then jump to VP's next-instr-ptr /* SlaveVP offsets: * 0x10 stackPtr * 0x18 framePtr @@ -62,7 +62,7 @@ .globl switchToCoreLoop switchToCoreLoop: #SlaveVP in %rdi - movq $SlvReturn , 0x20(%rdi) #store return address + movq $SlvReturn, 0x20(%rdi) #store return address movq %rsp , 0x10(%rdi) #save stack pointer movq %rbp , 0x18(%rdi) #save frame pointer movq 0x38(%rdi), %rsp #restore stack pointer @@ -148,8 +148,8 @@ ret #return from core loop -//Assembly code takes the return addr off the stack and saves -// into the loc pointed to by rdi. The return addr is at 0x8(%rbp) for 64bit +//Takes the return addr off the stack and saves into the loc pointed to by +// by the parameter passed in via rdi. Return addr is at 0x8(%rbp) for 64bit .globl VMS_int__save_return_into_ptd_to_loc_then_do_ret VMS_int__save_return_into_ptd_to_loc_then_do_ret: movq 0x8(%rbp), %rax #get ret address, rbp is the same as in the calling function diff -r 0c83ea8adefc -r a18539c0bc37 VMS__int.c --- a/VMS__int.c Sun Mar 04 14:26:35 2012 -0800 +++ b/VMS__int.c Wed Mar 07 22:53:50 2012 -0800 @@ -26,7 +26,7 @@ _VMSMasterEnv->numSlavesAlive += 1; - return create_slaveVP_helper( newSlv, fnPtr, dataParam, stackLocs ); + return VMS_int__create_slaveVP_helper( newSlv, fnPtr, dataParam, stackLocs ); } /* "ext" designates that it's for use outside the VMS system -- should only @@ -45,7 +45,7 @@ _VMSMasterEnv->numSlavesAlive += 1; - return create_slaveVP_helper(newSlv, fnPtr, dataParam, stackLocs); + return VMS_int__create_slaveVP_helper(newSlv, fnPtr, dataParam, stackLocs); } @@ -120,7 +120,7 @@ * of dis-owning it. */ void -VMS_int__dissipate_SlaveVP( SlaveVP *animatingSlv ) +VMS_int__dissipate_slaveVP( SlaveVP *animatingSlv ) { //dis-own all locations owned by this processor, causing to be freed // any locations that it is (was) sole owner of @@ -149,3 +149,41 @@ return _VMSMasterEnv->semanticEnv; } +/* + * + */ +inline SlaveVP * +VMS_int__create_slaveVP_helper( SlaveVP *newSlv, TopLevelFnPtr fnPtr, + void *dataParam, void *stackLocs ) + { + newSlv->startOfStack = stackLocs; + newSlv->procrID = _VMSMasterEnv->numSlavesCreated++; + newSlv->requests = NULL; + newSlv->schedSlot = NULL; + + VMS_int__point_slaveVP_to_Fn( newSlv, fnPtr, dataParam ); + + //============================= MEASUREMENT STUFF ======================== + #ifdef PROBES__TURN_ON_STATS_PROBES + //TODO: make this TSCHiLow or generic equivalent + //struct timeval timeStamp; + //gettimeofday( &(timeStamp), NULL); + //newSlv->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) - + // _VMSMasterEnv->createPtInSecs; + #endif + //======================================================================== + + return newSlv; + } + + +inline char * +VMS_int__strDup( char *str ) + { char *retStr; + + retStr = VMS_int__malloc( strlen(str) + 1 ); + if( str == NULL ) return str; + strcpy( retStr, str ); + + return retStr; + } diff -r 0c83ea8adefc -r a18539c0bc37 VMS__startup_and_shutdown.c --- a/VMS__startup_and_shutdown.c Sun Mar 04 14:26:35 2012 -0800 +++ b/VMS__startup_and_shutdown.c Wed Mar 07 22:53:50 2012 -0800 @@ -12,7 +12,6 @@ #include #include "VMS.h" -//#include "VMS__HW_dependent.h" #define thdAttrs NULL @@ -72,15 +71,32 @@ void VMS_SS__init() { + #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE + create_masterEnv(); + flushRegisters(); //? not sure why here -- merten added it..? + #else + create_masterEnv(); + create_the_coreLoop_OS_threads(); + #endif + } -#ifdef SEQUENTIAL - create_masterEnv(); - flushRegisters(); //? not sure why here -- merten added it..? -#else - create_masterEnv(); - create_the_coreLoop_OS_threads(); -#endif - } + VMS__start_VMS_running( ); + + VMSProcessID matrixMultProcessID; + + matrixMultProcessID = + VMS__spawn_program_on_data_in_Lang( &prog_seed_fn, data, Vthread_lang ); + + resMatrix = VMS__give_results_when_done_for( matrixMultProcessID ); + +// Vthread__give_results_when_done_for( matrixMultProcessID ); + + //VMS__shutdown_lang( Vthread ); + + //Vthread__shutdown_lang(); + + VMS__shutdown(); + void create_masterEnv() @@ -98,12 +114,9 @@ // with a massive initial chunk of memory. //After this, all other mallocs are VMS__malloc. _VMSMasterEnv->freeLists = VMS_ext__create_free_list(); - - - MEAS__Make_Meas_Hists_for_Malloc_Meas; - MEAS__Make_Meas_Hists_for_Plugin_Meas; //===================== Only VMS__malloc after this ==================== + masterEnv = (MasterEnv*)_VMSMasterEnv; //Make a readyToAnimateQ for each core loop @@ -135,7 +148,14 @@ //============================= MEASUREMENT STUFF ======================== - #ifdef STATS__TURN_ON_PROBES + + MEAS__Make_Meas_Hists_for_Susp_Meas; + MEAS__Make_Meas_Hists_for_Master_Meas; + MEAS__Make_Meas_Hists_for_Master_Lock_Meas; + MEAS__Make_Meas_Hists_for_Malloc_Meas; + MEAS__Make_Meas_Hists_for_Plugin_Meas; + + #ifdef PROBES__TURN_ON_STATS_PROBES _VMSMasterEnv->dynIntervalProbesInfo = makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->intervalProbes), 200); @@ -146,11 +166,7 @@ gettimeofday( &(timeStamp), NULL); _VMSMasterEnv->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0); - #endif - - MEAS__Make_Meas_Hists_for_Master_Lock_Meas - - MEAS__Make_Meas_Hists_for_Language(); + #endif //======================================================================== } @@ -236,7 +252,7 @@ void VMS_SS__start_the_work_then_wait_until_done() { -#ifdef SEQUENTIAL +#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE /*Only difference between version with an OS thread pinned to each core and * the sequential version of VMS is VMS__init_Seq, this, and coreLoop_Seq. */ @@ -315,7 +331,6 @@ shutDownSlv = VMS_int__create_slaveVP( &endOSThreadFn, NULL ); writeVMSQ( shutDownSlv, _VMSMasterEnv->readyToAnimateQs[coreIdx] ); } - } @@ -335,7 +350,7 @@ void endOSThreadFn( void *initData, SlaveVP *animatingSlv ) { - #ifdef SEQUENTIAL + #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE asmTerminateCoreLoopSeq(animatingSlv); #else asmTerminateCoreLoop(animatingSlv); @@ -351,7 +366,7 @@ //Before getting rid of everything, print out any measurements made forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&printHist ); forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&saveHistToFile); - forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, &freeHist ); + forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&freeHist ); MEAS__Print_Hists_for_Susp_Meas; MEAS__Print_Hists_for_Master_Meas; @@ -381,7 +396,7 @@ VMS_int__free( _VMSMasterEnv->allSchedSlots ); //============================= MEASUREMENT STUFF ======================== - #ifdef STATS__TURN_ON_PROBES + #ifdef PROBES__TURN_ON_STATS_PROBES freeDynArrayDeep( _VMSMasterEnv->dynIntervalProbesInfo, &VMS_WL__free_probe); #endif //======================================================================== diff -r 0c83ea8adefc -r a18539c0bc37 VMS_defs__HW_specific.h --- a/VMS_defs__HW_specific.h Sun Mar 04 14:26:35 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * Copyright 2012 OpenSourceStewardshipFoundation - * Licensed under BSD - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _VMS_HW_SPEC_DEFS_H -#define _VMS_HW_SPEC_DEFS_H -#define _GNU_SOURCE - - -//========================= Hardware related Constants ===================== - //This value is the number of hardware threads in the shared memory - // machine -#define NUM_CORES 4 - - // tradeoff amortizing master fixed overhead vs imbalance potential - // when work-stealing, can make bigger, at risk of losing cache affinity -#define NUM_SCHED_SLOTS 3 - -#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_WL__malloc -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x40000000 /* 1G */ - - //Frequency of TS counts -- have to do tests to verify - //NOTE: turn off (in BIOS) TURBO-BOOST and SPEED-STEP else won't be const -#define TSCOUNT_FREQ 3180000000 - -#define CACHE_LINE_SZ 256 -#define PAGE_SIZE 4096 - -//To prevent false-sharing, aligns a variable to a cache-line boundary. -//No need to use for local vars because those are never shared between cores -#define __align_to_cacheline__ __attribute__ ((aligned(CACHE_LINE_SZ))) - -//aligns a pointer to cacheline. The memory area has to contain at least -//CACHE_LINE_SZ bytes more then needed -#define __align_address(ptr) ((void*)(((uintptr_t)(ptr))&((uintptr_t)(~0x0FF)))) - -//=========================================================================== - -#endif /* _VMS_DEFS_H */ - diff -r 0c83ea8adefc -r a18539c0bc37 VMS_defs__lang_specific.h --- a/VMS_defs__lang_specific.h Sun Mar 04 14:26:35 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* - * Copyright 2009 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _VMS_LANG_SPEC_DEFS_H -#define _VMS_LANG_SPEC_DEFS_H - - - -//=================== Language-specific Measurement Stuff =================== -// -//TODO: move these into the language implementation directories -// - - -//=========================================================================== -//VCilk - -#ifdef VCILK - -#define spawnHistIdx 1 //note: starts at 1 -#define syncHistIdx 2 - -#define MEAS__Make_Meas_Hists_for_Language() \ - _VMSMasterEnv->measHistsInfo = \ - makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ - makeAMeasHist( spawnHistIdx, "Spawn", 50, 0, 200 ) \ - makeAMeasHist( syncHistIdx, "Sync", 50, 0, 200 ) - - -#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 ] ); -#endif - -//=========================================================================== -// SSR - -#ifdef SSR - -#define SendFromToHistIdx 1 //note: starts at 1 -#define SendOfTypeHistIdx 2 -#define ReceiveFromToHistIdx 3 -#define ReceiveOfTypeHistIdx 4 - -#define MEAS__Make_Meas_Hists_for_Language() \ - _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 ) - -#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 /* SSR */ - -#endif /* _VMS_DEFS_H */ - diff -r 0c83ea8adefc -r a18539c0bc37 VMS_defs__main.h --- a/VMS_defs__main.h Sun Mar 04 14:26:35 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,383 +0,0 @@ -/* - * Copyright 2009 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _VMS_DEFS_MAIN_H -#define _VMS_DEFS_MAIN_H -#define _GNU_SOURCE - -//=========================== VMS-wide defs =============================== -#include "VMS_primitive_data_types.h" - -#define SUCCESS 0 - - //only after macro-expansion are the defs of writePrivQ, aso looked up - // so these defs can be at the top, and writePrivQ defined later on.. -#define writeVMSQ writePrivQ -#define readVMSQ readPrivQ -#define makeVMSQ makePrivQ -#define numInVMSQ numInPrivQ -#define VMSQueueStruc PrivQueueStruc - - -//====================== Hardware Specific Defs ============================ -#include "VMS_defs__HW_specific.h" - -//========================= Debug Related Defs ============================= -// -//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 Slvs 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 Slvs*/ -#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 Related Defs ========================== -// -// - //when STATS__TURN_ON_PROBES is defined allows using probes to measure - // time intervals. The probes are macros that only compile to something - // when STATS__TURN_ON_PROBES is defined. The probes are saved in the - // master env -- but only when this is defined. - //The TSC probes use RDTSC instr, can be unreliable, Dbl uses gettimeofday -#define STATS__TURN_ON_PROBES -//#define STATS__USE_TSC_PROBES -#define STATS__USE_DBL_PROBES - -//================== Turn Measurement Things on and off ==================== - -//#define MEAS__TURN_ON_SYSTEM_MEAS - -/*NOTE: define MEAS__TURN_ON_MAKE_HISTS if any other MEAS__... below are*/ -//#define MEAS__TURN_ON_MAKE_HISTS - -//#define MEAS__TURN_ON_SUSP_MEAS -//#define MEAS__TURN_ON_MASTER_MEAS -//#define MEAS__TURN_ON_PLUGIN_MEAS -//#define MEAS__TURN_ON_MALLOC_MEAS -//#define MEAS__TURN_ON_MASTER_LOCK_MEAS - - /*turn on/off subtraction of create measurements from plugin meas*/ -//#define MEAS__TURN_ON_EXCLUDE_CREATION_TIME - - - -//================== Macros define types of meas want ===================== - -#ifdef MEAS__TURN_ON_SUSP_MEAS - #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ - uint32 preSuspTSCLow; \ - uint32 postSuspTSCLow; - - #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ - Histogram *suspLowTimeHist; \ - Histogram *suspHighTimeHist; - - #define MEAS__Make_Meas_Hists_for_Susp_Meas \ - _VMSMasterEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "master_low_time_hist");\ - _VMSMasterEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "master_high_time_hist"); - - //record time stamp: compare to time-stamp recorded below - #define MEAS__Capture_Pre_Susp_Point \ - saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); - - //NOTE: only take low part of count -- do sanity check when take diff - #define MEAS__Capture_Post_Susp_Point \ - saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ - addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ - _VMSMasterEnv->suspLowTimeHist ); \ - addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ - _VMSMasterEnv->suspHighTimeHist ); - - #define MEAS__Print_Hists_for_Susp_Meas \ - printHist( _VMSMasterEnv->pluginTimeHist ); - -#else - #define MEAS__Insert_Susp_Meas_Fields_into_Slave - #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_Susp_Meas - #define MEAS__Capture_Pre_Susp_Point - #define MEAS__Capture_Post_Susp_Point - #define MEAS__Print_Hists_for_Susp_Meas -#endif - -#ifdef MEAS__TURN_ON_MASTER_MEAS - #define MEAS__Insert_Master_Meas_Fields_into_Slave \ - uint32 startMasterTSCLow; \ - uint32 endMasterTSCLow; - - #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ - Histogram *masterLowTimeHist; \ - Histogram *masterHighTimeHist; - - #define MEAS__Make_Meas_Hists_for_Master_Meas \ - _VMSMasterEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "master_low_time_hist");\ - _VMSMasterEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "master_high_time_hist"); - - //Total Master time includes one coreloop time -- just assume the core - // loop time is same for Master as for AppSlvs, even though it may be - // smaller due to higher predictability of the fixed jmp. - #define MEAS__Capture_Pre_Master_Point\ - saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); - - #define MEAS__Capture_Post_Master_Point \ - saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ - addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ - _VMSMasterEnv->masterLowTimeHist ); \ - addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ - _VMSMasterEnv->masterHighTimeHist ); - - #define MEAS__Print_Hists_for_Master_Meas \ - printHist( _VMSMasterEnv->pluginTimeHist ); - -#else - #define MEAS__Insert_Master_Meas_Fields_into_Slave - #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_Master_Meas - #define MEAS__Capture_Pre_Master_Point - #define MEAS__Capture_Post_Master_Point - #define MEAS__Print_Hists_for_Master_Meas -#endif - - -#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS - #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ - Histogram *masterLockLowTimeHist; \ - Histogram *masterLockHighTimeHist; - - #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ - _VMSMasterEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ - "master lock low time hist");\ - _VMSMasterEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ - "master lock high time hist"); - - #define MEAS__Capture_Pre_Master_Lock_Point \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); - - #define MEAS__Capture_Post_Master_Lock_Point \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp,\ - _VMSMasterEnv->masterLockLowTimeHist ); \ - addIntervalToHist( startStamp, endStamp,\ - _VMSMasterEnv->masterLockHighTimeHist ); - - #define MEAS__Print_Hists_for_Master_Lock_Meas \ - printHist( _VMSMasterEnv->masterLockLowTimeHist ); \ - printHist( _VMSMasterEnv->masterLockHighTimeHist ); - -#else - #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas - #define MEAS__Capture_Pre_Master_Lock_Point - #define MEAS__Capture_Post_Master_Lock_Point - #define MEAS__Print_Hists_for_Master_Lock_Meas -#endif - - -#ifdef MEAS__TURN_ON_MALLOC_MEAS - #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ - Histogram *mallocTimeHist; \ - Histogram *freeTimeHist; - - #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ - _VMSMasterEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ - "malloc_time_hist");\ - _VMSMasterEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ - "free_time_hist"); - - #define MEAS__Capture_Pre_Malloc_Point \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); - - #define MEAS__Capture_Post_Malloc_Point \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp,\ - _VMSMasterEnv->mallocTimeHist ); - - #define MEAS__Capture_Pre_Free_Point \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); - - #define MEAS__Capture_Post_Free_Point \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp,\ - _VMSMasterEnv->freeTimeHist ); - - #define MEAS__Print_Hists_for_Malloc_Meas \ - printHist( _VMSMasterEnv->mallocTimeHist ); \ - saveHistToFile( _VMSMasterEnv->mallocTimeHist ); \ - printHist( _VMSMasterEnv->freeTimeHist ); \ - saveHistToFile( _VMSMasterEnv->freeTimeHist ); \ - freeHistExt( _VMSMasterEnv->mallocTimeHist ); \ - freeHistExt( _VMSMasterEnv->freeTimeHist ); - -#else - #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_Malloc_Meas - #define MEAS__Capture_Pre_Malloc_Point - #define MEAS__Capture_Post_Malloc_Point - #define MEAS__Capture_Pre_Free_Point - #define MEAS__Capture_Post_Free_Point - #define MEAS__Print_Hists_for_Malloc_Meas -#endif - - -#ifdef MEAS__TURN_ON_SYSTEM_MEAS - #define MEAS__Insert_System_Meas_Fields_into_Slave \ - TSCountLowHigh startSusp; \ - uint64 totalSuspCycles; \ - uint32 numGoodSusp; - - #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ - TSCountLowHigh startMaster; \ - uint64 totalMasterCycles; \ - uint32 numMasterAnimations; \ - TSCountLowHigh startReqHdlr; \ - uint64 totalPluginCycles; \ - uint32 numPluginAnimations; \ - uint64 cyclesTillStartMasterLoop; \ - TSCountLowHigh endMasterLoop; - -#else - #define MEAS__Insert_System_Meas_Fields_into_Slave - #define MEAS__Insert_System_Meas_Fields_into_MasterEnv -#endif - - -/*This macro's a bit weird -- the same macro is defined in three different - * ways, depending upon which defines are turned on - *That's because added the system meas, which interferes with plugin meas, - * but don't want to make plugin meas stop working.. this is compromise - */ -#ifdef MEAS__TURN_ON_PLUGIN_MEAS - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ - Histogram *reqHdlrLowTimeHist; \ - Histogram *reqHdlrHighTimeHist; - - #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ - _VMSMasterEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "plugin_low_time_hist");\ - _VMSMasterEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "plugin_high_time_hist"); - - #define Meas_startReqHdlr \ - int32 startStamp1, endStamp1; \ - saveLowTimeStampCountInto( startStamp1 ); - - #define Meas_endReqHdlr \ - saveLowTimeStampCountInto( endStamp1 ); \ - addIntervalToHist( startStamp1, endStamp1, \ - _VMSMasterEnv->reqHdlrLowTimeHist ); \ - addIntervalToHist( startStamp1, endStamp1, \ - _VMSMasterEnv->reqHdlrHighTimeHist ); - - #define MEAS__Print_Hists_for_Plugin_Meas \ - printHist( _VMSMasterEnv->reqHdlrLowTimeHist ); \ - saveHistToFile( _VMSMasterEnv->reqHdlrLowTimeHist ); \ - printHist( _VMSMasterEnv->reqHdlrHighTimeHist ); \ - saveHistToFile( _VMSMasterEnv->reqHdlrHighTimeHist ); \ - freeHistExt( _VMSMasterEnv->reqHdlrLowTimeHist ); \ - freeHistExt( _VMSMasterEnv->reqHdlrHighTimeHist ); - -#elif defined MEAS__TURN_ON_SYSTEM_MEAS - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv - - #define MEAS__Make_Meas_Hists_for_Plugin_Meas - - #define Meas_startMasterLoop \ - TSCountLowHigh startStamp1, endStamp1; \ - saveTSCLowHigh( endStamp1 ); \ - _VMSMasterEnv->cyclesTillStartMasterLoop = \ - endStamp1.longVal - masterVP->startSusp.longVal; - - #define Meas_endMasterLoop \ - saveTSCLowHigh( startStamp1 ); \ - _VMSMasterEnv->endMasterLoop.longVal = startStamp1.longVal; - - #define Meas_startReqHdlr \ - saveTSCLowHigh( startStamp1 ); \ - _VMSMasterEnv->startReqHdlr.longVal = startStamp1.longVal; - - #define Meas_endReqHdlr - - #define MEAS__Print_Hists_for_Plugin_Meas - -#else - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_Plugin_Meas - #define Meas_startMasterLoop - #define Meas_endMasterLoop - #define Meas_startReqHdlr - #define Meas_endReqHdlr - #define MEAS__Print_Hists_for_Plugin_Meas -#endif - - -//Experiment in two-step macros -- if doesn't work, insert each separately -#define MEAS__Insert_Meas_Fields_into_Slave \ - MEAS__Insert_Susp_Meas_Fields_into_Slave \ - MEAS__Insert_Master_Meas_Fields_into_Slave \ - MEAS__Insert_System_Meas_Fields_into_Slave - - -//====================== Histogram Macros -- Create ======================== -// -// - -//The language implementation should include a definition of this macro, -// which creates all the histograms the language uses to collect measurements -// of plugin operation -- so, if the language didn't define it, must -// define it here (as empty), to avoid compile error -#ifndef MEAS__Make_Meas_Hists_for_Language -#define MEAS__Make_Meas_Hists_for_Language() /*consume parens!*/ -#endif - - -#ifdef MEAS__TURN_ON_MAKE_HISTS - #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 - -//============================== Probes =================================== - - -//=========================================================================== -#endif /* _VMS_DEFS_H */ - diff -r 0c83ea8adefc -r a18539c0bc37 probes.c --- a/probes.c Sun Mar 04 14:26:35 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,270 +0,0 @@ -/* - * Copyright 2010 OpenSourceStewardshipFoundation - * - * Licensed under BSD - */ - -#include -#include -#include - -#include "VMS.h" - - - -//==================== Probes ================= -/* - * In practice, probe operations are called from the app, from inside slaves - * -- so have to be sure each probe is single-Slv owned, and be sure that - * any place common structures are modified it's done inside the master. - * So -- the only place common structures are modified is during creation. - * after that, all mods are to individual instances. - * - * Thniking perhaps should change the semantics to be that probes are - * attached to the virtual processor -- and then everything is guaranteed - * to be isolated -- except then can't take any intervals that span Slvs, - * and would have to transfer the probes to Master env when Slv dissipates.. - * gets messy.. - * - * For now, just making so that probe creation causes a suspend, so that - * the dynamic array in the master env is only modified from the master - * - */ - -//============================ Helpers =========================== -inline void -doNothing() - { - } - - -IntervalProbe * -create_generic_probe( char *nameStr, SlaveVP *animSlv ) - { - VMSSemReq reqData; - - reqData.reqType = createProbe; - reqData.nameStr = nameStr; - - VMS_WL__send_VMSSem_request( &reqData, animSlv ); - - return animSlv->dataRetFromReq; - } - -/*Use this version from outside VMS -- it uses external malloc, and modifies - * dynamic array, so can't be animated in a slave Slv - */ -IntervalProbe * -ext__create_generic_probe( char *nameStr ) - { IntervalProbe *newProbe; - int32 nameLen; - - newProbe = malloc( sizeof(IntervalProbe) ); - nameLen = strlen( nameStr ); - newProbe->nameStr = malloc( nameLen ); - memcpy( newProbe->nameStr, nameStr, nameLen ); - newProbe->hist = NULL; - newProbe->schedChoiceWasRecorded = FALSE; - newProbe->probeID = - addToDynArray( newProbe, _VMSMasterEnv->dynIntervalProbesInfo ); - - return newProbe; - } - -//============================ Fns def in header ======================= - -int32 -VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ) - { IntervalProbe *newProbe; - - newProbe = create_generic_probe( nameStr, animSlv ); - - return newProbe->probeID; - } - -int32 -VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, - float64 binWidth, char *nameStr, SlaveVP *animSlv ) - { IntervalProbe *newProbe; - DblHist *hist; - - newProbe = create_generic_probe( nameStr, animSlv ); - - hist = makeDblHistogram( numBins, startValue, binWidth ); - newProbe->hist = hist; - return newProbe->probeID; - } - - -int32 -VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv) - { IntervalProbe *newProbe; - struct timeval *startStamp; - float64 startSecs; - - newProbe = create_generic_probe( nameStr, animSlv ); - newProbe->endSecs = 0; - - gettimeofday( &(newProbe->startStamp), NULL); - - //turn into a double - startStamp = &(newProbe->startStamp); - startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); - newProbe->startSecs = startSecs; - - return newProbe->probeID; - } - -int32 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ) - { IntervalProbe *newProbe; - struct timeval *startStamp; - float64 startSecs; - - newProbe = ext__create_generic_probe( nameStr ); - newProbe->endSecs = 0; - - gettimeofday( &(newProbe->startStamp), NULL); - - //turn into a double - startStamp = &(newProbe->startStamp); - startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); - newProbe->startSecs = startSecs; - - return newProbe->probeID; - } - - -/*Only call from inside master or main startup/shutdown thread - */ -void -VMS_impl__free_probe( IntervalProbe *probe ) - { if( probe->hist != NULL ) freeDblHist( probe->hist ); - if( probe->nameStr != NULL) VMS_int__free( probe->nameStr ); - VMS_int__free( probe ); - } - - -void -VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ) - { IntervalProbe *probe; - - //TODO: fix this To be in Master -- race condition - probe = _VMSMasterEnv->intervalProbes[ probeID ]; - - addValueIntoTable(probe->nameStr, probe, _VMSMasterEnv->probeNameHashTbl); - } - - -IntervalProbe * -VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ) - { - //TODO: fix this To be in Master -- race condition - return getValueFromTable( probeName, _VMSMasterEnv->probeNameHashTbl ); - } - - -/*Everything is local to the animating procr, so no need for request, do - * work locally, in the anim Slv - */ -void -VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animatingSlv ) - { IntervalProbe *probe; - - probe = _VMSMasterEnv->intervalProbes[ probeID ]; - probe->schedChoiceWasRecorded = TRUE; - probe->coreNum = animatingSlv->coreAnimatedBy; - probe->slaveID = animatingSlv->procrID; - probe->slaveCreateSecs = animatingSlv->createPtInSecs; - } - -/*Everything is local to the animating procr, so no need for request, do - * work locally, in the anim Slv - */ -void -VMS_impl__record_interval_start_in_probe( int32 probeID ) - { IntervalProbe *probe; - - DEBUG( dbgProbes, "record start of interval\n" ) - probe = _VMSMasterEnv->intervalProbes[ probeID ]; - probe->startStamp = getTSCount(); - } - - -/*Everything is local to the animating procr, so no need for request, do - * work locally, in the anim Slv - * - *This should be safe to run inside SlaveVP -- weird behavior will be due - * to the logical error of having more than one interval open in overlapped. - */ -void -VMS_impl__record_interval_end_in_probe( int32 probeID ) - { IntervalProbe *probe; - TSCount endStamp; - - endStamp = getTSCount(); - - DEBUG( dbgProbes, "record end of interval\n" ) - - probe = _VMSMasterEnv->intervalProbes[ probeID ]; - probe->endStamp = endStamp; - - if( probe->hist != NULL ) - { TSCount interval = probe->endStamp - probe->startStamp; - //if the interval is sane, then add to histogram - if( interval < probe->hist->endOfRange * 10 ) - addToFloatHist( interval, probe->hist ); - } - } - - -void -print_probe_helper( IntervalProbe *probe ) - { - printf( "\nprobe: %s, ", probe->nameStr ); - - - if( probe->schedChoiceWasRecorded ) - { printf( "coreNum: %d, procrID: %d, procrCreated: %0.6f | ", - probe->coreNum, probe->slaveID, probe->slaveCreateSecs ); - } - - if( probe->endSecs == 0 ) //just a single point in time - { - printf( " time point: %.6f\n", - probe->startSecs - _VMSMasterEnv->createPtInSecs ); - } - else if( probe->hist == NULL ) //just an interval - { - printf( " startSecs: %.6f interval: %.6f\n", - (probe->startSecs - _VMSMasterEnv->createPtInSecs), probe->interval); - } - else //a full histogram of intervals - { - printDblHist( probe->hist ); - } - } - -//TODO: change so pass around pointer to probe instead of its array-index.. -// will eliminate chance for timing of resize to cause problems with the -// lookup -- even though don't think it actually can cause problems.. -// there's no need to pass index around -- have hash table for names, and -// only need it once, then have ptr to probe.. the thing about enum the -// index and use that as name is clunky in practice -- just hash. -void -VMS_impl__print_stats_of_probe( int32 probeID ) - { IntervalProbe *probe; - - probe = _VMSMasterEnv->intervalProbes[ probeID ]; - - print_probe_helper( probe ); - } - - -void -VMS_impl__print_stats_of_all_probes() - { - forAllInDynArrayDo( _VMSMasterEnv->dynIntervalProbesInfo, - &VMS_impl__print_stats_of_probe ); - fflush( stdout ); - } diff -r 0c83ea8adefc -r a18539c0bc37 probes.h --- a/probes.h Sun Mar 04 14:26:35 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,182 +0,0 @@ -/* - * Copyright 2009 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PROBES_H -#define _PROBES_H -#define _GNU_SOURCE - -#include "VMS_primitive_data_types.h" - -#include - -/*Note on order of include files: - * This file relies on #defines that appear in other files.. - */ - - -//typedef struct _IntervalProbe IntervalProbe; //in VMS.h - -struct _IntervalProbe - { - char *nameStr; - int32 probeID; - - int32 schedChoiceWasRecorded; - int32 coreNum; - int32 slaveID; - float64 slaveCreateSecs; - - // #ifdef STATS__USE_TSC_PROBES - TSCount startStamp; - TSCount endStamp; -// #else -// struct timeval startStamp; -// struct timeval endStamp; -// #endif - float64 startSecs; - float64 endSecs; - float64 interval; - DblHist *hist;//if NULL, then is single interval probe - }; - - -int32 -VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ); - -int32 -VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, - float64 binWidth, char *nameStr, SlaveVP *animSlv ); - -int32 -VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv); - -int32 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); - -void -VMS_impl__free_probe( IntervalProbe *probe ); - -void -VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ); - -IntervalProbe * -VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ); - -void -VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animSlv ); - -void -VMS_impl__record_interval_start_in_probe( int32 probeID ); - -void -VMS_impl__record_interval_end_in_probe( int32 probeID ); - -void -VMS_impl__print_stats_of_probe( int32 probeID ); - -void -VMS_impl__print_stats_of_all_probes(); - - -//======================== Probes ============================= -// -// Use macros to allow turning probes off with a #define switch -// This means probes have zero impact on performance when off -//============================================================= -#define VMS_App__record_time_point_into_new_probe VMS_WL__record_time_point_into_new_probe -#define VMS_ext__record_time_point_into_new_probe -#define VMS_App__create_single_interval_probe VMS_WL__create_single_interval_probe -#define VMS_App__create_histogram_probe VMS_WL__create_histogram_probe -#define VMS_App__index_probe_by_its_name VMS_WL__index_probe_by_its_name -#define VMS_App__get_probe_by_name VMS_WL__get_probe_by_name -#define VMS_App__record_sched_choice_into_probe VMS_WL__record_sched_choice_into_probe -#define VMS_App__record_interval_start_in_probe VMS_WL__record_interval_start_in_probe -#define VMS_App__record_interval_end_in_probe VMS_WL__record_interval_end_in_probe -#define VMS_App__print_stats_of_probe VMS_WL__print_stats_of_probe -#define VMS_App__print_stats_of_all_probes VMS_WL__print_stats_of_all_probes - -#ifdef STATS__ENABLE_PROBES -#define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) \ - VMS_impl__record_time_point_in_new_probe( nameStr, animSlv ) - -#define VMS_ext__record_time_point_into_new_probe( nameStr ) \ - VMS_ext_impl__record_time_point_into_new_probe( nameStr ) - -#define VMS_WL__create_single_interval_probe( nameStr, animSlv ) \ - VMS_impl__create_single_interval_probe( nameStr, animSlv ) - -#define VMS_WL__create_histogram_probe( numBins, startValue, \ - binWidth, nameStr, animSlv ) \ - VMS_impl__create_histogram_probe( numBins, startValue, \ - binWidth, nameStr, animSlv ) -#define VMS_int__free_probe( probe ) \ - VMS_impl__free_probe( probe ) - -#define VMS_WL__index_probe_by_its_name( probeID, animSlv ) \ - VMS_impl__index_probe_by_its_name( probeID, animSlv ) - -#define VMS_WL__get_probe_by_name( probeID, animSlv ) \ - VMS_impl__get_probe_by_name( probeName, animSlv ) - -#define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) \ - VMS_impl__record_sched_choice_into_probe( probeID, animSlv ) - -#define VMS_WL__record_interval_start_in_probe( probeID ) \ - VMS_impl__record_interval_start_in_probe( probeID ) - -#define VMS_WL__record_interval_end_in_probe( probeID ) \ - VMS_impl__record_interval_end_in_probe( probeID ) - -#define VMS_WL__print_stats_of_probe( probeID ) \ - VMS_impl__print_stats_of_probe( probeID ) - -#define VMS_WL__print_stats_of_all_probes() \ - VMS_impl__print_stats_of_all_probes() - - -#else -#define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) \ - 0 /* do nothing */ - -#define VMS_ext__record_time_point_into_new_probe( nameStr ) \ - 0 /* do nothing */ - - -#define VMS_WL__create_single_interval_probe( nameStr, animSlv ) \ - 0 /* do nothing */ - - -#define VMS_WL__create_histogram_probe( numBins, startValue, \ - binWidth, nameStr, animSlv ) \ - 0 /* do nothing */ - -#define VMS_WL__index_probe_by_its_name( probeID, animSlv ) \ - /* do nothing */ - -#define VMS_WL__get_probe_by_name( probeID, animSlv ) \ - NULL /* do nothing */ - -#define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) \ - /* do nothing */ - -#define VMS_WL__record_interval_start_in_probe( probeID ) \ - /* do nothing */ - -#define VMS_WL__record_interval_end_in_probe( probeID ) \ - /* do nothing */ - -#define VMS_WL__print_stats_of_probe( probeID ) \ - ; /* do nothing */ - -#define VMS_WL__print_stats_of_all_probes() \ - ;/* do nothing */ - -#endif /* defined STATS__ENABLE_PROBES */ - -#endif /* _PROBES_H */ - diff -r 0c83ea8adefc -r a18539c0bc37 vmalloc.c --- a/vmalloc.c Sun Mar 04 14:26:35 2012 -0800 +++ b/vmalloc.c Wed Mar 07 22:53:50 2012 -0800 @@ -260,13 +260,8 @@ VMS_int__free( void *ptrToFree ) { - //============================= MEASUREMENT STUFF ======================== - #ifdef MEAS__TIME_MALLOC - int32 startStamp, endStamp; - saveLowTimeStampCountInto( startStamp ); - #endif - //======================================================================== - + MEAS__Capture_Pre_Free_Point; + MallocArrays* freeLists = _VMSMasterEnv->freeLists; MallocProlog *chunkToFree = (MallocProlog*)ptrToFree - 1; uint32 containerIdx; @@ -307,13 +302,7 @@ freeLists->bigChunksSearchVector[1] |= (uint64)1 << (containerIdx-64); } - //============================= MEASUREMENT STUFF ======================== - #ifdef MEAS__TIME_MALLOC - saveLowTimeStampCountInto( endStamp ); - addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->freeTimeHist ); - #endif - //======================================================================== - + MEAS__Capture_Post_Free_Point; } /* diff -r 0c83ea8adefc -r a18539c0bc37 vutilities.c --- a/vutilities.c Sun Mar 04 14:26:35 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * Copyright 2009 OpenSourceCodeStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - * Created on November 14, 2009, 9:07 PM - */ - -#include -#include - -#include "VMS.h" - - -inline char * -VMS_int__strDup( char *str ) - { char *retStr; - - retStr = VMS_int__malloc( strlen(str) + 1 ); - if( str == NULL ) return str; - strcpy( retStr, str ); - - return retStr; - } diff -r 0c83ea8adefc -r a18539c0bc37 vutilities.h --- a/vutilities.h Sun Mar 04 14:26:35 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -/* - * Copyright 2009 OpenSourceCodeStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - * Created on November 14, 2009, 9:07 PM - */ - - -#ifndef _VUTILITIES_H -#define _VUTILITIES_H - -#include -#include "VMS_primitive_data_types.h" - -inline char * -VMS_int__strDup( char *str ); - -#endif