Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 210:a18539c0bc37 Common_Ancestor
Moved defines and probes into own directories
| author | Some Random Person <seanhalle@yahoo.com> |
|---|---|
| date | Wed, 07 Mar 2012 22:53:50 -0800 |
| parents | 0c83ea8adefc |
| children | 64737d3deeb4 |
| files | CoreLoop.c Defines/VMS_defs__DEBUG.h Defines/VMS_defs__HW_constants.h Defines/VMS_defs__MEAS.h Defines/VMS_defs__lang_specific.h Defines/VMS_defs__main.h Defines/VMS_defs__turn_on_and_off.h MasterLoop.c Probes/probes.c Probes/probes.h README_Code_Overview.txt VMS.h VMS__HW_dependent.c VMS__HW_dependent.h VMS__HW_dependent.s VMS__int.c VMS__startup_and_shutdown.c VMS_defs__HW_specific.h VMS_defs__lang_specific.h VMS_defs__main.h probes.c probes.h vmalloc.c vutilities.c vutilities.h |
| diffstat | 25 files changed, 1289 insertions(+), 1179 deletions(-) [+] |
line diff
1.1 --- a/CoreLoop.c Sun Mar 04 14:26:35 2012 -0800 1.2 +++ b/CoreLoop.c Wed Mar 07 22:53:50 2012 -0800 1.3 @@ -32,11 +32,11 @@ 1.4 coreLoop( void *paramsIn ) 1.5 { 1.6 ThdParams *coreLoopThdParams; 1.7 - int thisCoresIdx; 1.8 - SlaveVP *currSlv; 1.9 - VMSQueueStruc *readyToAnimateQ; 1.10 + int32 thisCoresIdx, currSlotIdx; 1.11 + SlaveVP *currVP; 1.12 + SchedSlot *currSlot, **schedSlots; 1.13 cpu_set_t coreMask; //has 1 in bit positions of allowed cores 1.14 - int errorCode; 1.15 + int32 errorCode; 1.16 1.17 //work-stealing struc on stack to prevent false-sharing in cache-line 1.18 volatile GateStruc gate; 1.19 @@ -77,52 +77,41 @@ 1.20 if(errorCode){ printf("\nset affinity failure\n"); exit(0); } 1.21 1.22 1.23 - //Save the return address in the SwitchSlv function 1.24 - saveCoreLoopReturnAddr((void**)&(_VMSMasterEnv->coreLoopReturnPt)); 1.25 + //Save return addr from stack into master-env for use later 1.26 + recordCoreLoopReturnLabelAddr((void**)&(_VMSMasterEnv->coreLoopReturnPt)); 1.27 1.28 + currSlotIdx = 0; //start at slot 0, go up until one empty, then do master 1.29 1.30 while(1){ 1.31 1.32 - //Get virtual processor from queue 1.33 - //The Q must be a global, static volatile var, so not kept in reg, 1.34 - // which forces reloading the pointer after each jmp to this point 1.35 - readyToAnimateQ = _VMSMasterEnv->readyToAnimateQs[thisCoresIdx]; 1.36 + schedSlots = _VMSMasterEnv->allSchedSlots[thisCoresIdx]; 1.37 1.38 - #ifdef USE_WORK_STEALING 1.39 - //Alg for work-stealing designed to make common case fast. Comment 1.40 - // in stealer code explains. 1.41 - gate.preGateProgress++; 1.42 - if( gate.gateClosed ) 1.43 - { //now, set coreloop's progress, so stealer can see that core loop 1.44 - // has made it into the waiting area. 1.45 - gate.waitProgress = gate.preGateProgress; 1.46 - while( gate.gateClosed ) /*busy wait*/; 1.47 + if( currSlotIdx >= NUM_SCHED_SLOTS ) goto switchToMaster; 1.48 + 1.49 + currSlot = schedSlots[ currSlotIdx ]; 1.50 + 1.51 + if( ! currSlot->needsSlaveAssigned ) //slot does have slave assigned 1.52 + { _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; //reset B2B master count 1.53 + currSlotIdx ++; 1.54 + currVP = currSlot->slaveAssignedToSlot; 1.55 } 1.56 - 1.57 - currSlv = (SlaveVP *) readVMSQ( readyToAnimateQ ); 1.58 - 1.59 - //Set the coreloop's progress, so stealer can see it has made it out 1.60 - // of the protected area 1.61 - gate.exitProgress = gate.preGateProgress; 1.62 - #else 1.63 - currSlv = (SlaveVP *) readVMSQ( readyToAnimateQ ); 1.64 - #endif 1.65 - 1.66 - if( currSlv != NULL ) _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; 1.67 - else 1.68 + else //slot is empty, so switch to master 1.69 { 1.70 + switchToMaster: 1.71 + currSlotIdx = 0; //switch to master, so start over at slot 0 1.72 + currVP = NULL; 1.73 + 1.74 MEAS__Capture_Pre_Master_Lock_Point; 1.75 1.76 int tries = 0; int gotLock = 0; 1.77 - while( currSlv == NULL ) //if queue was empty, enter get masterLock loop 1.78 - { //queue was empty, so get master lock 1.79 - 1.80 + while( currVP == NULL ) //keep going until get master lock 1.81 + { 1.82 gotLock = __sync_bool_compare_and_swap(&(_VMSMasterEnv->masterLock), 1.83 UNLOCKED, LOCKED ); 1.84 if( gotLock ) 1.85 { //run own MasterVP -- jmps to coreLoops startPt when done 1.86 - currSlv = _VMSMasterEnv->masterVPs[thisCoresIdx]; 1.87 - if( _VMSMasterEnv->numMasterInARow[thisCoresIdx] > 1000 ) 1.88 + currVP = _VMSMasterEnv->masterVPs[thisCoresIdx]; 1.89 + if( _VMSMasterEnv->numMasterInARow[thisCoresIdx] > 10 ) 1.90 { DEBUG( dbgB2BMaster,"Many back to back MasterVPs\n"); 1.91 pthread_yield(); 1.92 } 1.93 @@ -130,14 +119,14 @@ 1.94 break; //end while -- have a Slv to animate now 1.95 } 1.96 1.97 - tries++; //if too many, means master on other core taking too long 1.98 + tries++; //if too many, means master on other core taking too long 1.99 if( tries > MASTERLOCK_RETRIES ) { tries = 0; pthread_yield(); } 1.100 } 1.101 MEAS__Capture_Post_Master_Lock_Point; 1.102 } 1.103 1.104 1.105 - switchToSlv(currSlv); //The Slvs return in here 1.106 + switchToSlv(currVP); //Slave suspend makes core "return" from this call 1.107 flushRegisters(); 1.108 }//CoreLoop 1.109 } 1.110 @@ -147,13 +136,13 @@ 1.111 terminateCoreLoop(SlaveVP *currSlv){ 1.112 //first free shutdown Slv that jumped here -- it first restores the 1.113 // coreloop's stack, so addr of currSlv in stack frame is still correct 1.114 - VMS_int__dissipate_SlaveVP( currSlv ); 1.115 + VMS_int__dissipate_slaveVP( currSlv ); 1.116 pthread_exit( NULL ); 1.117 } 1.118 1.119 1.120 1.121 -#ifdef SEQUENTIAL 1.122 +#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE 1.123 1.124 //=========================================================================== 1.125 /*This sequential version is exact same as threaded, except doesn't do the 1.126 @@ -173,7 +162,7 @@ 1.127 thisCoresIdx = 0; 1.128 1.129 //Save the return address in the SwitchSlv function 1.130 - saveCoreLoopReturnAddr(&(_VMSMasterEnv->coreLoopReturnPt)); 1.131 + recordCoreLoopReturnLabelAddr(&(_VMSMasterEnv->coreLoopReturnPt)); 1.132 1.133 1.134 while(1){
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/Defines/VMS_defs__DEBUG.h Wed Mar 07 22:53:50 2012 -0800 2.3 @@ -0,0 +1,35 @@ 2.4 +/* 2.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 2.6 + * Licensed under GNU General Public License version 2 2.7 + * 2.8 + * Author: seanhalle@yahoo.com 2.9 + * 2.10 + */ 2.11 + 2.12 +#ifndef _VMS_DEFS_DEBUG_H 2.13 +#define _VMS_DEFS_DEBUG_H 2.14 +#define _GNU_SOURCE 2.15 + 2.16 +/* 2.17 + */ 2.18 +#ifdef DEBUG__TURN_ON_DEBUG_MSGS 2.19 + #define DEBUG( bool, msg) \ 2.20 + if( bool){ printf(msg); fflush(stdin);} 2.21 + #define DEBUG1( bool, msg, param) \ 2.22 + if(bool){printf(msg, param); fflush(stdin);} 2.23 + #define DEBUG2( bool, msg, p1, p2) \ 2.24 + if(bool) {printf(msg, p1, p2); fflush(stdin);} 2.25 +#else 2.26 + #define DEBUG( bool, msg) 2.27 + #define DEBUG1( bool, msg, param) 2.28 + #define DEBUG2( bool, msg, p1, p2) 2.29 +#endif 2.30 + 2.31 +//============================= ERROR MSGs ============================ 2.32 +#define ERROR(msg) printf(msg); 2.33 +#define ERROR1(msg, param) printf(msg, param); 2.34 +#define ERROR2(msg, p1, p2) printf(msg, p1, p2); 2.35 + 2.36 +//=========================================================================== 2.37 +#endif /* _VMS_DEFS_H */ 2.38 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/Defines/VMS_defs__HW_constants.h Wed Mar 07 22:53:50 2012 -0800 3.3 @@ -0,0 +1,51 @@ 3.4 +/* 3.5 + * Copyright 2012 OpenSourceStewardshipFoundation 3.6 + * Licensed under BSD 3.7 + * 3.8 + * Author: seanhalle@yahoo.com 3.9 + * 3.10 + */ 3.11 + 3.12 +#ifndef _VMS_HW_SPEC_DEFS_H 3.13 +#define _VMS_HW_SPEC_DEFS_H 3.14 +#define _GNU_SOURCE 3.15 + 3.16 + 3.17 +//========================= Hardware related Constants ===================== 3.18 + //This value is the number of hardware threads in the shared memory 3.19 + // machine 3.20 +#define NUM_CORES 4 3.21 + 3.22 + // tradeoff amortizing master fixed overhead vs imbalance potential 3.23 + // when work-stealing, can make bigger, at risk of losing cache affinity 3.24 +#define NUM_SCHED_SLOTS 3 3.25 + 3.26 +#define MIN_WORK_UNIT_CYCLES 20000 3.27 + 3.28 +#define MASTERLOCK_RETRIES 100 3.29 + 3.30 + // stack size in virtual processors created 3.31 +#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ 3.32 + 3.33 + // memory for VMS_WL__malloc 3.34 +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x40000000 /* 1G */ 3.35 + 3.36 + //Frequency of TS counts -- have to do tests to verify 3.37 + //NOTE: turn off (in BIOS) TURBO-BOOST and SPEED-STEP else won't be const 3.38 +#define TSCOUNT_FREQ 3180000000 3.39 + 3.40 +#define CACHE_LINE_SZ 256 3.41 +#define PAGE_SIZE 4096 3.42 + 3.43 +//To prevent false-sharing, aligns a variable to a cache-line boundary. 3.44 +//No need to use for local vars because those are never shared between cores 3.45 +#define __align_to_cacheline__ __attribute__ ((aligned(CACHE_LINE_SZ))) 3.46 + 3.47 +//aligns a pointer to cacheline. The memory area has to contain at least 3.48 +//CACHE_LINE_SZ bytes more then needed 3.49 +#define __align_address(ptr) ((void*)(((uintptr_t)(ptr))&((uintptr_t)(~0x0FF)))) 3.50 + 3.51 +//=========================================================================== 3.52 + 3.53 +#endif /* _VMS_DEFS_H */ 3.54 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/Defines/VMS_defs__MEAS.h Wed Mar 07 22:53:50 2012 -0800 4.3 @@ -0,0 +1,318 @@ 4.4 +/* 4.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 4.6 + * Licensed under GNU General Public License version 2 4.7 + * 4.8 + * Author: seanhalle@yahoo.com 4.9 + * 4.10 + */ 4.11 + 4.12 +#ifndef _VMS_DEFS_MEAS_H 4.13 +#define _VMS_DEFS_MEAS_H 4.14 +#define _GNU_SOURCE 4.15 + 4.16 +//================== Macros define types of meas want ===================== 4.17 +// 4.18 +/*Generic measurement macro -- has name-space collision potential, which 4.19 + * compiler will catch.. so only use one pair inside a given set of 4.20 + * curly braces. 4.21 + */ 4.22 +//TODO: finish generic capture interval in hist 4.23 +enum histograms 4.24 + { generic1 4.25 + }; 4.26 + #define MEAS__Capture_Pre_Point \ 4.27 + int32 startStamp, endStamp; \ 4.28 + saveLowTimeStampCountInto( startStamp ); 4.29 + 4.30 + #define MEAS__Capture_Post_Point( histName ) \ 4.31 + saveLowTimeStampCountInto( endStamp ); \ 4.32 + addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->histName ); 4.33 + 4.34 + 4.35 + 4.36 + 4.37 +//================== Macros define types of meas want ===================== 4.38 + 4.39 +#ifdef MEAS__TURN_ON_SUSP_MEAS 4.40 + #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ 4.41 + uint32 preSuspTSCLow; \ 4.42 + uint32 postSuspTSCLow; 4.43 + 4.44 + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ 4.45 + Histogram *suspLowTimeHist; \ 4.46 + Histogram *suspHighTimeHist; 4.47 + 4.48 + #define MEAS__Make_Meas_Hists_for_Susp_Meas \ 4.49 + _VMSMasterEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 4.50 + "master_low_time_hist");\ 4.51 + _VMSMasterEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 4.52 + "master_high_time_hist"); 4.53 + 4.54 + //record time stamp: compare to time-stamp recorded below 4.55 + #define MEAS__Capture_Pre_Susp_Point \ 4.56 + saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); 4.57 + 4.58 + //NOTE: only take low part of count -- do sanity check when take diff 4.59 + #define MEAS__Capture_Post_Susp_Point \ 4.60 + saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ 4.61 + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 4.62 + _VMSMasterEnv->suspLowTimeHist ); \ 4.63 + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 4.64 + _VMSMasterEnv->suspHighTimeHist ); 4.65 + 4.66 + #define MEAS__Print_Hists_for_Susp_Meas \ 4.67 + printHist( _VMSMasterEnv->pluginTimeHist ); 4.68 + 4.69 +#else 4.70 + #define MEAS__Insert_Susp_Meas_Fields_into_Slave 4.71 + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv 4.72 + #define MEAS__Make_Meas_Hists_for_Susp_Meas 4.73 + #define MEAS__Capture_Pre_Susp_Point 4.74 + #define MEAS__Capture_Post_Susp_Point 4.75 + #define MEAS__Print_Hists_for_Susp_Meas 4.76 +#endif 4.77 + 4.78 +#ifdef MEAS__TURN_ON_MASTER_MEAS 4.79 + #define MEAS__Insert_Master_Meas_Fields_into_Slave \ 4.80 + uint32 startMasterTSCLow; \ 4.81 + uint32 endMasterTSCLow; 4.82 + 4.83 + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ 4.84 + Histogram *masterLowTimeHist; \ 4.85 + Histogram *masterHighTimeHist; 4.86 + 4.87 + #define MEAS__Make_Meas_Hists_for_Master_Meas \ 4.88 + _VMSMasterEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 4.89 + "master_low_time_hist");\ 4.90 + _VMSMasterEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 4.91 + "master_high_time_hist"); 4.92 + 4.93 + //Total Master time includes one coreloop time -- just assume the core 4.94 + // loop time is same for Master as for AppSlvs, even though it may be 4.95 + // smaller due to higher predictability of the fixed jmp. 4.96 + #define MEAS__Capture_Pre_Master_Point\ 4.97 + saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); 4.98 + 4.99 + #define MEAS__Capture_Post_Master_Point \ 4.100 + saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ 4.101 + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 4.102 + _VMSMasterEnv->masterLowTimeHist ); \ 4.103 + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 4.104 + _VMSMasterEnv->masterHighTimeHist ); 4.105 + 4.106 + #define MEAS__Print_Hists_for_Master_Meas \ 4.107 + printHist( _VMSMasterEnv->pluginTimeHist ); 4.108 + 4.109 +#else 4.110 + #define MEAS__Insert_Master_Meas_Fields_into_Slave 4.111 + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv 4.112 + #define MEAS__Make_Meas_Hists_for_Master_Meas 4.113 + #define MEAS__Capture_Pre_Master_Point 4.114 + #define MEAS__Capture_Post_Master_Point 4.115 + #define MEAS__Print_Hists_for_Master_Meas 4.116 +#endif 4.117 + 4.118 + 4.119 +#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS 4.120 + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ 4.121 + Histogram *masterLockLowTimeHist; \ 4.122 + Histogram *masterLockHighTimeHist; 4.123 + 4.124 + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ 4.125 + _VMSMasterEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ 4.126 + "master lock low time hist");\ 4.127 + _VMSMasterEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ 4.128 + "master lock high time hist"); 4.129 + 4.130 + #define MEAS__Capture_Pre_Master_Lock_Point \ 4.131 + int32 startStamp, endStamp; \ 4.132 + saveLowTimeStampCountInto( startStamp ); 4.133 + 4.134 + #define MEAS__Capture_Post_Master_Lock_Point \ 4.135 + saveLowTimeStampCountInto( endStamp ); \ 4.136 + addIntervalToHist( startStamp, endStamp,\ 4.137 + _VMSMasterEnv->masterLockLowTimeHist ); \ 4.138 + addIntervalToHist( startStamp, endStamp,\ 4.139 + _VMSMasterEnv->masterLockHighTimeHist ); 4.140 + 4.141 + #define MEAS__Print_Hists_for_Master_Lock_Meas \ 4.142 + printHist( _VMSMasterEnv->masterLockLowTimeHist ); \ 4.143 + printHist( _VMSMasterEnv->masterLockHighTimeHist ); 4.144 + 4.145 +#else 4.146 + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv 4.147 + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas 4.148 + #define MEAS__Capture_Pre_Master_Lock_Point 4.149 + #define MEAS__Capture_Post_Master_Lock_Point 4.150 + #define MEAS__Print_Hists_for_Master_Lock_Meas 4.151 +#endif 4.152 + 4.153 + 4.154 +#ifdef MEAS__TURN_ON_MALLOC_MEAS 4.155 + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ 4.156 + Histogram *mallocTimeHist; \ 4.157 + Histogram *freeTimeHist; 4.158 + 4.159 + #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ 4.160 + _VMSMasterEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 4.161 + "malloc_time_hist");\ 4.162 + _VMSMasterEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 4.163 + "free_time_hist"); 4.164 + 4.165 + #define MEAS__Capture_Pre_Malloc_Point \ 4.166 + int32 startStamp, endStamp; \ 4.167 + saveLowTimeStampCountInto( startStamp ); 4.168 + 4.169 + #define MEAS__Capture_Post_Malloc_Point \ 4.170 + saveLowTimeStampCountInto( endStamp ); \ 4.171 + addIntervalToHist( startStamp, endStamp,\ 4.172 + _VMSMasterEnv->mallocTimeHist ); 4.173 + 4.174 + #define MEAS__Capture_Pre_Free_Point \ 4.175 + int32 startStamp, endStamp; \ 4.176 + saveLowTimeStampCountInto( startStamp ); 4.177 + 4.178 + #define MEAS__Capture_Post_Free_Point \ 4.179 + saveLowTimeStampCountInto( endStamp ); \ 4.180 + addIntervalToHist( startStamp, endStamp,\ 4.181 + _VMSMasterEnv->freeTimeHist ); 4.182 + 4.183 + #define MEAS__Print_Hists_for_Malloc_Meas \ 4.184 + printHist( _VMSMasterEnv->mallocTimeHist ); \ 4.185 + saveHistToFile( _VMSMasterEnv->mallocTimeHist ); \ 4.186 + printHist( _VMSMasterEnv->freeTimeHist ); \ 4.187 + saveHistToFile( _VMSMasterEnv->freeTimeHist ); \ 4.188 + freeHistExt( _VMSMasterEnv->mallocTimeHist ); \ 4.189 + freeHistExt( _VMSMasterEnv->freeTimeHist ); 4.190 + 4.191 +#else 4.192 + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv 4.193 + #define MEAS__Make_Meas_Hists_for_Malloc_Meas 4.194 + #define MEAS__Capture_Pre_Malloc_Point 4.195 + #define MEAS__Capture_Post_Malloc_Point 4.196 + #define MEAS__Capture_Pre_Free_Point 4.197 + #define MEAS__Capture_Post_Free_Point 4.198 + #define MEAS__Print_Hists_for_Malloc_Meas 4.199 +#endif 4.200 + 4.201 + 4.202 +#ifdef MEAS__TURN_ON_SYSTEM_MEAS 4.203 + #define MEAS__Insert_System_Meas_Fields_into_Slave \ 4.204 + TSCountLowHigh startSusp; \ 4.205 + uint64 totalSuspCycles; \ 4.206 + uint32 numGoodSusp; 4.207 + 4.208 + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ 4.209 + TSCountLowHigh startMaster; \ 4.210 + uint64 totalMasterCycles; \ 4.211 + uint32 numMasterAnimations; \ 4.212 + TSCountLowHigh startReqHdlr; \ 4.213 + uint64 totalPluginCycles; \ 4.214 + uint32 numPluginAnimations; \ 4.215 + uint64 cyclesTillStartMasterLoop; \ 4.216 + TSCountLowHigh endMasterLoop; 4.217 + 4.218 +#else 4.219 + #define MEAS__Insert_System_Meas_Fields_into_Slave 4.220 + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv 4.221 +#endif 4.222 + 4.223 + 4.224 +#ifdef MEAS__TURN_ON_PLUGIN_MEAS 4.225 + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ 4.226 + Histogram *reqHdlrLowTimeHist; \ 4.227 + Histogram *reqHdlrHighTimeHist; 4.228 + 4.229 + #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ 4.230 + _VMSMasterEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 4.231 + "plugin_low_time_hist");\ 4.232 + _VMSMasterEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 4.233 + "plugin_high_time_hist"); 4.234 + 4.235 + #define MEAS__startReqHdlr \ 4.236 + int32 startStamp1, endStamp1; \ 4.237 + saveLowTimeStampCountInto( startStamp1 ); 4.238 + 4.239 + #define MEAS__endReqHdlr \ 4.240 + saveLowTimeStampCountInto( endStamp1 ); \ 4.241 + addIntervalToHist( startStamp1, endStamp1, \ 4.242 + _VMSMasterEnv->reqHdlrLowTimeHist ); \ 4.243 + addIntervalToHist( startStamp1, endStamp1, \ 4.244 + _VMSMasterEnv->reqHdlrHighTimeHist ); 4.245 + 4.246 + #define MEAS__Print_Hists_for_Plugin_Meas \ 4.247 + printHist( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 4.248 + saveHistToFile( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 4.249 + printHist( _VMSMasterEnv->reqHdlrHighTimeHist ); \ 4.250 + saveHistToFile( _VMSMasterEnv->reqHdlrHighTimeHist ); \ 4.251 + freeHistExt( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 4.252 + freeHistExt( _VMSMasterEnv->reqHdlrHighTimeHist ); 4.253 +#else 4.254 + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv 4.255 + #define MEAS__Make_Meas_Hists_for_Plugin_Meas 4.256 + #define MEAS__startReqHdlr 4.257 + #define MEAS__endReqHdlr 4.258 + #define MEAS__Print_Hists_for_Plugin_Meas 4.259 + 4.260 +#endif 4.261 + 4.262 + 4.263 +#ifdef MEAS__TURN_ON_SYSTEM_MEAS 4.264 + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv 4.265 + 4.266 + #define MEAS__startMasterLoop \ 4.267 + TSCountLowHigh startStamp1, endStamp1; \ 4.268 + saveTSCLowHigh( endStamp1 ); \ 4.269 + _VMSMasterEnv->cyclesTillStartMasterLoop = \ 4.270 + endStamp1.longVal - masterVP->startSusp.longVal; 4.271 + 4.272 + #define MEAS__endMasterLoop \ 4.273 + saveTSCLowHigh( startStamp1 ); \ 4.274 + _VMSMasterEnv->endMasterLoop.longVal = startStamp1.longVal; 4.275 + 4.276 +#else 4.277 + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv 4.278 + #define MEAS__Make_Meas_Hists_for_System_Meas 4.279 + #define MEAS__startMasterLoop_forSys 4.280 + #define MEAS__endMasterLoop_forSys 4.281 + #define MEAS__startReqHdlr_forSys 4.282 + #define MEAS__endReqHdlr_forSys 4.283 + #define MEAS__Print_Hists_for_System_Meas 4.284 +#endif 4.285 + 4.286 + 4.287 +//Experiment in two-step macros -- if doesn't work, insert each separately 4.288 +#define MEAS__Insert_Meas_Fields_into_Slave \ 4.289 + MEAS__Insert_Susp_Meas_Fields_into_Slave \ 4.290 + MEAS__Insert_Master_Meas_Fields_into_Slave \ 4.291 + MEAS__Insert_System_Meas_Fields_into_Slave 4.292 + 4.293 + 4.294 +//====================== Histogram Macros -- Create ======================== 4.295 +// 4.296 +// 4.297 + 4.298 +//The language implementation should include a definition of this macro, 4.299 +// which creates all the histograms the language uses to collect measurements 4.300 +// of plugin operation -- so, if the language didn't define it, must 4.301 +// define it here (as empty), to avoid compile error 4.302 +#ifndef MEAS__Make_Meas_Hists_for_Language 4.303 +#define MEAS__Make_Meas_Hists_for_Language 4.304 +#endif 4.305 + 4.306 + 4.307 +#ifdef MEAS__TURN_ON_MAKE_HISTS 4.308 + #define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ 4.309 + makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \ 4.310 + _VMSMasterEnv->measHists[idx] = \ 4.311 + makeFixedBinHist( numBins, startVal, binWidth, name ); 4.312 +#else 4.313 + #define makeAMeasHist( idx, name, numBins, startVal, binWidth ) 4.314 +#endif 4.315 + 4.316 +//============================== Probes =================================== 4.317 + 4.318 + 4.319 +//=========================================================================== 4.320 +#endif /* _VMS_DEFS_H */ 4.321 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/Defines/VMS_defs__lang_specific.h Wed Mar 07 22:53:50 2012 -0800 5.3 @@ -0,0 +1,110 @@ 5.4 +/* 5.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 5.6 + * Licensed under GNU General Public License version 2 5.7 + * 5.8 + * Author: seanhalle@yahoo.com 5.9 + * 5.10 + */ 5.11 + 5.12 +#ifndef _VMS_LANG_SPEC_DEFS_H 5.13 +#define _VMS_LANG_SPEC_DEFS_H 5.14 + 5.15 + 5.16 + 5.17 +//=================== Language-specific Measurement Stuff =================== 5.18 +// 5.19 +//TODO: move these into the language implementation directories 5.20 +// 5.21 + 5.22 + 5.23 +//=========================================================================== 5.24 +//VCilk 5.25 + 5.26 +#ifdef VCILK 5.27 + 5.28 +#define spawnHistIdx 1 //note: starts at 1 5.29 +#define syncHistIdx 2 5.30 + 5.31 +#define MEAS__Make_Meas_Hists_for_Language() \ 5.32 + _VMSMasterEnv->measHistsInfo = \ 5.33 + makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ 5.34 + makeAMeasHist( spawnHistIdx, "Spawn", 50, 0, 200 ) \ 5.35 + makeAMeasHist( syncHistIdx, "Sync", 50, 0, 200 ) 5.36 + 5.37 + 5.38 +#define Meas_startSpawn \ 5.39 + int32 startStamp, endStamp; \ 5.40 + saveLowTimeStampCountInto( startStamp ); \ 5.41 + 5.42 +#define Meas_endSpawn \ 5.43 + saveLowTimeStampCountInto( endStamp ); \ 5.44 + addIntervalToHist( startStamp, endStamp, \ 5.45 + _VMSMasterEnv->measHists[ spawnHistIdx ] ); 5.46 + 5.47 +#define Meas_startSync \ 5.48 + int32 startStamp, endStamp; \ 5.49 + saveLowTimeStampCountInto( startStamp ); \ 5.50 + 5.51 +#define Meas_endSync \ 5.52 + saveLowTimeStampCountInto( endStamp ); \ 5.53 + addIntervalToHist( startStamp, endStamp, \ 5.54 + _VMSMasterEnv->measHists[ syncHistIdx ] ); 5.55 +#endif 5.56 + 5.57 +//=========================================================================== 5.58 +// SSR 5.59 + 5.60 +#ifdef SSR 5.61 + 5.62 +#define SendFromToHistIdx 1 //note: starts at 1 5.63 +#define SendOfTypeHistIdx 2 5.64 +#define ReceiveFromToHistIdx 3 5.65 +#define ReceiveOfTypeHistIdx 4 5.66 + 5.67 +#define MEAS__Make_Meas_Hists_for_Language() \ 5.68 + _VMSMasterEnv->measHistsInfo = \ 5.69 + makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ 5.70 + makeAMeasHist( SendFromToHistIdx, "SendFromTo", 50, 0, 100 ) \ 5.71 + makeAMeasHist( SendOfTypeHistIdx, "SendOfType", 50, 0, 100 ) \ 5.72 + makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \ 5.73 + makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 ) 5.74 + 5.75 +#define Meas_startSendFromTo \ 5.76 + int32 startStamp, endStamp; \ 5.77 + saveLowTimeStampCountInto( startStamp ); \ 5.78 + 5.79 +#define Meas_endSendFromTo \ 5.80 + saveLowTimeStampCountInto( endStamp ); \ 5.81 + addIntervalToHist( startStamp, endStamp, \ 5.82 + _VMSMasterEnv->measHists[ SendFromToHistIdx ] ); 5.83 + 5.84 +#define Meas_startSendOfType \ 5.85 + int32 startStamp, endStamp; \ 5.86 + saveLowTimeStampCountInto( startStamp ); \ 5.87 + 5.88 +#define Meas_endSendOfType \ 5.89 + saveLowTimeStampCountInto( endStamp ); \ 5.90 + addIntervalToHist( startStamp, endStamp, \ 5.91 + _VMSMasterEnv->measHists[ SendOfTypeHistIdx ] ); 5.92 + 5.93 +#define Meas_startReceiveFromTo \ 5.94 + int32 startStamp, endStamp; \ 5.95 + saveLowTimeStampCountInto( startStamp ); \ 5.96 + 5.97 +#define Meas_endReceiveFromTo \ 5.98 + saveLowTimeStampCountInto( endStamp ); \ 5.99 + addIntervalToHist( startStamp, endStamp, \ 5.100 + _VMSMasterEnv->measHists[ ReceiveFromToHistIdx ] ); 5.101 + 5.102 +#define Meas_startReceiveOfType \ 5.103 + int32 startStamp, endStamp; \ 5.104 + saveLowTimeStampCountInto( startStamp ); \ 5.105 + 5.106 +#define Meas_endReceiveOfType \ 5.107 + saveLowTimeStampCountInto( endStamp ); \ 5.108 + addIntervalToHist( startStamp, endStamp, \ 5.109 + _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); 5.110 +#endif /* SSR */ 5.111 + 5.112 +#endif /* _VMS_DEFS_H */ 5.113 +
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/Defines/VMS_defs__main.h Wed Mar 07 22:53:50 2012 -0800 6.3 @@ -0,0 +1,41 @@ 6.4 +/* 6.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 6.6 + * Licensed under GNU General Public License version 2 6.7 + * 6.8 + * Author: seanhalle@yahoo.com 6.9 + * 6.10 + */ 6.11 + 6.12 +#ifndef _VMS_DEFS_MAIN_H 6.13 +#define _VMS_DEFS_MAIN_H 6.14 +#define _GNU_SOURCE 6.15 + 6.16 +//=========================== VMS-wide defs =============================== 6.17 + 6.18 +#define SUCCESS 0 6.19 + 6.20 + //only after macro-expansion are the defs of writePrivQ, aso looked up 6.21 + // so these defs can be at the top, and writePrivQ defined later on.. 6.22 +#define writeVMSQ writePrivQ 6.23 +#define readVMSQ readPrivQ 6.24 +#define makeVMSQ makePrivQ 6.25 +#define numInVMSQ numInPrivQ 6.26 +#define VMSQueueStruc PrivQueueStruc 6.27 + 6.28 + 6.29 +/*The language should re-define this, but need a default in case it doesn't*/ 6.30 +#ifndef _LANG_NAME_ 6.31 +#define _LANG_NAME_ "" 6.32 +#endif 6.33 + 6.34 +//====================== Hardware Constants ============================ 6.35 +#include "VMS_defs__HW_constants.h" 6.36 + 6.37 +//====================== Debug, Meas, etc defines ====================== 6.38 +#include "VMS_defs__turn_on_and_off.h" 6.39 +#include "VMS_defs__DEBUG.h" 6.40 +#include "VMS_defs__MEAS.h" 6.41 + 6.42 +//=========================================================================== 6.43 +#endif /* */ 6.44 +
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/Defines/VMS_defs__turn_on_and_off.h Wed Mar 07 22:53:50 2012 -0800 7.3 @@ -0,0 +1,75 @@ 7.4 +/* 7.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 7.6 + * Licensed under GNU General Public License version 2 7.7 + * 7.8 + * Author: seanhalle@yahoo.com 7.9 + * 7.10 + */ 7.11 + 7.12 +#ifndef _VMS_DEFS_TURN_ON_AND_OFF_H 7.13 +#define _VMS_DEFS_TURN_ON_AND_OFF_H 7.14 +#define _GNU_SOURCE 7.15 + 7.16 +//====================== Turn Debug things on and off ===================== 7.17 +/*When DEBUG__TURN_ON_SEQUENTIAL_MODE is defined, VMS does sequential exe in the main thread 7.18 + * It still does co-routines and all the mechanisms are the same, it just 7.19 + * has only a single thread and animates Slvs one at a time 7.20 + */ 7.21 +//#define DEBUG__TURN_ON_SEQUENTIAL_MODE 7.22 + 7.23 + 7.24 +/*turns on the probe-instrumentation in the application -- when not 7.25 + * defined, the calls to the probe functions turn into comments 7.26 + */ 7.27 +//#define DEBUG__TURN_ON_DEBUG_MSGS 7.28 +//#define DEBUG__TURN_ON_ERROR_MSGS 7.29 + 7.30 +/*These defines turn types of bug messages on and off 7.31 + */ 7.32 +#define dbgAppFlow TRUE /* Top level flow of application code -- general*/ 7.33 +#define dbgProbes FALSE /* for issues inside probes themselves*/ 7.34 +#define dbgB2BMaster FALSE /* in coreloop, back to back master Slvs*/ 7.35 +#define dbgRqstHdlr FALSE /* in request handler code*/ 7.36 + 7.37 + 7.38 +//================== Turn Probe Things on and off ==================== 7.39 +/*Probes are used in the application as a cheap, convenient, and fast way 7.40 + * to collect statistics. Define this to enable them, else the probe 7.41 + * statements in the application code all turn into empty whitespace 7.42 + * in the pre-processor 7.43 + */ 7.44 +//#define PROBES__TURN_ON_STATS_PROBES 7.45 + 7.46 +/*When PROBES__TURN_ON_STATS_PROBES is defined, turn on one of these to choose 7.47 + * what kind of measurement the probes store 7.48 + */ 7.49 +//#define PROBES__USE_TSC_PROBES 7.50 +#define PROBES__USE_TIME_OF_DAY_PROBES 7.51 +//#define PROBES__USE_PERF_CTR_PROBES 7.52 + 7.53 + 7.54 +//============== Turn Internal Measurement Things on and off =============== 7.55 + 7.56 +//#define MEAS__TURN_ON_SUSP_MEAS 7.57 +//#define MEAS__TURN_ON_MASTER_MEAS 7.58 +//#define MEAS__TURN_ON_MASTER_LOCK_MEAS 7.59 +//#define MEAS__TURN_ON_MALLOC_MEAS 7.60 +//#define MEAS__TURN_ON_PLUGIN_MEAS 7.61 +//#define MEAS__TURN_ON_SYSTEM_MEAS 7.62 + 7.63 + /*turn on/off subtraction of create measurements from plugin meas*/ 7.64 +//#define MEAS__TURN_ON_EXCLUDE_CREATION_TIME 7.65 + 7.66 + 7.67 +//=================== Turn on or off system options ======================= 7.68 +// 7.69 +/*Defining SYS__TURN_ON_WORK_STEALING causes the core controller behavior 7.70 + * to change. When it detects too many back-to-back masters, then it 7.71 + * searches the other core controllers, looking for work it can steal from 7.72 + * them. 7.73 + */ 7.74 +//#define SYS__TURN_ON_WORK_STEALING 7.75 + 7.76 +//=========================================================================== 7.77 +#endif /* */ 7.78 +
8.1 --- a/MasterLoop.c Sun Mar 04 14:26:35 2012 -0800 8.2 +++ b/MasterLoop.c Wed Mar 07 22:53:50 2012 -0800 8.3 @@ -83,7 +83,7 @@ 8.4 void *semanticEnv; 8.5 8.6 int32 thisCoresIdx; 8.7 - SlaveVP *masterVP; 8.8 + SlaveVP *masterVP; 8.9 volatile SlaveVP *volatileMasterVP; 8.10 8.11 volatileMasterVP = animatingSlv; 8.12 @@ -118,7 +118,7 @@ 8.13 schedSlots = masterEnv->allSchedSlots[thisCoresIdx]; 8.14 8.15 requestHandler = masterEnv->requestHandler; 8.16 - slaveAssigner = masterEnv->slaveAssigner; 8.17 + slaveAssigner = masterEnv->slaveAssigner; 8.18 semanticEnv = masterEnv->semanticEnv; 8.19 8.20 8.21 @@ -133,23 +133,12 @@ 8.22 currSlot->workIsDone = FALSE; 8.23 currSlot->needsSlaveAssigned = TRUE; 8.24 8.25 - //process requests from slave to master 8.26 - //====================== MEASUREMENT STUFF =================== 8.27 - #ifdef MEAS__TURN_ON_PLUGIN_MEAS 8.28 - int32 startStamp1, endStamp1; 8.29 - saveLowTimeStampCountInto( startStamp1 ); 8.30 - #endif 8.31 - //============================================================ 8.32 + MEAS__startReqHdlr; 8.33 + 8.34 + //process the requests made by the slave (held inside slave struc) 8.35 (*requestHandler)( currSlot->slaveAssignedToSlot, semanticEnv ); 8.36 - //====================== MEASUREMENT STUFF =================== 8.37 - #ifdef MEAS__TURN_ON_PLUGIN_MEAS 8.38 - saveLowTimeStampCountInto( endStamp1 ); 8.39 - addIntervalToHist( startStamp1, endStamp1, 8.40 - _VMSMasterEnv->reqHdlrLowTimeHist ); 8.41 - addIntervalToHist( startStamp1, endStamp1, 8.42 - _VMSMasterEnv->reqHdlrHighTimeHist ); 8.43 - #endif 8.44 - //============================================================ 8.45 + 8.46 + MEAS__endReqHdlr; 8.47 } 8.48 if( currSlot->needsSlaveAssigned ) 8.49 { //give slot a new Slv 8.50 @@ -158,17 +147,15 @@ 8.51 8.52 if( schedSlaveVP != NULL ) 8.53 { currSlot->slaveAssignedToSlot = schedSlaveVP; 8.54 - schedSlaveVP->schedSlot = currSlot; 8.55 + schedSlaveVP->schedSlot = currSlot; 8.56 currSlot->needsSlaveAssigned = FALSE; 8.57 numSlotsFilled += 1; 8.58 - 8.59 - writeVMSQ( schedSlaveVP, readyToAnimateQ ); 8.60 } 8.61 } 8.62 } 8.63 8.64 8.65 - #ifdef USE_WORK_STEALING 8.66 + #ifdef SYS__TURN_ON_WORK_STEALING 8.67 //If no slots filled, means no more work, look for work to steal. 8.68 if( numSlotsFilled == 0 ) 8.69 { gateProtected_stealWorkInto( currSlot, readyToAnimateQ, masterVP );
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/Probes/probes.c Wed Mar 07 22:53:50 2012 -0800 9.3 @@ -0,0 +1,301 @@ 9.4 +/* 9.5 + * Copyright 2010 OpenSourceStewardshipFoundation 9.6 + * 9.7 + * Licensed under BSD 9.8 + */ 9.9 + 9.10 +#include <stdio.h> 9.11 +#include <malloc.h> 9.12 +#include <sys/time.h> 9.13 + 9.14 +#include "VMS.h" 9.15 + 9.16 + 9.17 + 9.18 +//==================== Probes ================= 9.19 +/* 9.20 + * In practice, probe operations are called from the app, from inside slaves 9.21 + * -- so have to be sure each probe is single-Slv owned, and be sure that 9.22 + * any place common structures are modified it's done inside the master. 9.23 + * So -- the only place common structures are modified is during creation. 9.24 + * after that, all mods are to individual instances. 9.25 + * 9.26 + * Thniking perhaps should change the semantics to be that probes are 9.27 + * attached to the virtual processor -- and then everything is guaranteed 9.28 + * to be isolated -- except then can't take any intervals that span Slvs, 9.29 + * and would have to transfer the probes to Master env when Slv dissipates.. 9.30 + * gets messy.. 9.31 + * 9.32 + * For now, just making so that probe creation causes a suspend, so that 9.33 + * the dynamic array in the master env is only modified from the master 9.34 + * 9.35 + */ 9.36 + 9.37 +//============================ Helpers =========================== 9.38 +inline void 9.39 +doNothing() 9.40 + { 9.41 + } 9.42 + 9.43 + 9.44 +IntervalProbe * 9.45 +create_generic_probe( char *nameStr, SlaveVP *animSlv ) 9.46 + { 9.47 + VMSSemReq reqData; 9.48 + 9.49 + reqData.reqType = createProbe; 9.50 + reqData.nameStr = nameStr; 9.51 + 9.52 + VMS_WL__send_VMSSem_request( &reqData, animSlv ); 9.53 + 9.54 + return animSlv->dataRetFromReq; 9.55 + } 9.56 + 9.57 +/*Use this version from outside VMS -- it uses external malloc, and modifies 9.58 + * dynamic array, so can't be animated in a slave Slv 9.59 + */ 9.60 +IntervalProbe * 9.61 +ext__create_generic_probe( char *nameStr ) 9.62 + { IntervalProbe *newProbe; 9.63 + int32 nameLen; 9.64 + 9.65 + newProbe = malloc( sizeof(IntervalProbe) ); 9.66 + nameLen = strlen( nameStr ); 9.67 + newProbe->nameStr = malloc( nameLen ); 9.68 + memcpy( newProbe->nameStr, nameStr, nameLen ); 9.69 + newProbe->hist = NULL; 9.70 + newProbe->schedChoiceWasRecorded = FALSE; 9.71 + newProbe->probeID = 9.72 + addToDynArray( newProbe, _VMSMasterEnv->dynIntervalProbesInfo ); 9.73 + 9.74 + return newProbe; 9.75 + } 9.76 + 9.77 +//============================ Fns def in header ======================= 9.78 + 9.79 +int32 9.80 +VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ) 9.81 + { IntervalProbe *newProbe; 9.82 + 9.83 + newProbe = create_generic_probe( nameStr, animSlv ); 9.84 + 9.85 + return newProbe->probeID; 9.86 + } 9.87 + 9.88 +int32 9.89 +VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 9.90 + float64 binWidth, char *nameStr, SlaveVP *animSlv ) 9.91 + { IntervalProbe *newProbe; 9.92 + 9.93 + newProbe = create_generic_probe( nameStr, animSlv ); 9.94 + 9.95 +#ifdef PROBES__USE_TIME_OF_DAY_PROBES 9.96 + DblHist *hist; 9.97 + hist = makeDblHistogram( numBins, startValue, binWidth ); 9.98 +#else 9.99 + Histogram *hist; 9.100 + hist = makeHistogram( numBins, startValue, binWidth ); 9.101 +#endif 9.102 + newProbe->hist = hist; 9.103 + return newProbe->probeID; 9.104 + } 9.105 + 9.106 + 9.107 +int32 9.108 +VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv) 9.109 + { IntervalProbe *newProbe; 9.110 + struct timeval *startStamp; 9.111 + float64 startSecs; 9.112 + 9.113 + newProbe = create_generic_probe( nameStr, animSlv ); 9.114 + newProbe->endSecs = 0; 9.115 + 9.116 + 9.117 + gettimeofday( &(newProbe->startStamp), NULL); 9.118 + 9.119 + //turn into a double 9.120 + startStamp = &(newProbe->startStamp); 9.121 + startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); 9.122 + newProbe->startSecs = startSecs; 9.123 + 9.124 + return newProbe->probeID; 9.125 + } 9.126 + 9.127 +int32 9.128 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ) 9.129 + { IntervalProbe *newProbe; 9.130 + struct timeval *startStamp; 9.131 + float64 startSecs; 9.132 + 9.133 + newProbe = ext__create_generic_probe( nameStr ); 9.134 + newProbe->endSecs = 0; 9.135 + 9.136 + gettimeofday( &(newProbe->startStamp), NULL); 9.137 + 9.138 + //turn into a double 9.139 + startStamp = &(newProbe->startStamp); 9.140 + startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); 9.141 + newProbe->startSecs = startSecs; 9.142 + 9.143 + return newProbe->probeID; 9.144 + } 9.145 + 9.146 + 9.147 +/*Only call from inside master or main startup/shutdown thread 9.148 + */ 9.149 +void 9.150 +VMS_impl__free_probe( IntervalProbe *probe ) 9.151 + { if( probe->hist != NULL ) freeDblHist( probe->hist ); 9.152 + if( probe->nameStr != NULL) VMS_int__free( probe->nameStr ); 9.153 + VMS_int__free( probe ); 9.154 + } 9.155 + 9.156 + 9.157 +void 9.158 +VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ) 9.159 + { IntervalProbe *probe; 9.160 + 9.161 + //TODO: fix this To be in Master -- race condition 9.162 + probe = _VMSMasterEnv->intervalProbes[ probeID ]; 9.163 + 9.164 + addValueIntoTable(probe->nameStr, probe, _VMSMasterEnv->probeNameHashTbl); 9.165 + } 9.166 + 9.167 + 9.168 +IntervalProbe * 9.169 +VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ) 9.170 + { 9.171 + //TODO: fix this To be in Master -- race condition 9.172 + return getValueFromTable( probeName, _VMSMasterEnv->probeNameHashTbl ); 9.173 + } 9.174 + 9.175 + 9.176 +/*Everything is local to the animating procr, so no need for request, do 9.177 + * work locally, in the anim Slv 9.178 + */ 9.179 +void 9.180 +VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animatingSlv ) 9.181 + { IntervalProbe *probe; 9.182 + 9.183 + probe = _VMSMasterEnv->intervalProbes[ probeID ]; 9.184 + probe->schedChoiceWasRecorded = TRUE; 9.185 + probe->coreNum = animatingSlv->coreAnimatedBy; 9.186 + probe->slaveID = animatingSlv->procrID; 9.187 + probe->slaveCreateSecs = animatingSlv->createPtInSecs; 9.188 + } 9.189 + 9.190 +/*Everything is local to the animating procr, so no need for request, do 9.191 + * work locally, in the anim Slv 9.192 + */ 9.193 +void 9.194 +VMS_impl__record_interval_start_in_probe( int32 probeID ) 9.195 + { IntervalProbe *probe; 9.196 + 9.197 + DEBUG( dbgProbes, "record start of interval\n" ) 9.198 + probe = _VMSMasterEnv->intervalProbes[ probeID ]; 9.199 + 9.200 + //record *start* point as last thing, after lookup 9.201 +#ifdef PROBES__USE_TIME_OF_DAY_PROBES 9.202 + gettimeofday( &(probe->startStamp), NULL); 9.203 +#else #ifdef PROBES__USE_TSC_PROBES 9.204 + probe->startStamp = getTSCount(); 9.205 +#endif 9.206 + } 9.207 + 9.208 + 9.209 +/*Everything is local to the animating procr, except the histogram, so do 9.210 + * work locally, in the anim Slv -- may lose a few histogram counts 9.211 + * 9.212 + *This should be safe to run inside SlaveVP 9.213 + */ 9.214 +void 9.215 +VMS_impl__record_interval_end_in_probe( int32 probeID ) 9.216 + { IntervalProbe *probe; 9.217 + 9.218 + //Record first thing -- before looking up the probe to store it into 9.219 +#ifdef PROBES__USE_TIME_OF_DAY_PROBES 9.220 + struct timeval endStamp, interval; 9.221 + gettimeofday( &(endStamp), NULL); 9.222 +#endif 9.223 +#ifdef PROBES__USE_TSC_PROBES 9.224 + TSCount endStamp, interval; 9.225 + endStamp = getTSCount(); 9.226 +#endif 9.227 +#ifdef PROBES__USE_PERF_CTR_PROBES 9.228 + 9.229 +#endif 9.230 + 9.231 + probe = _VMSMasterEnv->intervalProbes[ probeID ]; 9.232 + 9.233 +#ifdef PROBES__USE_TIME_OF_DAY_PROBES 9.234 + if( probe->hist != NULL ) 9.235 + { interval = probe->endStamp - probe->startStamp; 9.236 + addToDblHist( interval.tv_sec + interval.tv_usec/1000000.0, probe->hist ); 9.237 + } 9.238 +#endif 9.239 +#ifdef PROBES__USE_TSC_PROBES 9.240 + if( probe->hist != NULL ) 9.241 + { interval = probe->endStamp - probe->startStamp; 9.242 + //Sanity check for TSC counter overflow: if sane, add to histogram 9.243 + if( interval < probe->hist->endOfRange * 10 ) 9.244 + addToHist( interval, probe->hist ); 9.245 + } 9.246 +#endif 9.247 +#ifdef PROBES__USE_PERF_CTR_PROBES 9.248 + 9.249 +#endif 9.250 + 9.251 + DEBUG( dbgProbes, "record end of interval\n" ) 9.252 + } 9.253 + 9.254 + 9.255 +void 9.256 +print_probe_helper( IntervalProbe *probe ) 9.257 + { 9.258 + printf( "\nprobe: %s, ", probe->nameStr ); 9.259 + 9.260 + 9.261 + if( probe->schedChoiceWasRecorded ) 9.262 + { printf( "coreNum: %d, procrID: %d, procrCreated: %0.6f | ", 9.263 + probe->coreNum, probe->slaveID, probe->slaveCreateSecs ); 9.264 + } 9.265 + 9.266 + if( probe->endSecs == 0 ) //just a single point in time 9.267 + { 9.268 + printf( " time point: %.6f\n", 9.269 + probe->startSecs - _VMSMasterEnv->createPtInSecs ); 9.270 + } 9.271 + else if( probe->hist == NULL ) //just an interval 9.272 + { 9.273 + printf( " startSecs: %.6f interval: %.6f\n", 9.274 + (probe->startSecs - _VMSMasterEnv->createPtInSecs), probe->interval); 9.275 + } 9.276 + else //a full histogram of intervals 9.277 + { 9.278 + printDblHist( probe->hist ); 9.279 + } 9.280 + } 9.281 + 9.282 +//TODO: change so pass around pointer to probe instead of its array-index.. 9.283 +// will eliminate chance for timing of resize to cause problems with the 9.284 +// lookup -- even though don't think it actually can cause problems.. 9.285 +// there's no need to pass index around -- have hash table for names, and 9.286 +// only need it once, then have ptr to probe.. the thing about enum the 9.287 +// index and use that as name is clunky in practice -- just hash. 9.288 +void 9.289 +VMS_impl__print_stats_of_probe( int32 probeID ) 9.290 + { IntervalProbe *probe; 9.291 + 9.292 + probe = _VMSMasterEnv->intervalProbes[ probeID ]; 9.293 + 9.294 + print_probe_helper( probe ); 9.295 + } 9.296 + 9.297 + 9.298 +void 9.299 +VMS_impl__print_stats_of_all_probes() 9.300 + { 9.301 + forAllInDynArrayDo( _VMSMasterEnv->dynIntervalProbesInfo, 9.302 + &VMS_impl__print_stats_of_probe ); 9.303 + fflush( stdout ); 9.304 + }
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/Probes/probes.h Wed Mar 07 22:53:50 2012 -0800 10.3 @@ -0,0 +1,179 @@ 10.4 +/* 10.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 10.6 + * Licensed under GNU General Public License version 2 10.7 + * 10.8 + * Author: seanhalle@yahoo.com 10.9 + * 10.10 + */ 10.11 + 10.12 +#ifndef _PROBES_H 10.13 +#define _PROBES_H 10.14 +#define _GNU_SOURCE 10.15 + 10.16 +#include "../VMS_primitive_data_types.h" 10.17 + 10.18 +#include <sys/time.h> 10.19 + 10.20 +/*Note on order of include files: 10.21 + * This file relies on #defines that appear in other files, which must come 10.22 + * first in the #include sequence.. 10.23 + */ 10.24 + 10.25 + 10.26 +/*Use these aliases in application code*/ 10.27 +#define VMS_App__record_time_point_into_new_probe VMS_WL__record_time_point_into_new_probe 10.28 +#define VMS_App__create_single_interval_probe VMS_WL__create_single_interval_probe 10.29 +#define VMS_App__create_histogram_probe VMS_WL__create_histogram_probe 10.30 +#define VMS_App__index_probe_by_its_name VMS_WL__index_probe_by_its_name 10.31 +#define VMS_App__get_probe_by_name VMS_WL__get_probe_by_name 10.32 +#define VMS_App__record_sched_choice_into_probe VMS_WL__record_sched_choice_into_probe 10.33 +#define VMS_App__record_interval_start_in_probe VMS_WL__record_interval_start_in_probe 10.34 +#define VMS_App__record_interval_end_in_probe VMS_WL__record_interval_end_in_probe 10.35 +#define VMS_App__print_stats_of_probe VMS_WL__print_stats_of_probe 10.36 +#define VMS_App__print_stats_of_all_probes VMS_WL__print_stats_of_all_probes 10.37 + 10.38 + 10.39 +//========================== 10.40 +#ifdef PROBES__USE_TSC_PROBES 10.41 + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ 10.42 + TSCount startStamp; \ 10.43 + TSCount endStamp; \ 10.44 + TSCount interval; \ 10.45 + Histogram *hist; /*if left NULL, then is single interval probe*/ 10.46 +#endif 10.47 +#ifdef PROBES__USE_TIME_OF_DAY_PROBES 10.48 + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ 10.49 + struct timeval startStamp; \ 10.50 + struct timeval endStamp; \ 10.51 + float64 startSecs; \ 10.52 + float64 endSecs; \ 10.53 + float64 interval; \ 10.54 + DblHist *hist; /*if NULL, then is single interval probe*/ 10.55 +#endif 10.56 +#ifdef PROBES__USE_PERF_CTR_PROBES 10.57 + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ 10.58 + int64 startStamp; \ 10.59 + int64 endStamp; \ 10.60 + int64 interval; \ 10.61 + Histogram *hist; /*if left NULL, then is single interval probe*/ 10.62 +#endif 10.63 + 10.64 +//typedef struct _IntervalProbe IntervalProbe; -- is in VMS.h 10.65 +struct _IntervalProbe 10.66 + { 10.67 + char *nameStr; 10.68 + int32 probeID; 10.69 + 10.70 + int32 schedChoiceWasRecorded; 10.71 + int32 coreNum; 10.72 + int32 slaveID; 10.73 + float64 slaveCreateSecs; 10.74 + PROBES__Insert_timestamps_and_intervals_into_probe_struct; 10.75 + }; 10.76 + 10.77 +//=========================== NEVER USE THESE ========================== 10.78 +/*NEVER use these in any code!! These are here only for use in the macros 10.79 + * defined in this file!! 10.80 + */ 10.81 +int32 10.82 +VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ); 10.83 + 10.84 +int32 10.85 +VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 10.86 + float64 binWidth, char *nameStr, SlaveVP *animSlv ); 10.87 + 10.88 +int32 10.89 +VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv); 10.90 + 10.91 +int32 10.92 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); 10.93 + 10.94 +void 10.95 +VMS_impl__free_probe( IntervalProbe *probe ); 10.96 + 10.97 +void 10.98 +VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ); 10.99 + 10.100 +IntervalProbe * 10.101 +VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ); 10.102 + 10.103 +void 10.104 +VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animSlv ); 10.105 + 10.106 +void 10.107 +VMS_impl__record_interval_start_in_probe( int32 probeID ); 10.108 + 10.109 +void 10.110 +VMS_impl__record_interval_end_in_probe( int32 probeID ); 10.111 + 10.112 +void 10.113 +VMS_impl__print_stats_of_probe( int32 probeID ); 10.114 + 10.115 +void 10.116 +VMS_impl__print_stats_of_all_probes(); 10.117 + 10.118 + 10.119 +//======================== Probes ============================= 10.120 +// 10.121 +// Use macros to allow turning probes off with a #define switch 10.122 +// This means probes have zero impact on performance when off 10.123 +//============================================================= 10.124 + 10.125 +#ifdef PROBES__TURN_ON_STATS_PROBES 10.126 + #define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) \ 10.127 + VMS_impl__record_time_point_in_new_probe( nameStr, animSlv ) 10.128 + 10.129 + #define VMS_ext__record_time_point_into_new_probe( nameStr ) \ 10.130 + VMS_ext_impl__record_time_point_into_new_probe( nameStr ) 10.131 + 10.132 + #define VMS_WL__create_single_interval_probe( nameStr, animSlv ) \ 10.133 + VMS_impl__create_single_interval_probe( nameStr, animSlv ) 10.134 + 10.135 + #define VMS_WL__create_histogram_probe( numBins, startValue, \ 10.136 + binWidth, nameStr, animSlv ) \ 10.137 + VMS_impl__create_histogram_probe( numBins, startValue, \ 10.138 + binWidth, nameStr, animSlv ) 10.139 + #define VMS_int__free_probe( probe ) \ 10.140 + VMS_impl__free_probe( probe ) 10.141 + 10.142 + #define VMS_WL__index_probe_by_its_name( probeID, animSlv ) \ 10.143 + VMS_impl__index_probe_by_its_name( probeID, animSlv ) 10.144 + 10.145 + #define VMS_WL__get_probe_by_name( probeID, animSlv ) \ 10.146 + VMS_impl__get_probe_by_name( probeName, animSlv ) 10.147 + 10.148 + #define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) \ 10.149 + VMS_impl__record_sched_choice_into_probe( probeID, animSlv ) 10.150 + 10.151 + #define VMS_WL__record_interval_start_in_probe( probeID ) \ 10.152 + VMS_impl__record_interval_start_in_probe( probeID ) 10.153 + 10.154 + #define VMS_WL__record_interval_end_in_probe( probeID ) \ 10.155 + VMS_impl__record_interval_end_in_probe( probeID ) 10.156 + 10.157 + #define VMS_WL__print_stats_of_probe( probeID ) \ 10.158 + VMS_impl__print_stats_of_probe( probeID ) 10.159 + 10.160 + #define VMS_WL__print_stats_of_all_probes() \ 10.161 + VMS_impl__print_stats_of_all_probes() 10.162 + 10.163 + 10.164 +#else 10.165 + #define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) 0 /* do nothing */ 10.166 + #define VMS_ext__record_time_point_into_new_probe( nameStr ) 0 /* do nothing */ 10.167 + #define VMS_WL__create_single_interval_probe( nameStr, animSlv ) 0 /* do nothing */ 10.168 + #define VMS_WL__create_histogram_probe( numBins, startValue, \ 10.169 + binWidth, nameStr, animSlv ) \ 10.170 + 0 /* do nothing */ 10.171 + #define VMS_WL__index_probe_by_its_name( probeID, animSlv ) /* do nothing */ 10.172 + #define VMS_WL__get_probe_by_name( probeID, animSlv ) NULL /* do nothing */ 10.173 + #define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) /* do nothing */ 10.174 + #define VMS_WL__record_interval_start_in_probe( probeID ) /* do nothing */ 10.175 + #define VMS_WL__record_interval_end_in_probe( probeID ) /* do nothing */ 10.176 + #define VMS_WL__print_stats_of_probe( probeID ) ; /* do nothing */ 10.177 + #define VMS_WL__print_stats_of_all_probes() ;/* do nothing */ 10.178 + 10.179 +#endif /* defined PROBES__TURN_ON_STATS_PROBES */ 10.180 + 10.181 +#endif /* _PROBES_H */ 10.182 +
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/README_Code_Overview.txt Wed Mar 07 22:53:50 2012 -0800 11.3 @@ -0,0 +1,18 @@ 11.4 + 11.5 +This file is intended to help those new to VMS to find their way around the code. 11.6 + 11.7 +Some observations: 11.8 +-] VMS.h is the top header file, and is the root of a tree of #includes that pulls in all the other headers 11.9 + 11.10 +-] Defines directory contains all the header files that hold #define statements 11.11 + 11.12 +-] 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.. 11.13 + 11.14 +-] 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.. 11.15 + 11.16 +-] 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. 11.17 + 11.18 +-] 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. 11.19 + 11.20 +-] 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. 11.21 +
12.1 --- a/VMS.h Sun Mar 04 14:26:35 2012 -0800 12.2 +++ b/VMS.h Wed Mar 07 22:53:50 2012 -0800 12.3 @@ -20,15 +20,11 @@ 12.4 #include <pthread.h> 12.5 #include <sys/time.h> 12.6 12.7 -#ifndef _LANG_NAME_ 12.8 -#define _LANG_NAME_ "" 12.9 -#endif 12.10 - 12.11 //================= Defines: included from separate files ================= 12.12 // 12.13 // Note: ALL defines are in other files, none are in here 12.14 // 12.15 -#include "VMS_defs__main.h" 12.16 +#include "Defines/VMS_defs__main.h" 12.17 12.18 12.19 //================================ Typedefs ================================= 12.20 @@ -111,7 +107,7 @@ 12.21 * assembly code to fail -- hard-codes offsets of fields 12.22 */ 12.23 struct _SlaveVP 12.24 - { int procrID; //for debugging -- count up each time create 12.25 + { int procrID; //each slave given a unique ID 12.26 int coreAnimatedBy; 12.27 void *startOfStack; 12.28 void *stackPtr; 12.29 @@ -125,8 +121,8 @@ 12.30 SchedSlot *schedSlot; 12.31 VMSReqst *requests; 12.32 12.33 - void *semanticData; //this livesUSE_GNU here for the life of Slv 12.34 - void *dataRetFromReq;//values returned from plugin to Slv go here 12.35 + void *semanticData; //this is live for the life of Slv 12.36 + void *dataRetFromReq;//Used to return vals from plugin to Wrapper Lib 12.37 12.38 //=========== MEASUREMENT STUFF ========== 12.39 MEAS__Insert_Meas_Fields_into_Slave; 12.40 @@ -147,8 +143,8 @@ 12.41 RequestHandler requestHandler; 12.42 12.43 SchedSlot ***allSchedSlots; 12.44 - VMSQueueStruc **readyToAnimateQs; 12.45 - SlaveVP **masterVPs; 12.46 + VMSQueueStruc **readyToAnimateQs; 12.47 + SlaveVP **masterVPs; 12.48 12.49 void *semanticEnv; 12.50 void *OSEventStruc; //for future, when add I/O to BLIS 12.51 @@ -288,21 +284,23 @@ 12.52 #define VMS_PI__create_slaveVP VMS_int__create_slaveVP 12.53 #define VMS_WL__create_slaveVP VMS_int__create_slaveVP 12.54 12.55 + //Use this to create processor inside entry point & other places outside 12.56 + // the VMS system boundary (IE, don't animate with a SlaveVP or MasterVP) 12.57 +SlaveVP * 12.58 +VMS_ext__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam ); 12.59 + 12.60 +inline SlaveVP * 12.61 +VMS_int__create_slaveVP_helper( SlaveVP *newSlv, TopLevelFnPtr fnPtr, 12.62 + void *dataParam, void *stackLocs ); 12.63 + 12.64 inline void 12.65 VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr, 12.66 void *dataParam); 12.67 -#define VMS_PI__point_slaveVP_to_Fn VMS_int__point_slaveVP_to_Fn 12.68 -#define VMS_WL__point_slaveVP_to_Fn VMS_int__point_slaveVP_to_Fn 12.69 12.70 void 12.71 -VMS_int__dissipate_SlaveVP( SlaveVP *slaveToDissipate ); 12.72 -#define VMS_PI__dissipate_SlaveVP VMS_int__dissipateSlaveVP 12.73 -//From WL, dissipate a SlaveVP by sending a request 12.74 - 12.75 - //Use this to create processor inside entry point & other places outside 12.76 - // the VMS system boundary (IE, not run in slave nor Master) 12.77 -SlaveVP * 12.78 -VMS_ext__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam ); 12.79 +VMS_int__dissipate_slaveVP( SlaveVP *slaveToDissipate ); 12.80 +#define VMS_PI__dissipate_slaveVP VMS_int__dissipate_slaveVP 12.81 +//WL: dissipate a SlaveVP by sending a request 12.82 12.83 void 12.84 VMS_ext__dissipate_slaveVP( SlaveVP *slaveToDissipate ); 12.85 @@ -355,8 +353,14 @@ 12.86 VMS_WL__give_num_plugin_animations(); 12.87 12.88 12.89 -#include "probes.h" 12.90 -#include "vutilities.h" 12.91 +//========================= Utilities ======================= 12.92 +inline char * 12.93 +VMS_int__strDup( char *str ); 12.94 12.95 + 12.96 +//========================= Probes ======================= 12.97 +#include "Probes/probes.h" 12.98 + 12.99 +//================================================ 12.100 #endif /* _VMS_H */ 12.101
13.1 --- a/VMS__HW_dependent.c Sun Mar 04 14:26:35 2012 -0800 13.2 +++ b/VMS__HW_dependent.c Wed Mar 07 22:53:50 2012 -0800 13.3 @@ -11,6 +11,10 @@ 13.4 * jumps to it. So, set the resumeInstrPtr to the helper-assembly. 13.5 *No need to save registers on old stack frame, because there's no old 13.6 * animator state to return to 13.7 + * 13.8 + *This was factored into separate function because it's used stand-alone in 13.9 + * some wrapper-libraries (but only "int" version, to warn users to check 13.10 + * carefully that it's safe) 13.11 */ 13.12 inline void 13.13 VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr, 13.14 @@ -45,4 +49,5 @@ 13.15 // suspend will save processor's stack and frame into slave 13.16 slaveVP->stackPtr = slaveVP->startOfStack; 13.17 slaveVP->framePtr = slaveVP->startOfStack; 13.18 - } 13.19 \ No newline at end of file 13.20 + } 13.21 +
14.1 --- a/VMS__HW_dependent.h Sun Mar 04 14:26:35 2012 -0800 14.2 +++ b/VMS__HW_dependent.h Wed Mar 07 22:53:50 2012 -0800 14.3 @@ -11,7 +11,7 @@ 14.4 #define _GNU_SOURCE 14.5 14.6 void 14.7 -saveCoreLoopReturnAddr(void **returnAddress); 14.8 +recordCoreLoopReturnLabelAddr(void **returnAddress); 14.9 14.10 void 14.11 switchToSlv(SlaveVP *nextSlave); 14.12 @@ -31,10 +31,6 @@ 14.13 #define flushRegisters() \ 14.14 asm volatile ("":::"%rbx", "%r12", "%r13","%r14","%r15") 14.15 14.16 -inline SlaveVP * 14.17 -create_slaveVP_helper( SlaveVP *newSlv, TopLevelFnPtr fnPtr, 14.18 - void *dataParam, void *stackLocs ); 14.19 - 14.20 void 14.21 VMS_int__save_return_into_ptd_to_loc_then_do_ret(void *ptdToLoc); 14.22
15.1 --- a/VMS__HW_dependent.s Sun Mar 04 14:26:35 2012 -0800 15.2 +++ b/VMS__HW_dependent.s Wed Mar 07 22:53:50 2012 -0800 15.3 @@ -6,7 +6,7 @@ 15.4 //Save return label address for the coreLoop to pointer 15.5 //Arguments: Pointer to variable holding address 15.6 .globl saveCoreLoopReturnAddr 15.7 -saveCoreLoopReturnAddr: 15.8 +recordCoreLoopReturnLabelAddr: 15.9 movq $coreLoopReturn, %rcx #load label address 15.10 movq %rcx, (%rdi) #save address to pointer 15.11 ret 15.12 @@ -21,8 +21,8 @@ 15.13 movq (%rsp) , %rax #get top-level function's addr from stack 15.14 jmp *%rax #jump to the top-level function 15.15 15.16 -//Switches form CoreLoop to Slv ether a normal Slv or the Master Loop 15.17 -//switch to Slv's stack and frame ptr then jump to Slv fn 15.18 +//Switches form CoreLoop to either a normal Slv VP or the Master VP 15.19 +//switch to VP's stack and frame ptr then jump to VP's next-instr-ptr 15.20 /* SlaveVP offsets: 15.21 * 0x10 stackPtr 15.22 * 0x18 framePtr 15.23 @@ -62,7 +62,7 @@ 15.24 .globl switchToCoreLoop 15.25 switchToCoreLoop: 15.26 #SlaveVP in %rdi 15.27 - movq $SlvReturn , 0x20(%rdi) #store return address 15.28 + movq $SlvReturn, 0x20(%rdi) #store return address 15.29 movq %rsp , 0x10(%rdi) #save stack pointer 15.30 movq %rbp , 0x18(%rdi) #save frame pointer 15.31 movq 0x38(%rdi), %rsp #restore stack pointer 15.32 @@ -148,8 +148,8 @@ 15.33 ret #return from core loop 15.34 15.35 15.36 -//Assembly code takes the return addr off the stack and saves 15.37 -// into the loc pointed to by rdi. The return addr is at 0x8(%rbp) for 64bit 15.38 +//Takes the return addr off the stack and saves into the loc pointed to by 15.39 +// by the parameter passed in via rdi. Return addr is at 0x8(%rbp) for 64bit 15.40 .globl VMS_int__save_return_into_ptd_to_loc_then_do_ret 15.41 VMS_int__save_return_into_ptd_to_loc_then_do_ret: 15.42 movq 0x8(%rbp), %rax #get ret address, rbp is the same as in the calling function
16.1 --- a/VMS__int.c Sun Mar 04 14:26:35 2012 -0800 16.2 +++ b/VMS__int.c Wed Mar 07 22:53:50 2012 -0800 16.3 @@ -26,7 +26,7 @@ 16.4 16.5 _VMSMasterEnv->numSlavesAlive += 1; 16.6 16.7 - return create_slaveVP_helper( newSlv, fnPtr, dataParam, stackLocs ); 16.8 + return VMS_int__create_slaveVP_helper( newSlv, fnPtr, dataParam, stackLocs ); 16.9 } 16.10 16.11 /* "ext" designates that it's for use outside the VMS system -- should only 16.12 @@ -45,7 +45,7 @@ 16.13 16.14 _VMSMasterEnv->numSlavesAlive += 1; 16.15 16.16 - return create_slaveVP_helper(newSlv, fnPtr, dataParam, stackLocs); 16.17 + return VMS_int__create_slaveVP_helper(newSlv, fnPtr, dataParam, stackLocs); 16.18 } 16.19 16.20 16.21 @@ -120,7 +120,7 @@ 16.22 * of dis-owning it. 16.23 */ 16.24 void 16.25 -VMS_int__dissipate_SlaveVP( SlaveVP *animatingSlv ) 16.26 +VMS_int__dissipate_slaveVP( SlaveVP *animatingSlv ) 16.27 { 16.28 //dis-own all locations owned by this processor, causing to be freed 16.29 // any locations that it is (was) sole owner of 16.30 @@ -149,3 +149,41 @@ 16.31 return _VMSMasterEnv->semanticEnv; 16.32 } 16.33 16.34 +/* 16.35 + * 16.36 + */ 16.37 +inline SlaveVP * 16.38 +VMS_int__create_slaveVP_helper( SlaveVP *newSlv, TopLevelFnPtr fnPtr, 16.39 + void *dataParam, void *stackLocs ) 16.40 + { 16.41 + newSlv->startOfStack = stackLocs; 16.42 + newSlv->procrID = _VMSMasterEnv->numSlavesCreated++; 16.43 + newSlv->requests = NULL; 16.44 + newSlv->schedSlot = NULL; 16.45 + 16.46 + VMS_int__point_slaveVP_to_Fn( newSlv, fnPtr, dataParam ); 16.47 + 16.48 + //============================= MEASUREMENT STUFF ======================== 16.49 + #ifdef PROBES__TURN_ON_STATS_PROBES 16.50 + //TODO: make this TSCHiLow or generic equivalent 16.51 + //struct timeval timeStamp; 16.52 + //gettimeofday( &(timeStamp), NULL); 16.53 + //newSlv->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) - 16.54 + // _VMSMasterEnv->createPtInSecs; 16.55 + #endif 16.56 + //======================================================================== 16.57 + 16.58 + return newSlv; 16.59 + } 16.60 + 16.61 + 16.62 +inline char * 16.63 +VMS_int__strDup( char *str ) 16.64 + { char *retStr; 16.65 + 16.66 + retStr = VMS_int__malloc( strlen(str) + 1 ); 16.67 + if( str == NULL ) return str; 16.68 + strcpy( retStr, str ); 16.69 + 16.70 + return retStr; 16.71 + }
17.1 --- a/VMS__startup_and_shutdown.c Sun Mar 04 14:26:35 2012 -0800 17.2 +++ b/VMS__startup_and_shutdown.c Wed Mar 07 22:53:50 2012 -0800 17.3 @@ -12,7 +12,6 @@ 17.4 #include <sys/time.h> 17.5 17.6 #include "VMS.h" 17.7 -//#include "VMS__HW_dependent.h" 17.8 17.9 17.10 #define thdAttrs NULL 17.11 @@ -72,15 +71,32 @@ 17.12 void 17.13 VMS_SS__init() 17.14 { 17.15 + #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE 17.16 + create_masterEnv(); 17.17 + flushRegisters(); //? not sure why here -- merten added it..? 17.18 + #else 17.19 + create_masterEnv(); 17.20 + create_the_coreLoop_OS_threads(); 17.21 + #endif 17.22 + } 17.23 17.24 -#ifdef SEQUENTIAL 17.25 - create_masterEnv(); 17.26 - flushRegisters(); //? not sure why here -- merten added it..? 17.27 -#else 17.28 - create_masterEnv(); 17.29 - create_the_coreLoop_OS_threads(); 17.30 -#endif 17.31 - } 17.32 + VMS__start_VMS_running( ); 17.33 + 17.34 + VMSProcessID matrixMultProcessID; 17.35 + 17.36 + matrixMultProcessID = 17.37 + VMS__spawn_program_on_data_in_Lang( &prog_seed_fn, data, Vthread_lang ); 17.38 + 17.39 + resMatrix = VMS__give_results_when_done_for( matrixMultProcessID ); 17.40 + 17.41 +// Vthread__give_results_when_done_for( matrixMultProcessID ); 17.42 + 17.43 + //VMS__shutdown_lang( Vthread ); 17.44 + 17.45 + //Vthread__shutdown_lang(); 17.46 + 17.47 + VMS__shutdown(); 17.48 + 17.49 17.50 void 17.51 create_masterEnv() 17.52 @@ -98,12 +114,9 @@ 17.53 // with a massive initial chunk of memory. 17.54 //After this, all other mallocs are VMS__malloc. 17.55 _VMSMasterEnv->freeLists = VMS_ext__create_free_list(); 17.56 - 17.57 - 17.58 - MEAS__Make_Meas_Hists_for_Malloc_Meas; 17.59 - MEAS__Make_Meas_Hists_for_Plugin_Meas; 17.60 17.61 //===================== Only VMS__malloc after this ==================== 17.62 + 17.63 masterEnv = (MasterEnv*)_VMSMasterEnv; 17.64 17.65 //Make a readyToAnimateQ for each core loop 17.66 @@ -135,7 +148,14 @@ 17.67 17.68 17.69 //============================= MEASUREMENT STUFF ======================== 17.70 - #ifdef STATS__TURN_ON_PROBES 17.71 + 17.72 + MEAS__Make_Meas_Hists_for_Susp_Meas; 17.73 + MEAS__Make_Meas_Hists_for_Master_Meas; 17.74 + MEAS__Make_Meas_Hists_for_Master_Lock_Meas; 17.75 + MEAS__Make_Meas_Hists_for_Malloc_Meas; 17.76 + MEAS__Make_Meas_Hists_for_Plugin_Meas; 17.77 + 17.78 + #ifdef PROBES__TURN_ON_STATS_PROBES 17.79 _VMSMasterEnv->dynIntervalProbesInfo = 17.80 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->intervalProbes), 200); 17.81 17.82 @@ -146,11 +166,7 @@ 17.83 gettimeofday( &(timeStamp), NULL); 17.84 _VMSMasterEnv->createPtInSecs = 17.85 timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0); 17.86 - #endif 17.87 - 17.88 - MEAS__Make_Meas_Hists_for_Master_Lock_Meas 17.89 - 17.90 - MEAS__Make_Meas_Hists_for_Language(); 17.91 + #endif 17.92 //======================================================================== 17.93 } 17.94 17.95 @@ -236,7 +252,7 @@ 17.96 void 17.97 VMS_SS__start_the_work_then_wait_until_done() 17.98 { 17.99 -#ifdef SEQUENTIAL 17.100 +#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE 17.101 /*Only difference between version with an OS thread pinned to each core and 17.102 * the sequential version of VMS is VMS__init_Seq, this, and coreLoop_Seq. 17.103 */ 17.104 @@ -315,7 +331,6 @@ 17.105 shutDownSlv = VMS_int__create_slaveVP( &endOSThreadFn, NULL ); 17.106 writeVMSQ( shutDownSlv, _VMSMasterEnv->readyToAnimateQs[coreIdx] ); 17.107 } 17.108 - 17.109 } 17.110 17.111 17.112 @@ -335,7 +350,7 @@ 17.113 void 17.114 endOSThreadFn( void *initData, SlaveVP *animatingSlv ) 17.115 { 17.116 - #ifdef SEQUENTIAL 17.117 + #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE 17.118 asmTerminateCoreLoopSeq(animatingSlv); 17.119 #else 17.120 asmTerminateCoreLoop(animatingSlv); 17.121 @@ -351,7 +366,7 @@ 17.122 //Before getting rid of everything, print out any measurements made 17.123 forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&printHist ); 17.124 forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&saveHistToFile); 17.125 - forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, &freeHist ); 17.126 + forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&freeHist ); 17.127 17.128 MEAS__Print_Hists_for_Susp_Meas; 17.129 MEAS__Print_Hists_for_Master_Meas; 17.130 @@ -381,7 +396,7 @@ 17.131 VMS_int__free( _VMSMasterEnv->allSchedSlots ); 17.132 17.133 //============================= MEASUREMENT STUFF ======================== 17.134 - #ifdef STATS__TURN_ON_PROBES 17.135 + #ifdef PROBES__TURN_ON_STATS_PROBES 17.136 freeDynArrayDeep( _VMSMasterEnv->dynIntervalProbesInfo, &VMS_WL__free_probe); 17.137 #endif 17.138 //========================================================================
18.1 --- a/VMS_defs__HW_specific.h Sun Mar 04 14:26:35 2012 -0800 18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 18.3 @@ -1,51 +0,0 @@ 18.4 -/* 18.5 - * Copyright 2012 OpenSourceStewardshipFoundation 18.6 - * Licensed under BSD 18.7 - * 18.8 - * Author: seanhalle@yahoo.com 18.9 - * 18.10 - */ 18.11 - 18.12 -#ifndef _VMS_HW_SPEC_DEFS_H 18.13 -#define _VMS_HW_SPEC_DEFS_H 18.14 -#define _GNU_SOURCE 18.15 - 18.16 - 18.17 -//========================= Hardware related Constants ===================== 18.18 - //This value is the number of hardware threads in the shared memory 18.19 - // machine 18.20 -#define NUM_CORES 4 18.21 - 18.22 - // tradeoff amortizing master fixed overhead vs imbalance potential 18.23 - // when work-stealing, can make bigger, at risk of losing cache affinity 18.24 -#define NUM_SCHED_SLOTS 3 18.25 - 18.26 -#define MIN_WORK_UNIT_CYCLES 20000 18.27 - 18.28 -#define MASTERLOCK_RETRIES 10000 18.29 - 18.30 - // stack size in virtual processors created 18.31 -#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ 18.32 - 18.33 - // memory for VMS_WL__malloc 18.34 -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x40000000 /* 1G */ 18.35 - 18.36 - //Frequency of TS counts -- have to do tests to verify 18.37 - //NOTE: turn off (in BIOS) TURBO-BOOST and SPEED-STEP else won't be const 18.38 -#define TSCOUNT_FREQ 3180000000 18.39 - 18.40 -#define CACHE_LINE_SZ 256 18.41 -#define PAGE_SIZE 4096 18.42 - 18.43 -//To prevent false-sharing, aligns a variable to a cache-line boundary. 18.44 -//No need to use for local vars because those are never shared between cores 18.45 -#define __align_to_cacheline__ __attribute__ ((aligned(CACHE_LINE_SZ))) 18.46 - 18.47 -//aligns a pointer to cacheline. The memory area has to contain at least 18.48 -//CACHE_LINE_SZ bytes more then needed 18.49 -#define __align_address(ptr) ((void*)(((uintptr_t)(ptr))&((uintptr_t)(~0x0FF)))) 18.50 - 18.51 -//=========================================================================== 18.52 - 18.53 -#endif /* _VMS_DEFS_H */ 18.54 -
19.1 --- a/VMS_defs__lang_specific.h Sun Mar 04 14:26:35 2012 -0800 19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 19.3 @@ -1,110 +0,0 @@ 19.4 -/* 19.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 19.6 - * Licensed under GNU General Public License version 2 19.7 - * 19.8 - * Author: seanhalle@yahoo.com 19.9 - * 19.10 - */ 19.11 - 19.12 -#ifndef _VMS_LANG_SPEC_DEFS_H 19.13 -#define _VMS_LANG_SPEC_DEFS_H 19.14 - 19.15 - 19.16 - 19.17 -//=================== Language-specific Measurement Stuff =================== 19.18 -// 19.19 -//TODO: move these into the language implementation directories 19.20 -// 19.21 - 19.22 - 19.23 -//=========================================================================== 19.24 -//VCilk 19.25 - 19.26 -#ifdef VCILK 19.27 - 19.28 -#define spawnHistIdx 1 //note: starts at 1 19.29 -#define syncHistIdx 2 19.30 - 19.31 -#define MEAS__Make_Meas_Hists_for_Language() \ 19.32 - _VMSMasterEnv->measHistsInfo = \ 19.33 - makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ 19.34 - makeAMeasHist( spawnHistIdx, "Spawn", 50, 0, 200 ) \ 19.35 - makeAMeasHist( syncHistIdx, "Sync", 50, 0, 200 ) 19.36 - 19.37 - 19.38 -#define Meas_startSpawn \ 19.39 - int32 startStamp, endStamp; \ 19.40 - saveLowTimeStampCountInto( startStamp ); \ 19.41 - 19.42 -#define Meas_endSpawn \ 19.43 - saveLowTimeStampCountInto( endStamp ); \ 19.44 - addIntervalToHist( startStamp, endStamp, \ 19.45 - _VMSMasterEnv->measHists[ spawnHistIdx ] ); 19.46 - 19.47 -#define Meas_startSync \ 19.48 - int32 startStamp, endStamp; \ 19.49 - saveLowTimeStampCountInto( startStamp ); \ 19.50 - 19.51 -#define Meas_endSync \ 19.52 - saveLowTimeStampCountInto( endStamp ); \ 19.53 - addIntervalToHist( startStamp, endStamp, \ 19.54 - _VMSMasterEnv->measHists[ syncHistIdx ] ); 19.55 -#endif 19.56 - 19.57 -//=========================================================================== 19.58 -// SSR 19.59 - 19.60 -#ifdef SSR 19.61 - 19.62 -#define SendFromToHistIdx 1 //note: starts at 1 19.63 -#define SendOfTypeHistIdx 2 19.64 -#define ReceiveFromToHistIdx 3 19.65 -#define ReceiveOfTypeHistIdx 4 19.66 - 19.67 -#define MEAS__Make_Meas_Hists_for_Language() \ 19.68 - _VMSMasterEnv->measHistsInfo = \ 19.69 - makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ 19.70 - makeAMeasHist( SendFromToHistIdx, "SendFromTo", 50, 0, 100 ) \ 19.71 - makeAMeasHist( SendOfTypeHistIdx, "SendOfType", 50, 0, 100 ) \ 19.72 - makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \ 19.73 - makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 ) 19.74 - 19.75 -#define Meas_startSendFromTo \ 19.76 - int32 startStamp, endStamp; \ 19.77 - saveLowTimeStampCountInto( startStamp ); \ 19.78 - 19.79 -#define Meas_endSendFromTo \ 19.80 - saveLowTimeStampCountInto( endStamp ); \ 19.81 - addIntervalToHist( startStamp, endStamp, \ 19.82 - _VMSMasterEnv->measHists[ SendFromToHistIdx ] ); 19.83 - 19.84 -#define Meas_startSendOfType \ 19.85 - int32 startStamp, endStamp; \ 19.86 - saveLowTimeStampCountInto( startStamp ); \ 19.87 - 19.88 -#define Meas_endSendOfType \ 19.89 - saveLowTimeStampCountInto( endStamp ); \ 19.90 - addIntervalToHist( startStamp, endStamp, \ 19.91 - _VMSMasterEnv->measHists[ SendOfTypeHistIdx ] ); 19.92 - 19.93 -#define Meas_startReceiveFromTo \ 19.94 - int32 startStamp, endStamp; \ 19.95 - saveLowTimeStampCountInto( startStamp ); \ 19.96 - 19.97 -#define Meas_endReceiveFromTo \ 19.98 - saveLowTimeStampCountInto( endStamp ); \ 19.99 - addIntervalToHist( startStamp, endStamp, \ 19.100 - _VMSMasterEnv->measHists[ ReceiveFromToHistIdx ] ); 19.101 - 19.102 -#define Meas_startReceiveOfType \ 19.103 - int32 startStamp, endStamp; \ 19.104 - saveLowTimeStampCountInto( startStamp ); \ 19.105 - 19.106 -#define Meas_endReceiveOfType \ 19.107 - saveLowTimeStampCountInto( endStamp ); \ 19.108 - addIntervalToHist( startStamp, endStamp, \ 19.109 - _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); 19.110 -#endif /* SSR */ 19.111 - 19.112 -#endif /* _VMS_DEFS_H */ 19.113 -
20.1 --- a/VMS_defs__main.h Sun Mar 04 14:26:35 2012 -0800 20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 20.3 @@ -1,383 +0,0 @@ 20.4 -/* 20.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 20.6 - * Licensed under GNU General Public License version 2 20.7 - * 20.8 - * Author: seanhalle@yahoo.com 20.9 - * 20.10 - */ 20.11 - 20.12 -#ifndef _VMS_DEFS_MAIN_H 20.13 -#define _VMS_DEFS_MAIN_H 20.14 -#define _GNU_SOURCE 20.15 - 20.16 -//=========================== VMS-wide defs =============================== 20.17 -#include "VMS_primitive_data_types.h" 20.18 - 20.19 -#define SUCCESS 0 20.20 - 20.21 - //only after macro-expansion are the defs of writePrivQ, aso looked up 20.22 - // so these defs can be at the top, and writePrivQ defined later on.. 20.23 -#define writeVMSQ writePrivQ 20.24 -#define readVMSQ readPrivQ 20.25 -#define makeVMSQ makePrivQ 20.26 -#define numInVMSQ numInPrivQ 20.27 -#define VMSQueueStruc PrivQueueStruc 20.28 - 20.29 - 20.30 -//====================== Hardware Specific Defs ============================ 20.31 -#include "VMS_defs__HW_specific.h" 20.32 - 20.33 -//========================= Debug Related Defs ============================= 20.34 -// 20.35 -//When SEQUENTIAL is defined, VMS does sequential exe in the main thread 20.36 -// It still does co-routines and all the mechanisms are the same, it just 20.37 -// has only a single thread and animates Slvs one at a time 20.38 -//#define SEQUENTIAL 20.39 - 20.40 -//#define USE_WORK_STEALING 20.41 - 20.42 -//turns on the probe-instrumentation in the application -- when not 20.43 -// defined, the calls to the probe functions turn into comments 20.44 -//#define STATS__ENABLE_PROBES 20.45 -//#define TURN_ON_DEBUG_PROBES 20.46 - 20.47 -//These defines turn types of bug messages on and off 20.48 -// be sure debug messages are un-commented (next block of defines) 20.49 -#define dbgAppFlow TRUE /* Top level flow of application code -- general*/ 20.50 -#define dbgProbes FALSE /* for issues inside probes themselves*/ 20.51 -#define dbgB2BMaster FALSE /* in coreloop, back to back master Slvs*/ 20.52 -#define dbgRqstHdlr FALSE /* in request handler code*/ 20.53 - 20.54 -//Comment or un- the substitute half to turn on/off types of debug message 20.55 -#define DEBUG( bool, msg) \ 20.56 -// if( bool){ printf(msg); fflush(stdin);} 20.57 -#define DEBUG1( bool, msg, param) \ 20.58 -// if(bool){printf(msg, param); fflush(stdin);} 20.59 -#define DEBUG2( bool, msg, p1, p2) \ 20.60 -// if(bool) {printf(msg, p1, p2); fflush(stdin);} 20.61 - 20.62 -#define ERROR(msg) printf(msg); 20.63 -#define ERROR1(msg, param) printf(msg, param); 20.64 -#define ERROR2(msg, p1, p2) printf(msg, p1, p2); 20.65 - 20.66 -//====================== Measurement Related Defs ========================== 20.67 -// 20.68 -// 20.69 - //when STATS__TURN_ON_PROBES is defined allows using probes to measure 20.70 - // time intervals. The probes are macros that only compile to something 20.71 - // when STATS__TURN_ON_PROBES is defined. The probes are saved in the 20.72 - // master env -- but only when this is defined. 20.73 - //The TSC probes use RDTSC instr, can be unreliable, Dbl uses gettimeofday 20.74 -#define STATS__TURN_ON_PROBES 20.75 -//#define STATS__USE_TSC_PROBES 20.76 -#define STATS__USE_DBL_PROBES 20.77 - 20.78 -//================== Turn Measurement Things on and off ==================== 20.79 - 20.80 -//#define MEAS__TURN_ON_SYSTEM_MEAS 20.81 - 20.82 -/*NOTE: define MEAS__TURN_ON_MAKE_HISTS if any other MEAS__... below are*/ 20.83 -//#define MEAS__TURN_ON_MAKE_HISTS 20.84 - 20.85 -//#define MEAS__TURN_ON_SUSP_MEAS 20.86 -//#define MEAS__TURN_ON_MASTER_MEAS 20.87 -//#define MEAS__TURN_ON_PLUGIN_MEAS 20.88 -//#define MEAS__TURN_ON_MALLOC_MEAS 20.89 -//#define MEAS__TURN_ON_MASTER_LOCK_MEAS 20.90 - 20.91 - /*turn on/off subtraction of create measurements from plugin meas*/ 20.92 -//#define MEAS__TURN_ON_EXCLUDE_CREATION_TIME 20.93 - 20.94 - 20.95 - 20.96 -//================== Macros define types of meas want ===================== 20.97 - 20.98 -#ifdef MEAS__TURN_ON_SUSP_MEAS 20.99 - #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ 20.100 - uint32 preSuspTSCLow; \ 20.101 - uint32 postSuspTSCLow; 20.102 - 20.103 - #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ 20.104 - Histogram *suspLowTimeHist; \ 20.105 - Histogram *suspHighTimeHist; 20.106 - 20.107 - #define MEAS__Make_Meas_Hists_for_Susp_Meas \ 20.108 - _VMSMasterEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 20.109 - "master_low_time_hist");\ 20.110 - _VMSMasterEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 20.111 - "master_high_time_hist"); 20.112 - 20.113 - //record time stamp: compare to time-stamp recorded below 20.114 - #define MEAS__Capture_Pre_Susp_Point \ 20.115 - saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); 20.116 - 20.117 - //NOTE: only take low part of count -- do sanity check when take diff 20.118 - #define MEAS__Capture_Post_Susp_Point \ 20.119 - saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ 20.120 - addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 20.121 - _VMSMasterEnv->suspLowTimeHist ); \ 20.122 - addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 20.123 - _VMSMasterEnv->suspHighTimeHist ); 20.124 - 20.125 - #define MEAS__Print_Hists_for_Susp_Meas \ 20.126 - printHist( _VMSMasterEnv->pluginTimeHist ); 20.127 - 20.128 -#else 20.129 - #define MEAS__Insert_Susp_Meas_Fields_into_Slave 20.130 - #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv 20.131 - #define MEAS__Make_Meas_Hists_for_Susp_Meas 20.132 - #define MEAS__Capture_Pre_Susp_Point 20.133 - #define MEAS__Capture_Post_Susp_Point 20.134 - #define MEAS__Print_Hists_for_Susp_Meas 20.135 -#endif 20.136 - 20.137 -#ifdef MEAS__TURN_ON_MASTER_MEAS 20.138 - #define MEAS__Insert_Master_Meas_Fields_into_Slave \ 20.139 - uint32 startMasterTSCLow; \ 20.140 - uint32 endMasterTSCLow; 20.141 - 20.142 - #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ 20.143 - Histogram *masterLowTimeHist; \ 20.144 - Histogram *masterHighTimeHist; 20.145 - 20.146 - #define MEAS__Make_Meas_Hists_for_Master_Meas \ 20.147 - _VMSMasterEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 20.148 - "master_low_time_hist");\ 20.149 - _VMSMasterEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 20.150 - "master_high_time_hist"); 20.151 - 20.152 - //Total Master time includes one coreloop time -- just assume the core 20.153 - // loop time is same for Master as for AppSlvs, even though it may be 20.154 - // smaller due to higher predictability of the fixed jmp. 20.155 - #define MEAS__Capture_Pre_Master_Point\ 20.156 - saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); 20.157 - 20.158 - #define MEAS__Capture_Post_Master_Point \ 20.159 - saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ 20.160 - addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 20.161 - _VMSMasterEnv->masterLowTimeHist ); \ 20.162 - addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 20.163 - _VMSMasterEnv->masterHighTimeHist ); 20.164 - 20.165 - #define MEAS__Print_Hists_for_Master_Meas \ 20.166 - printHist( _VMSMasterEnv->pluginTimeHist ); 20.167 - 20.168 -#else 20.169 - #define MEAS__Insert_Master_Meas_Fields_into_Slave 20.170 - #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv 20.171 - #define MEAS__Make_Meas_Hists_for_Master_Meas 20.172 - #define MEAS__Capture_Pre_Master_Point 20.173 - #define MEAS__Capture_Post_Master_Point 20.174 - #define MEAS__Print_Hists_for_Master_Meas 20.175 -#endif 20.176 - 20.177 - 20.178 -#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS 20.179 - #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ 20.180 - Histogram *masterLockLowTimeHist; \ 20.181 - Histogram *masterLockHighTimeHist; 20.182 - 20.183 - #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ 20.184 - _VMSMasterEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ 20.185 - "master lock low time hist");\ 20.186 - _VMSMasterEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ 20.187 - "master lock high time hist"); 20.188 - 20.189 - #define MEAS__Capture_Pre_Master_Lock_Point \ 20.190 - int32 startStamp, endStamp; \ 20.191 - saveLowTimeStampCountInto( startStamp ); 20.192 - 20.193 - #define MEAS__Capture_Post_Master_Lock_Point \ 20.194 - saveLowTimeStampCountInto( endStamp ); \ 20.195 - addIntervalToHist( startStamp, endStamp,\ 20.196 - _VMSMasterEnv->masterLockLowTimeHist ); \ 20.197 - addIntervalToHist( startStamp, endStamp,\ 20.198 - _VMSMasterEnv->masterLockHighTimeHist ); 20.199 - 20.200 - #define MEAS__Print_Hists_for_Master_Lock_Meas \ 20.201 - printHist( _VMSMasterEnv->masterLockLowTimeHist ); \ 20.202 - printHist( _VMSMasterEnv->masterLockHighTimeHist ); 20.203 - 20.204 -#else 20.205 - #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv 20.206 - #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas 20.207 - #define MEAS__Capture_Pre_Master_Lock_Point 20.208 - #define MEAS__Capture_Post_Master_Lock_Point 20.209 - #define MEAS__Print_Hists_for_Master_Lock_Meas 20.210 -#endif 20.211 - 20.212 - 20.213 -#ifdef MEAS__TURN_ON_MALLOC_MEAS 20.214 - #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ 20.215 - Histogram *mallocTimeHist; \ 20.216 - Histogram *freeTimeHist; 20.217 - 20.218 - #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ 20.219 - _VMSMasterEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 20.220 - "malloc_time_hist");\ 20.221 - _VMSMasterEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 20.222 - "free_time_hist"); 20.223 - 20.224 - #define MEAS__Capture_Pre_Malloc_Point \ 20.225 - int32 startStamp, endStamp; \ 20.226 - saveLowTimeStampCountInto( startStamp ); 20.227 - 20.228 - #define MEAS__Capture_Post_Malloc_Point \ 20.229 - saveLowTimeStampCountInto( endStamp ); \ 20.230 - addIntervalToHist( startStamp, endStamp,\ 20.231 - _VMSMasterEnv->mallocTimeHist ); 20.232 - 20.233 - #define MEAS__Capture_Pre_Free_Point \ 20.234 - int32 startStamp, endStamp; \ 20.235 - saveLowTimeStampCountInto( startStamp ); 20.236 - 20.237 - #define MEAS__Capture_Post_Free_Point \ 20.238 - saveLowTimeStampCountInto( endStamp ); \ 20.239 - addIntervalToHist( startStamp, endStamp,\ 20.240 - _VMSMasterEnv->freeTimeHist ); 20.241 - 20.242 - #define MEAS__Print_Hists_for_Malloc_Meas \ 20.243 - printHist( _VMSMasterEnv->mallocTimeHist ); \ 20.244 - saveHistToFile( _VMSMasterEnv->mallocTimeHist ); \ 20.245 - printHist( _VMSMasterEnv->freeTimeHist ); \ 20.246 - saveHistToFile( _VMSMasterEnv->freeTimeHist ); \ 20.247 - freeHistExt( _VMSMasterEnv->mallocTimeHist ); \ 20.248 - freeHistExt( _VMSMasterEnv->freeTimeHist ); 20.249 - 20.250 -#else 20.251 - #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv 20.252 - #define MEAS__Make_Meas_Hists_for_Malloc_Meas 20.253 - #define MEAS__Capture_Pre_Malloc_Point 20.254 - #define MEAS__Capture_Post_Malloc_Point 20.255 - #define MEAS__Capture_Pre_Free_Point 20.256 - #define MEAS__Capture_Post_Free_Point 20.257 - #define MEAS__Print_Hists_for_Malloc_Meas 20.258 -#endif 20.259 - 20.260 - 20.261 -#ifdef MEAS__TURN_ON_SYSTEM_MEAS 20.262 - #define MEAS__Insert_System_Meas_Fields_into_Slave \ 20.263 - TSCountLowHigh startSusp; \ 20.264 - uint64 totalSuspCycles; \ 20.265 - uint32 numGoodSusp; 20.266 - 20.267 - #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ 20.268 - TSCountLowHigh startMaster; \ 20.269 - uint64 totalMasterCycles; \ 20.270 - uint32 numMasterAnimations; \ 20.271 - TSCountLowHigh startReqHdlr; \ 20.272 - uint64 totalPluginCycles; \ 20.273 - uint32 numPluginAnimations; \ 20.274 - uint64 cyclesTillStartMasterLoop; \ 20.275 - TSCountLowHigh endMasterLoop; 20.276 - 20.277 -#else 20.278 - #define MEAS__Insert_System_Meas_Fields_into_Slave 20.279 - #define MEAS__Insert_System_Meas_Fields_into_MasterEnv 20.280 -#endif 20.281 - 20.282 - 20.283 -/*This macro's a bit weird -- the same macro is defined in three different 20.284 - * ways, depending upon which defines are turned on 20.285 - *That's because added the system meas, which interferes with plugin meas, 20.286 - * but don't want to make plugin meas stop working.. this is compromise 20.287 - */ 20.288 -#ifdef MEAS__TURN_ON_PLUGIN_MEAS 20.289 - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ 20.290 - Histogram *reqHdlrLowTimeHist; \ 20.291 - Histogram *reqHdlrHighTimeHist; 20.292 - 20.293 - #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ 20.294 - _VMSMasterEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 20.295 - "plugin_low_time_hist");\ 20.296 - _VMSMasterEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 20.297 - "plugin_high_time_hist"); 20.298 - 20.299 - #define Meas_startReqHdlr \ 20.300 - int32 startStamp1, endStamp1; \ 20.301 - saveLowTimeStampCountInto( startStamp1 ); 20.302 - 20.303 - #define Meas_endReqHdlr \ 20.304 - saveLowTimeStampCountInto( endStamp1 ); \ 20.305 - addIntervalToHist( startStamp1, endStamp1, \ 20.306 - _VMSMasterEnv->reqHdlrLowTimeHist ); \ 20.307 - addIntervalToHist( startStamp1, endStamp1, \ 20.308 - _VMSMasterEnv->reqHdlrHighTimeHist ); 20.309 - 20.310 - #define MEAS__Print_Hists_for_Plugin_Meas \ 20.311 - printHist( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 20.312 - saveHistToFile( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 20.313 - printHist( _VMSMasterEnv->reqHdlrHighTimeHist ); \ 20.314 - saveHistToFile( _VMSMasterEnv->reqHdlrHighTimeHist ); \ 20.315 - freeHistExt( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 20.316 - freeHistExt( _VMSMasterEnv->reqHdlrHighTimeHist ); 20.317 - 20.318 -#elif defined MEAS__TURN_ON_SYSTEM_MEAS 20.319 - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv 20.320 - 20.321 - #define MEAS__Make_Meas_Hists_for_Plugin_Meas 20.322 - 20.323 - #define Meas_startMasterLoop \ 20.324 - TSCountLowHigh startStamp1, endStamp1; \ 20.325 - saveTSCLowHigh( endStamp1 ); \ 20.326 - _VMSMasterEnv->cyclesTillStartMasterLoop = \ 20.327 - endStamp1.longVal - masterVP->startSusp.longVal; 20.328 - 20.329 - #define Meas_endMasterLoop \ 20.330 - saveTSCLowHigh( startStamp1 ); \ 20.331 - _VMSMasterEnv->endMasterLoop.longVal = startStamp1.longVal; 20.332 - 20.333 - #define Meas_startReqHdlr \ 20.334 - saveTSCLowHigh( startStamp1 ); \ 20.335 - _VMSMasterEnv->startReqHdlr.longVal = startStamp1.longVal; 20.336 - 20.337 - #define Meas_endReqHdlr 20.338 - 20.339 - #define MEAS__Print_Hists_for_Plugin_Meas 20.340 - 20.341 -#else 20.342 - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv 20.343 - #define MEAS__Make_Meas_Hists_for_Plugin_Meas 20.344 - #define Meas_startMasterLoop 20.345 - #define Meas_endMasterLoop 20.346 - #define Meas_startReqHdlr 20.347 - #define Meas_endReqHdlr 20.348 - #define MEAS__Print_Hists_for_Plugin_Meas 20.349 -#endif 20.350 - 20.351 - 20.352 -//Experiment in two-step macros -- if doesn't work, insert each separately 20.353 -#define MEAS__Insert_Meas_Fields_into_Slave \ 20.354 - MEAS__Insert_Susp_Meas_Fields_into_Slave \ 20.355 - MEAS__Insert_Master_Meas_Fields_into_Slave \ 20.356 - MEAS__Insert_System_Meas_Fields_into_Slave 20.357 - 20.358 - 20.359 -//====================== Histogram Macros -- Create ======================== 20.360 -// 20.361 -// 20.362 - 20.363 -//The language implementation should include a definition of this macro, 20.364 -// which creates all the histograms the language uses to collect measurements 20.365 -// of plugin operation -- so, if the language didn't define it, must 20.366 -// define it here (as empty), to avoid compile error 20.367 -#ifndef MEAS__Make_Meas_Hists_for_Language 20.368 -#define MEAS__Make_Meas_Hists_for_Language() /*consume parens!*/ 20.369 -#endif 20.370 - 20.371 - 20.372 -#ifdef MEAS__TURN_ON_MAKE_HISTS 20.373 - #define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ 20.374 - makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \ 20.375 - _VMSMasterEnv->measHists[idx] = \ 20.376 - makeFixedBinHist( numBins, startVal, binWidth, name ); 20.377 -#else 20.378 - #define makeAMeasHist( idx, name, numBins, startVal, binWidth ) 20.379 -#endif 20.380 - 20.381 -//============================== Probes =================================== 20.382 - 20.383 - 20.384 -//=========================================================================== 20.385 -#endif /* _VMS_DEFS_H */ 20.386 -
21.1 --- a/probes.c Sun Mar 04 14:26:35 2012 -0800 21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 21.3 @@ -1,270 +0,0 @@ 21.4 -/* 21.5 - * Copyright 2010 OpenSourceStewardshipFoundation 21.6 - * 21.7 - * Licensed under BSD 21.8 - */ 21.9 - 21.10 -#include <stdio.h> 21.11 -#include <malloc.h> 21.12 -#include <sys/time.h> 21.13 - 21.14 -#include "VMS.h" 21.15 - 21.16 - 21.17 - 21.18 -//==================== Probes ================= 21.19 -/* 21.20 - * In practice, probe operations are called from the app, from inside slaves 21.21 - * -- so have to be sure each probe is single-Slv owned, and be sure that 21.22 - * any place common structures are modified it's done inside the master. 21.23 - * So -- the only place common structures are modified is during creation. 21.24 - * after that, all mods are to individual instances. 21.25 - * 21.26 - * Thniking perhaps should change the semantics to be that probes are 21.27 - * attached to the virtual processor -- and then everything is guaranteed 21.28 - * to be isolated -- except then can't take any intervals that span Slvs, 21.29 - * and would have to transfer the probes to Master env when Slv dissipates.. 21.30 - * gets messy.. 21.31 - * 21.32 - * For now, just making so that probe creation causes a suspend, so that 21.33 - * the dynamic array in the master env is only modified from the master 21.34 - * 21.35 - */ 21.36 - 21.37 -//============================ Helpers =========================== 21.38 -inline void 21.39 -doNothing() 21.40 - { 21.41 - } 21.42 - 21.43 - 21.44 -IntervalProbe * 21.45 -create_generic_probe( char *nameStr, SlaveVP *animSlv ) 21.46 - { 21.47 - VMSSemReq reqData; 21.48 - 21.49 - reqData.reqType = createProbe; 21.50 - reqData.nameStr = nameStr; 21.51 - 21.52 - VMS_WL__send_VMSSem_request( &reqData, animSlv ); 21.53 - 21.54 - return animSlv->dataRetFromReq; 21.55 - } 21.56 - 21.57 -/*Use this version from outside VMS -- it uses external malloc, and modifies 21.58 - * dynamic array, so can't be animated in a slave Slv 21.59 - */ 21.60 -IntervalProbe * 21.61 -ext__create_generic_probe( char *nameStr ) 21.62 - { IntervalProbe *newProbe; 21.63 - int32 nameLen; 21.64 - 21.65 - newProbe = malloc( sizeof(IntervalProbe) ); 21.66 - nameLen = strlen( nameStr ); 21.67 - newProbe->nameStr = malloc( nameLen ); 21.68 - memcpy( newProbe->nameStr, nameStr, nameLen ); 21.69 - newProbe->hist = NULL; 21.70 - newProbe->schedChoiceWasRecorded = FALSE; 21.71 - newProbe->probeID = 21.72 - addToDynArray( newProbe, _VMSMasterEnv->dynIntervalProbesInfo ); 21.73 - 21.74 - return newProbe; 21.75 - } 21.76 - 21.77 -//============================ Fns def in header ======================= 21.78 - 21.79 -int32 21.80 -VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ) 21.81 - { IntervalProbe *newProbe; 21.82 - 21.83 - newProbe = create_generic_probe( nameStr, animSlv ); 21.84 - 21.85 - return newProbe->probeID; 21.86 - } 21.87 - 21.88 -int32 21.89 -VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 21.90 - float64 binWidth, char *nameStr, SlaveVP *animSlv ) 21.91 - { IntervalProbe *newProbe; 21.92 - DblHist *hist; 21.93 - 21.94 - newProbe = create_generic_probe( nameStr, animSlv ); 21.95 - 21.96 - hist = makeDblHistogram( numBins, startValue, binWidth ); 21.97 - newProbe->hist = hist; 21.98 - return newProbe->probeID; 21.99 - } 21.100 - 21.101 - 21.102 -int32 21.103 -VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv) 21.104 - { IntervalProbe *newProbe; 21.105 - struct timeval *startStamp; 21.106 - float64 startSecs; 21.107 - 21.108 - newProbe = create_generic_probe( nameStr, animSlv ); 21.109 - newProbe->endSecs = 0; 21.110 - 21.111 - gettimeofday( &(newProbe->startStamp), NULL); 21.112 - 21.113 - //turn into a double 21.114 - startStamp = &(newProbe->startStamp); 21.115 - startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); 21.116 - newProbe->startSecs = startSecs; 21.117 - 21.118 - return newProbe->probeID; 21.119 - } 21.120 - 21.121 -int32 21.122 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ) 21.123 - { IntervalProbe *newProbe; 21.124 - struct timeval *startStamp; 21.125 - float64 startSecs; 21.126 - 21.127 - newProbe = ext__create_generic_probe( nameStr ); 21.128 - newProbe->endSecs = 0; 21.129 - 21.130 - gettimeofday( &(newProbe->startStamp), NULL); 21.131 - 21.132 - //turn into a double 21.133 - startStamp = &(newProbe->startStamp); 21.134 - startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); 21.135 - newProbe->startSecs = startSecs; 21.136 - 21.137 - return newProbe->probeID; 21.138 - } 21.139 - 21.140 - 21.141 -/*Only call from inside master or main startup/shutdown thread 21.142 - */ 21.143 -void 21.144 -VMS_impl__free_probe( IntervalProbe *probe ) 21.145 - { if( probe->hist != NULL ) freeDblHist( probe->hist ); 21.146 - if( probe->nameStr != NULL) VMS_int__free( probe->nameStr ); 21.147 - VMS_int__free( probe ); 21.148 - } 21.149 - 21.150 - 21.151 -void 21.152 -VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ) 21.153 - { IntervalProbe *probe; 21.154 - 21.155 - //TODO: fix this To be in Master -- race condition 21.156 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 21.157 - 21.158 - addValueIntoTable(probe->nameStr, probe, _VMSMasterEnv->probeNameHashTbl); 21.159 - } 21.160 - 21.161 - 21.162 -IntervalProbe * 21.163 -VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ) 21.164 - { 21.165 - //TODO: fix this To be in Master -- race condition 21.166 - return getValueFromTable( probeName, _VMSMasterEnv->probeNameHashTbl ); 21.167 - } 21.168 - 21.169 - 21.170 -/*Everything is local to the animating procr, so no need for request, do 21.171 - * work locally, in the anim Slv 21.172 - */ 21.173 -void 21.174 -VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animatingSlv ) 21.175 - { IntervalProbe *probe; 21.176 - 21.177 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 21.178 - probe->schedChoiceWasRecorded = TRUE; 21.179 - probe->coreNum = animatingSlv->coreAnimatedBy; 21.180 - probe->slaveID = animatingSlv->procrID; 21.181 - probe->slaveCreateSecs = animatingSlv->createPtInSecs; 21.182 - } 21.183 - 21.184 -/*Everything is local to the animating procr, so no need for request, do 21.185 - * work locally, in the anim Slv 21.186 - */ 21.187 -void 21.188 -VMS_impl__record_interval_start_in_probe( int32 probeID ) 21.189 - { IntervalProbe *probe; 21.190 - 21.191 - DEBUG( dbgProbes, "record start of interval\n" ) 21.192 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 21.193 - probe->startStamp = getTSCount(); 21.194 - } 21.195 - 21.196 - 21.197 -/*Everything is local to the animating procr, so no need for request, do 21.198 - * work locally, in the anim Slv 21.199 - * 21.200 - *This should be safe to run inside SlaveVP -- weird behavior will be due 21.201 - * to the logical error of having more than one interval open in overlapped. 21.202 - */ 21.203 -void 21.204 -VMS_impl__record_interval_end_in_probe( int32 probeID ) 21.205 - { IntervalProbe *probe; 21.206 - TSCount endStamp; 21.207 - 21.208 - endStamp = getTSCount(); 21.209 - 21.210 - DEBUG( dbgProbes, "record end of interval\n" ) 21.211 - 21.212 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 21.213 - probe->endStamp = endStamp; 21.214 - 21.215 - if( probe->hist != NULL ) 21.216 - { TSCount interval = probe->endStamp - probe->startStamp; 21.217 - //if the interval is sane, then add to histogram 21.218 - if( interval < probe->hist->endOfRange * 10 ) 21.219 - addToFloatHist( interval, probe->hist ); 21.220 - } 21.221 - } 21.222 - 21.223 - 21.224 -void 21.225 -print_probe_helper( IntervalProbe *probe ) 21.226 - { 21.227 - printf( "\nprobe: %s, ", probe->nameStr ); 21.228 - 21.229 - 21.230 - if( probe->schedChoiceWasRecorded ) 21.231 - { printf( "coreNum: %d, procrID: %d, procrCreated: %0.6f | ", 21.232 - probe->coreNum, probe->slaveID, probe->slaveCreateSecs ); 21.233 - } 21.234 - 21.235 - if( probe->endSecs == 0 ) //just a single point in time 21.236 - { 21.237 - printf( " time point: %.6f\n", 21.238 - probe->startSecs - _VMSMasterEnv->createPtInSecs ); 21.239 - } 21.240 - else if( probe->hist == NULL ) //just an interval 21.241 - { 21.242 - printf( " startSecs: %.6f interval: %.6f\n", 21.243 - (probe->startSecs - _VMSMasterEnv->createPtInSecs), probe->interval); 21.244 - } 21.245 - else //a full histogram of intervals 21.246 - { 21.247 - printDblHist( probe->hist ); 21.248 - } 21.249 - } 21.250 - 21.251 -//TODO: change so pass around pointer to probe instead of its array-index.. 21.252 -// will eliminate chance for timing of resize to cause problems with the 21.253 -// lookup -- even though don't think it actually can cause problems.. 21.254 -// there's no need to pass index around -- have hash table for names, and 21.255 -// only need it once, then have ptr to probe.. the thing about enum the 21.256 -// index and use that as name is clunky in practice -- just hash. 21.257 -void 21.258 -VMS_impl__print_stats_of_probe( int32 probeID ) 21.259 - { IntervalProbe *probe; 21.260 - 21.261 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 21.262 - 21.263 - print_probe_helper( probe ); 21.264 - } 21.265 - 21.266 - 21.267 -void 21.268 -VMS_impl__print_stats_of_all_probes() 21.269 - { 21.270 - forAllInDynArrayDo( _VMSMasterEnv->dynIntervalProbesInfo, 21.271 - &VMS_impl__print_stats_of_probe ); 21.272 - fflush( stdout ); 21.273 - }
22.1 --- a/probes.h Sun Mar 04 14:26:35 2012 -0800 22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 22.3 @@ -1,182 +0,0 @@ 22.4 -/* 22.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 22.6 - * Licensed under GNU General Public License version 2 22.7 - * 22.8 - * Author: seanhalle@yahoo.com 22.9 - * 22.10 - */ 22.11 - 22.12 -#ifndef _PROBES_H 22.13 -#define _PROBES_H 22.14 -#define _GNU_SOURCE 22.15 - 22.16 -#include "VMS_primitive_data_types.h" 22.17 - 22.18 -#include <sys/time.h> 22.19 - 22.20 -/*Note on order of include files: 22.21 - * This file relies on #defines that appear in other files.. 22.22 - */ 22.23 - 22.24 - 22.25 -//typedef struct _IntervalProbe IntervalProbe; //in VMS.h 22.26 - 22.27 -struct _IntervalProbe 22.28 - { 22.29 - char *nameStr; 22.30 - int32 probeID; 22.31 - 22.32 - int32 schedChoiceWasRecorded; 22.33 - int32 coreNum; 22.34 - int32 slaveID; 22.35 - float64 slaveCreateSecs; 22.36 - 22.37 - // #ifdef STATS__USE_TSC_PROBES 22.38 - TSCount startStamp; 22.39 - TSCount endStamp; 22.40 -// #else 22.41 -// struct timeval startStamp; 22.42 -// struct timeval endStamp; 22.43 -// #endif 22.44 - float64 startSecs; 22.45 - float64 endSecs; 22.46 - float64 interval; 22.47 - DblHist *hist;//if NULL, then is single interval probe 22.48 - }; 22.49 - 22.50 - 22.51 -int32 22.52 -VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ); 22.53 - 22.54 -int32 22.55 -VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 22.56 - float64 binWidth, char *nameStr, SlaveVP *animSlv ); 22.57 - 22.58 -int32 22.59 -VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv); 22.60 - 22.61 -int32 22.62 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); 22.63 - 22.64 -void 22.65 -VMS_impl__free_probe( IntervalProbe *probe ); 22.66 - 22.67 -void 22.68 -VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ); 22.69 - 22.70 -IntervalProbe * 22.71 -VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ); 22.72 - 22.73 -void 22.74 -VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animSlv ); 22.75 - 22.76 -void 22.77 -VMS_impl__record_interval_start_in_probe( int32 probeID ); 22.78 - 22.79 -void 22.80 -VMS_impl__record_interval_end_in_probe( int32 probeID ); 22.81 - 22.82 -void 22.83 -VMS_impl__print_stats_of_probe( int32 probeID ); 22.84 - 22.85 -void 22.86 -VMS_impl__print_stats_of_all_probes(); 22.87 - 22.88 - 22.89 -//======================== Probes ============================= 22.90 -// 22.91 -// Use macros to allow turning probes off with a #define switch 22.92 -// This means probes have zero impact on performance when off 22.93 -//============================================================= 22.94 -#define VMS_App__record_time_point_into_new_probe VMS_WL__record_time_point_into_new_probe 22.95 -#define VMS_ext__record_time_point_into_new_probe 22.96 -#define VMS_App__create_single_interval_probe VMS_WL__create_single_interval_probe 22.97 -#define VMS_App__create_histogram_probe VMS_WL__create_histogram_probe 22.98 -#define VMS_App__index_probe_by_its_name VMS_WL__index_probe_by_its_name 22.99 -#define VMS_App__get_probe_by_name VMS_WL__get_probe_by_name 22.100 -#define VMS_App__record_sched_choice_into_probe VMS_WL__record_sched_choice_into_probe 22.101 -#define VMS_App__record_interval_start_in_probe VMS_WL__record_interval_start_in_probe 22.102 -#define VMS_App__record_interval_end_in_probe VMS_WL__record_interval_end_in_probe 22.103 -#define VMS_App__print_stats_of_probe VMS_WL__print_stats_of_probe 22.104 -#define VMS_App__print_stats_of_all_probes VMS_WL__print_stats_of_all_probes 22.105 - 22.106 -#ifdef STATS__ENABLE_PROBES 22.107 -#define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) \ 22.108 - VMS_impl__record_time_point_in_new_probe( nameStr, animSlv ) 22.109 - 22.110 -#define VMS_ext__record_time_point_into_new_probe( nameStr ) \ 22.111 - VMS_ext_impl__record_time_point_into_new_probe( nameStr ) 22.112 - 22.113 -#define VMS_WL__create_single_interval_probe( nameStr, animSlv ) \ 22.114 - VMS_impl__create_single_interval_probe( nameStr, animSlv ) 22.115 - 22.116 -#define VMS_WL__create_histogram_probe( numBins, startValue, \ 22.117 - binWidth, nameStr, animSlv ) \ 22.118 - VMS_impl__create_histogram_probe( numBins, startValue, \ 22.119 - binWidth, nameStr, animSlv ) 22.120 -#define VMS_int__free_probe( probe ) \ 22.121 - VMS_impl__free_probe( probe ) 22.122 - 22.123 -#define VMS_WL__index_probe_by_its_name( probeID, animSlv ) \ 22.124 - VMS_impl__index_probe_by_its_name( probeID, animSlv ) 22.125 - 22.126 -#define VMS_WL__get_probe_by_name( probeID, animSlv ) \ 22.127 - VMS_impl__get_probe_by_name( probeName, animSlv ) 22.128 - 22.129 -#define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) \ 22.130 - VMS_impl__record_sched_choice_into_probe( probeID, animSlv ) 22.131 - 22.132 -#define VMS_WL__record_interval_start_in_probe( probeID ) \ 22.133 - VMS_impl__record_interval_start_in_probe( probeID ) 22.134 - 22.135 -#define VMS_WL__record_interval_end_in_probe( probeID ) \ 22.136 - VMS_impl__record_interval_end_in_probe( probeID ) 22.137 - 22.138 -#define VMS_WL__print_stats_of_probe( probeID ) \ 22.139 - VMS_impl__print_stats_of_probe( probeID ) 22.140 - 22.141 -#define VMS_WL__print_stats_of_all_probes() \ 22.142 - VMS_impl__print_stats_of_all_probes() 22.143 - 22.144 - 22.145 -#else 22.146 -#define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) \ 22.147 - 0 /* do nothing */ 22.148 - 22.149 -#define VMS_ext__record_time_point_into_new_probe( nameStr ) \ 22.150 - 0 /* do nothing */ 22.151 - 22.152 - 22.153 -#define VMS_WL__create_single_interval_probe( nameStr, animSlv ) \ 22.154 - 0 /* do nothing */ 22.155 - 22.156 - 22.157 -#define VMS_WL__create_histogram_probe( numBins, startValue, \ 22.158 - binWidth, nameStr, animSlv ) \ 22.159 - 0 /* do nothing */ 22.160 - 22.161 -#define VMS_WL__index_probe_by_its_name( probeID, animSlv ) \ 22.162 - /* do nothing */ 22.163 - 22.164 -#define VMS_WL__get_probe_by_name( probeID, animSlv ) \ 22.165 - NULL /* do nothing */ 22.166 - 22.167 -#define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) \ 22.168 - /* do nothing */ 22.169 - 22.170 -#define VMS_WL__record_interval_start_in_probe( probeID ) \ 22.171 - /* do nothing */ 22.172 - 22.173 -#define VMS_WL__record_interval_end_in_probe( probeID ) \ 22.174 - /* do nothing */ 22.175 - 22.176 -#define VMS_WL__print_stats_of_probe( probeID ) \ 22.177 - ; /* do nothing */ 22.178 - 22.179 -#define VMS_WL__print_stats_of_all_probes() \ 22.180 - ;/* do nothing */ 22.181 - 22.182 -#endif /* defined STATS__ENABLE_PROBES */ 22.183 - 22.184 -#endif /* _PROBES_H */ 22.185 -
23.1 --- a/vmalloc.c Sun Mar 04 14:26:35 2012 -0800 23.2 +++ b/vmalloc.c Wed Mar 07 22:53:50 2012 -0800 23.3 @@ -260,13 +260,8 @@ 23.4 VMS_int__free( void *ptrToFree ) 23.5 { 23.6 23.7 - //============================= MEASUREMENT STUFF ======================== 23.8 - #ifdef MEAS__TIME_MALLOC 23.9 - int32 startStamp, endStamp; 23.10 - saveLowTimeStampCountInto( startStamp ); 23.11 - #endif 23.12 - //======================================================================== 23.13 - 23.14 + MEAS__Capture_Pre_Free_Point; 23.15 + 23.16 MallocArrays* freeLists = _VMSMasterEnv->freeLists; 23.17 MallocProlog *chunkToFree = (MallocProlog*)ptrToFree - 1; 23.18 uint32 containerIdx; 23.19 @@ -307,13 +302,7 @@ 23.20 freeLists->bigChunksSearchVector[1] |= (uint64)1 << (containerIdx-64); 23.21 } 23.22 23.23 - //============================= MEASUREMENT STUFF ======================== 23.24 - #ifdef MEAS__TIME_MALLOC 23.25 - saveLowTimeStampCountInto( endStamp ); 23.26 - addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->freeTimeHist ); 23.27 - #endif 23.28 - //======================================================================== 23.29 - 23.30 + MEAS__Capture_Post_Free_Point; 23.31 } 23.32 23.33 /*
24.1 --- a/vutilities.c Sun Mar 04 14:26:35 2012 -0800 24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 24.3 @@ -1,25 +0,0 @@ 24.4 -/* 24.5 - * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 24.6 - * Licensed under GNU General Public License version 2 24.7 - * 24.8 - * Author: seanhalle@yahoo.com 24.9 - * 24.10 - * Created on November 14, 2009, 9:07 PM 24.11 - */ 24.12 - 24.13 -#include <malloc.h> 24.14 -#include <stdlib.h> 24.15 - 24.16 -#include "VMS.h" 24.17 - 24.18 - 24.19 -inline char * 24.20 -VMS_int__strDup( char *str ) 24.21 - { char *retStr; 24.22 - 24.23 - retStr = VMS_int__malloc( strlen(str) + 1 ); 24.24 - if( str == NULL ) return str; 24.25 - strcpy( retStr, str ); 24.26 - 24.27 - return retStr; 24.28 - }
25.1 --- a/vutilities.h Sun Mar 04 14:26:35 2012 -0800 25.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 25.3 @@ -1,20 +0,0 @@ 25.4 -/* 25.5 - * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 25.6 - * Licensed under GNU General Public License version 2 25.7 - * 25.8 - * Author: seanhalle@yahoo.com 25.9 - * 25.10 - * Created on November 14, 2009, 9:07 PM 25.11 - */ 25.12 - 25.13 - 25.14 -#ifndef _VUTILITIES_H 25.15 -#define _VUTILITIES_H 25.16 - 25.17 -#include <string.h> 25.18 -#include "VMS_primitive_data_types.h" 25.19 - 25.20 -inline char * 25.21 -VMS_int__strDup( char *str ); 25.22 - 25.23 -#endif
