Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 223:b0b93147adfb Common_Ancestor
More rearrangement -- have "Services_Offered_by_VMS" directory now, w/Debug etc
author | Some Random Person <seanhalle@yahoo.com> |
---|---|
date | Tue, 13 Mar 2012 18:28:04 -0700 |
parents | c88ce1db91ef |
children | efcc6331a2a2 |
files | Defines/VMS_defs.h Defines/VMS_defs__DEBUG.h Defines/VMS_defs__MEAS.h Defines/VMS_defs__lang_specific.h Defines/VMS_defs__main.h Probes/probes.c Probes/probes.h SchedulingMaster.c Services_Offered_by_VMS/Debugging/DEBUG__macros.h Services_Offered_by_VMS/Lang_Constructs/VMS_Lang.h Services_Offered_by_VMS/Measurement_and_Stats/MEAS__macros.h Services_Offered_by_VMS/Measurement_and_Stats/probes.c Services_Offered_by_VMS/Measurement_and_Stats/probes.h Services_Offered_by_VMS/Memory_Handling/vmalloc.c Services_Offered_by_VMS/Memory_Handling/vmalloc.h VMS.h VMS__int.c VMS__startup_and_shutdown.c vmalloc.c vmalloc.h |
diffstat | 20 files changed, 1441 insertions(+), 1543 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Defines/VMS_defs.h Tue Mar 13 18:28:04 2012 -0700 1.3 @@ -0,0 +1,43 @@ 1.4 +/* 1.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 1.6 + * Licensed under GNU General Public License version 2 1.7 + * 1.8 + * Author: seanhalle@yahoo.com 1.9 + * 1.10 + */ 1.11 + 1.12 +#ifndef _VMS_DEFS_MAIN_H 1.13 +#define _VMS_DEFS_MAIN_H 1.14 +#define _GNU_SOURCE 1.15 + 1.16 +//=========================== VMS-wide defs =============================== 1.17 + 1.18 +#define SUCCESS 0 1.19 + 1.20 + //only after macro-expansion are the defs of writePrivQ, aso looked up 1.21 + // so these defs can be at the top, and writePrivQ defined later on.. 1.22 +#define writeVMSQ writePrivQ 1.23 +#define readVMSQ readPrivQ 1.24 +#define makeVMSQ makePrivQ 1.25 +#define numInVMSQ numInPrivQ 1.26 +#define VMSQueueStruc PrivQueueStruc 1.27 + 1.28 + 1.29 +/*The language should re-define this, but need a default in case it doesn't*/ 1.30 +#ifndef _LANG_NAME_ 1.31 +#define _LANG_NAME_ "" 1.32 +#endif 1.33 + 1.34 +//====================== Hardware Constants ============================ 1.35 +#include "VMS_defs__HW_constants.h" 1.36 + 1.37 +//====================== Macros ====================== 1.38 + //for turning macros and other VMS features on and off 1.39 +#include "VMS_defs__turn_on_and_off.h" 1.40 + 1.41 +#include "../Services_Offered_by_VMS/Debugging/DEBUG__macros.h" 1.42 +#include "../Services_Offered_by_VMS/Measurement_and_Stats/MEAS__macros.h" 1.43 + 1.44 +//=========================================================================== 1.45 +#endif /* */ 1.46 +
2.1 --- a/Defines/VMS_defs__DEBUG.h Tue Mar 13 10:02:06 2012 -0700 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,35 +0,0 @@ 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_Print( bool, msg) \ 2.20 - if( bool){ printf(msg); fflush(stdin);} 2.21 - #define DEBUG_Print1( bool, msg, param) \ 2.22 - if(bool){printf(msg, param); fflush(stdin);} 2.23 - #define DEBUG_Print2( bool, msg, p1, p2) \ 2.24 - if(bool) {printf(msg, p1, p2); fflush(stdin);} 2.25 -#else 2.26 - #define DEBUG_Print( bool, msg) 2.27 - #define DEBUG_Print1( bool, msg, param) 2.28 - #define DEBUG_Print2( 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 --- a/Defines/VMS_defs__MEAS.h Tue Mar 13 10:02:06 2012 -0700 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,325 +0,0 @@ 3.4 -/* 3.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 3.6 - * Licensed under GNU General Public License version 2 3.7 - * 3.8 - * Author: seanhalle@yahoo.com 3.9 - * 3.10 - */ 3.11 - 3.12 -#ifndef _VMS_DEFS_MEAS_H 3.13 -#define _VMS_DEFS_MEAS_H 3.14 -#define _GNU_SOURCE 3.15 - 3.16 -//================== Macros define types of meas want ===================== 3.17 -// 3.18 -/*Generic measurement macro -- has name-space collision potential, which 3.19 - * compiler will catch.. so only use one pair inside a given set of 3.20 - * curly braces. 3.21 - */ 3.22 -//TODO: finish generic capture interval in hist 3.23 -enum histograms 3.24 - { generic1 3.25 - }; 3.26 - #define MEAS__Capture_Pre_Point \ 3.27 - int32 startStamp, endStamp; \ 3.28 - saveLowTimeStampCountInto( startStamp ); 3.29 - 3.30 - #define MEAS__Capture_Post_Point( histName ) \ 3.31 - saveLowTimeStampCountInto( endStamp ); \ 3.32 - addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->histName ); 3.33 - 3.34 - 3.35 - 3.36 - 3.37 -//================== Macros define types of meas want ===================== 3.38 - 3.39 -#ifdef MEAS__TURN_ON_SUSP_MEAS 3.40 - #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ 3.41 - uint32 preSuspTSCLow; \ 3.42 - uint32 postSuspTSCLow; 3.43 - 3.44 - #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ 3.45 - Histogram *suspLowTimeHist; \ 3.46 - Histogram *suspHighTimeHist; 3.47 - 3.48 - #define MEAS__Make_Meas_Hists_for_Susp_Meas \ 3.49 - _VMSMasterEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 3.50 - "master_low_time_hist");\ 3.51 - _VMSMasterEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 3.52 - "master_high_time_hist"); 3.53 - 3.54 - //record time stamp: compare to time-stamp recorded below 3.55 - #define MEAS__Capture_Pre_Susp_Point \ 3.56 - saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); 3.57 - 3.58 - //NOTE: only take low part of count -- do sanity check when take diff 3.59 - #define MEAS__Capture_Post_Susp_Point \ 3.60 - saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ 3.61 - addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 3.62 - _VMSMasterEnv->suspLowTimeHist ); \ 3.63 - addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 3.64 - _VMSMasterEnv->suspHighTimeHist ); 3.65 - 3.66 - #define MEAS__Print_Hists_for_Susp_Meas \ 3.67 - printHist( _VMSMasterEnv->pluginTimeHist ); 3.68 - 3.69 -#else 3.70 - #define MEAS__Insert_Susp_Meas_Fields_into_Slave 3.71 - #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv 3.72 - #define MEAS__Make_Meas_Hists_for_Susp_Meas 3.73 - #define MEAS__Capture_Pre_Susp_Point 3.74 - #define MEAS__Capture_Post_Susp_Point 3.75 - #define MEAS__Print_Hists_for_Susp_Meas 3.76 -#endif 3.77 - 3.78 -#ifdef MEAS__TURN_ON_MASTER_MEAS 3.79 - #define MEAS__Insert_Master_Meas_Fields_into_Slave \ 3.80 - uint32 startMasterTSCLow; \ 3.81 - uint32 endMasterTSCLow; 3.82 - 3.83 - #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ 3.84 - Histogram *masterLowTimeHist; \ 3.85 - Histogram *masterHighTimeHist; 3.86 - 3.87 - #define MEAS__Make_Meas_Hists_for_Master_Meas \ 3.88 - _VMSMasterEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 3.89 - "master_low_time_hist");\ 3.90 - _VMSMasterEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 3.91 - "master_high_time_hist"); 3.92 - 3.93 - //Total Master time includes one coreloop time -- just assume the core 3.94 - // loop time is same for Master as for AppSlvs, even though it may be 3.95 - // smaller due to higher predictability of the fixed jmp. 3.96 - #define MEAS__Capture_Pre_Master_Point\ 3.97 - saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); 3.98 - 3.99 - #define MEAS__Capture_Post_Master_Point \ 3.100 - saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ 3.101 - addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 3.102 - _VMSMasterEnv->masterLowTimeHist ); \ 3.103 - addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 3.104 - _VMSMasterEnv->masterHighTimeHist ); 3.105 - 3.106 - #define MEAS__Print_Hists_for_Master_Meas \ 3.107 - printHist( _VMSMasterEnv->pluginTimeHist ); 3.108 - 3.109 -#else 3.110 - #define MEAS__Insert_Master_Meas_Fields_into_Slave 3.111 - #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv 3.112 - #define MEAS__Make_Meas_Hists_for_Master_Meas 3.113 - #define MEAS__Capture_Pre_Master_Point 3.114 - #define MEAS__Capture_Post_Master_Point 3.115 - #define MEAS__Print_Hists_for_Master_Meas 3.116 -#endif 3.117 - 3.118 - 3.119 -#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS 3.120 - #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ 3.121 - Histogram *masterLockLowTimeHist; \ 3.122 - Histogram *masterLockHighTimeHist; 3.123 - 3.124 - #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ 3.125 - _VMSMasterEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ 3.126 - "master lock low time hist");\ 3.127 - _VMSMasterEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ 3.128 - "master lock high time hist"); 3.129 - 3.130 - #define MEAS__Capture_Pre_Master_Lock_Point \ 3.131 - int32 startStamp, endStamp; \ 3.132 - saveLowTimeStampCountInto( startStamp ); 3.133 - 3.134 - #define MEAS__Capture_Post_Master_Lock_Point \ 3.135 - saveLowTimeStampCountInto( endStamp ); \ 3.136 - addIntervalToHist( startStamp, endStamp,\ 3.137 - _VMSMasterEnv->masterLockLowTimeHist ); \ 3.138 - addIntervalToHist( startStamp, endStamp,\ 3.139 - _VMSMasterEnv->masterLockHighTimeHist ); 3.140 - 3.141 - #define MEAS__Print_Hists_for_Master_Lock_Meas \ 3.142 - printHist( _VMSMasterEnv->masterLockLowTimeHist ); \ 3.143 - printHist( _VMSMasterEnv->masterLockHighTimeHist ); 3.144 - 3.145 -#else 3.146 - #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv 3.147 - #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas 3.148 - #define MEAS__Capture_Pre_Master_Lock_Point 3.149 - #define MEAS__Capture_Post_Master_Lock_Point 3.150 - #define MEAS__Print_Hists_for_Master_Lock_Meas 3.151 -#endif 3.152 - 3.153 - 3.154 -#ifdef MEAS__TURN_ON_MALLOC_MEAS 3.155 - #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ 3.156 - Histogram *mallocTimeHist; \ 3.157 - Histogram *freeTimeHist; 3.158 - 3.159 - #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ 3.160 - _VMSMasterEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 3.161 - "malloc_time_hist");\ 3.162 - _VMSMasterEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 3.163 - "free_time_hist"); 3.164 - 3.165 - #define MEAS__Capture_Pre_Malloc_Point \ 3.166 - int32 startStamp, endStamp; \ 3.167 - saveLowTimeStampCountInto( startStamp ); 3.168 - 3.169 - #define MEAS__Capture_Post_Malloc_Point \ 3.170 - saveLowTimeStampCountInto( endStamp ); \ 3.171 - addIntervalToHist( startStamp, endStamp,\ 3.172 - _VMSMasterEnv->mallocTimeHist ); 3.173 - 3.174 - #define MEAS__Capture_Pre_Free_Point \ 3.175 - int32 startStamp, endStamp; \ 3.176 - saveLowTimeStampCountInto( startStamp ); 3.177 - 3.178 - #define MEAS__Capture_Post_Free_Point \ 3.179 - saveLowTimeStampCountInto( endStamp ); \ 3.180 - addIntervalToHist( startStamp, endStamp,\ 3.181 - _VMSMasterEnv->freeTimeHist ); 3.182 - 3.183 - #define MEAS__Print_Hists_for_Malloc_Meas \ 3.184 - printHist( _VMSMasterEnv->mallocTimeHist ); \ 3.185 - saveHistToFile( _VMSMasterEnv->mallocTimeHist ); \ 3.186 - printHist( _VMSMasterEnv->freeTimeHist ); \ 3.187 - saveHistToFile( _VMSMasterEnv->freeTimeHist ); \ 3.188 - freeHistExt( _VMSMasterEnv->mallocTimeHist ); \ 3.189 - freeHistExt( _VMSMasterEnv->freeTimeHist ); 3.190 - 3.191 -#else 3.192 - #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv 3.193 - #define MEAS__Make_Meas_Hists_for_Malloc_Meas 3.194 - #define MEAS__Capture_Pre_Malloc_Point 3.195 - #define MEAS__Capture_Post_Malloc_Point 3.196 - #define MEAS__Capture_Pre_Free_Point 3.197 - #define MEAS__Capture_Post_Free_Point 3.198 - #define MEAS__Print_Hists_for_Malloc_Meas 3.199 -#endif 3.200 - 3.201 - 3.202 - 3.203 -#ifdef MEAS__TURN_ON_PLUGIN_MEAS 3.204 - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ 3.205 - Histogram *reqHdlrLowTimeHist; \ 3.206 - Histogram *reqHdlrHighTimeHist; 3.207 - 3.208 - #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ 3.209 - _VMSMasterEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 3.210 - "plugin_low_time_hist");\ 3.211 - _VMSMasterEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 3.212 - "plugin_high_time_hist"); 3.213 - 3.214 - #define MEAS__startReqHdlr \ 3.215 - int32 startStamp1, endStamp1; \ 3.216 - saveLowTimeStampCountInto( startStamp1 ); 3.217 - 3.218 - #define MEAS__endReqHdlr \ 3.219 - saveLowTimeStampCountInto( endStamp1 ); \ 3.220 - addIntervalToHist( startStamp1, endStamp1, \ 3.221 - _VMSMasterEnv->reqHdlrLowTimeHist ); \ 3.222 - addIntervalToHist( startStamp1, endStamp1, \ 3.223 - _VMSMasterEnv->reqHdlrHighTimeHist ); 3.224 - 3.225 - #define MEAS__Print_Hists_for_Plugin_Meas \ 3.226 - printHist( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 3.227 - saveHistToFile( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 3.228 - printHist( _VMSMasterEnv->reqHdlrHighTimeHist ); \ 3.229 - saveHistToFile( _VMSMasterEnv->reqHdlrHighTimeHist ); \ 3.230 - freeHistExt( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 3.231 - freeHistExt( _VMSMasterEnv->reqHdlrHighTimeHist ); 3.232 -#else 3.233 - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv 3.234 - #define MEAS__Make_Meas_Hists_for_Plugin_Meas 3.235 - #define MEAS__startReqHdlr 3.236 - #define MEAS__endReqHdlr 3.237 - #define MEAS__Print_Hists_for_Plugin_Meas 3.238 - 3.239 -#endif 3.240 - 3.241 - 3.242 -#ifdef MEAS__TURN_ON_SYSTEM_MEAS 3.243 - #define MEAS__Insert_System_Meas_Fields_into_Slave \ 3.244 - TSCountLowHigh startSusp; \ 3.245 - uint64 totalSuspCycles; \ 3.246 - uint32 numGoodSusp; 3.247 - 3.248 - #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ 3.249 - TSCountLowHigh startMaster; \ 3.250 - uint64 totalMasterCycles; \ 3.251 - uint32 numMasterAnimations; \ 3.252 - TSCountLowHigh startReqHdlr; \ 3.253 - uint64 totalPluginCycles; \ 3.254 - uint32 numPluginAnimations; \ 3.255 - uint64 cyclesTillStartMasterLoop; \ 3.256 - TSCountLowHigh endMasterLoop; 3.257 - 3.258 - #define MEAS__startMasterLoop_forSys \ 3.259 - TSCountLowHigh startStamp1, endStamp1; \ 3.260 - saveTSCLowHigh( endStamp1 ); \ 3.261 - _VMSMasterEnv->cyclesTillStartMasterLoop = \ 3.262 - endStamp1.longVal - masterVP->startSusp.longVal; 3.263 - 3.264 - #define Meas_startReqHdlr_forSys \ 3.265 - saveTSCLowHigh( startStamp1 ); \ 3.266 - _VMSMasterEnv->startReqHdlr.longVal = startStamp1.longVal; 3.267 - 3.268 - #define MEAS__endMasterLoop_forSys \ 3.269 - saveTSCLowHigh( startStamp1 ); \ 3.270 - _VMSMasterEnv->endMasterLoop.longVal = startStamp1.longVal; 3.271 - 3.272 - /*A TSC is stored in VP first thing inside wrapper-lib 3.273 - * Now, measures cycles from there to here 3.274 - * Master and Plugin will add this value to other trace-seg measures 3.275 - */ 3.276 - #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys\ 3.277 - saveTSCLowHigh(endSusp); \ 3.278 - numCycles = endSusp.longVal - currVP->startSusp.longVal; \ 3.279 - /*sanity check (400K is about 20K iters)*/ \ 3.280 - if( numCycles < 400000 ) \ 3.281 - { currVP->totalSuspCycles += numCycles; \ 3.282 - currVP->numGoodSusp++; \ 3.283 - } \ 3.284 - /*recorded every time, but only read if currVP == MasterVP*/ \ 3.285 - _VMSMasterEnv->startMaster.longVal = endSusp.longVal; 3.286 - 3.287 -#else 3.288 - #define MEAS__Insert_System_Meas_Fields_into_Slave 3.289 - #define MEAS__Insert_System_Meas_Fields_into_MasterEnv 3.290 - #define MEAS__Make_Meas_Hists_for_System_Meas 3.291 - #define MEAS__startMasterLoop_forSys 3.292 - #define MEAS__startReqHdlr_forSys 3.293 - #define MEAS__endMasterLoop_forSys 3.294 - #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys 3.295 - #define MEAS__Print_Hists_for_System_Meas 3.296 -#endif 3.297 - 3.298 - 3.299 -//Experiment in two-step macros -- if doesn't work, insert each separately 3.300 -#define MEAS__Insert_Meas_Fields_into_Slave \ 3.301 - MEAS__Insert_Susp_Meas_Fields_into_Slave \ 3.302 - MEAS__Insert_Master_Meas_Fields_into_Slave \ 3.303 - MEAS__Insert_System_Meas_Fields_into_Slave 3.304 - 3.305 - 3.306 -//====================== Histogram Macros -- Create ======================== 3.307 -// 3.308 -// 3.309 - 3.310 -//The language implementation should include a definition of this macro, 3.311 -// which creates all the histograms the language uses to collect measurements 3.312 -// of plugin operation -- so, if the language didn't define it, must 3.313 -// define it here (as empty), to avoid compile error 3.314 -#ifndef MEAS__Make_Meas_Hists_for_Language 3.315 -#define MEAS__Make_Meas_Hists_for_Language 3.316 -#endif 3.317 - 3.318 -#define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ 3.319 - makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \ 3.320 - _VMSMasterEnv->measHists[idx] = \ 3.321 - makeFixedBinHist( numBins, startVal, binWidth, name ); 3.322 - 3.323 -//============================== Probes =================================== 3.324 - 3.325 - 3.326 -//=========================================================================== 3.327 -#endif /* _VMS_DEFS_MEAS_H */ 3.328 -
4.1 --- a/Defines/VMS_defs__lang_specific.h Tue Mar 13 10:02:06 2012 -0700 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,110 +0,0 @@ 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_LANG_SPEC_DEFS_H 4.13 -#define _VMS_LANG_SPEC_DEFS_H 4.14 - 4.15 - 4.16 - 4.17 -//=================== Language-specific Measurement Stuff =================== 4.18 -// 4.19 -//TODO: move these into the language implementation directories 4.20 -// 4.21 - 4.22 - 4.23 -//=========================================================================== 4.24 -//VCilk 4.25 - 4.26 -#ifdef VCILK 4.27 - 4.28 -#define spawnHistIdx 1 //note: starts at 1 4.29 -#define syncHistIdx 2 4.30 - 4.31 -#define MEAS__Make_Meas_Hists_for_Language() \ 4.32 - _VMSMasterEnv->measHistsInfo = \ 4.33 - makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ 4.34 - makeAMeasHist( spawnHistIdx, "Spawn", 50, 0, 200 ) \ 4.35 - makeAMeasHist( syncHistIdx, "Sync", 50, 0, 200 ) 4.36 - 4.37 - 4.38 -#define Meas_startSpawn \ 4.39 - int32 startStamp, endStamp; \ 4.40 - saveLowTimeStampCountInto( startStamp ); \ 4.41 - 4.42 -#define Meas_endSpawn \ 4.43 - saveLowTimeStampCountInto( endStamp ); \ 4.44 - addIntervalToHist( startStamp, endStamp, \ 4.45 - _VMSMasterEnv->measHists[ spawnHistIdx ] ); 4.46 - 4.47 -#define Meas_startSync \ 4.48 - int32 startStamp, endStamp; \ 4.49 - saveLowTimeStampCountInto( startStamp ); \ 4.50 - 4.51 -#define Meas_endSync \ 4.52 - saveLowTimeStampCountInto( endStamp ); \ 4.53 - addIntervalToHist( startStamp, endStamp, \ 4.54 - _VMSMasterEnv->measHists[ syncHistIdx ] ); 4.55 -#endif 4.56 - 4.57 -//=========================================================================== 4.58 -// SSR 4.59 - 4.60 -#ifdef SSR 4.61 - 4.62 -#define SendFromToHistIdx 1 //note: starts at 1 4.63 -#define SendOfTypeHistIdx 2 4.64 -#define ReceiveFromToHistIdx 3 4.65 -#define ReceiveOfTypeHistIdx 4 4.66 - 4.67 -#define MEAS__Make_Meas_Hists_for_Language() \ 4.68 - _VMSMasterEnv->measHistsInfo = \ 4.69 - makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ 4.70 - makeAMeasHist( SendFromToHistIdx, "SendFromTo", 50, 0, 100 ) \ 4.71 - makeAMeasHist( SendOfTypeHistIdx, "SendOfType", 50, 0, 100 ) \ 4.72 - makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \ 4.73 - makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 ) 4.74 - 4.75 -#define Meas_startSendFromTo \ 4.76 - int32 startStamp, endStamp; \ 4.77 - saveLowTimeStampCountInto( startStamp ); \ 4.78 - 4.79 -#define Meas_endSendFromTo \ 4.80 - saveLowTimeStampCountInto( endStamp ); \ 4.81 - addIntervalToHist( startStamp, endStamp, \ 4.82 - _VMSMasterEnv->measHists[ SendFromToHistIdx ] ); 4.83 - 4.84 -#define Meas_startSendOfType \ 4.85 - int32 startStamp, endStamp; \ 4.86 - saveLowTimeStampCountInto( startStamp ); \ 4.87 - 4.88 -#define Meas_endSendOfType \ 4.89 - saveLowTimeStampCountInto( endStamp ); \ 4.90 - addIntervalToHist( startStamp, endStamp, \ 4.91 - _VMSMasterEnv->measHists[ SendOfTypeHistIdx ] ); 4.92 - 4.93 -#define Meas_startReceiveFromTo \ 4.94 - int32 startStamp, endStamp; \ 4.95 - saveLowTimeStampCountInto( startStamp ); \ 4.96 - 4.97 -#define Meas_endReceiveFromTo \ 4.98 - saveLowTimeStampCountInto( endStamp ); \ 4.99 - addIntervalToHist( startStamp, endStamp, \ 4.100 - _VMSMasterEnv->measHists[ ReceiveFromToHistIdx ] ); 4.101 - 4.102 -#define Meas_startReceiveOfType \ 4.103 - int32 startStamp, endStamp; \ 4.104 - saveLowTimeStampCountInto( startStamp ); \ 4.105 - 4.106 -#define Meas_endReceiveOfType \ 4.107 - saveLowTimeStampCountInto( endStamp ); \ 4.108 - addIntervalToHist( startStamp, endStamp, \ 4.109 - _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); 4.110 -#endif /* SSR */ 4.111 - 4.112 -#endif /* _VMS_DEFS_H */ 4.113 -
5.1 --- a/Defines/VMS_defs__main.h Tue Mar 13 10:02:06 2012 -0700 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,41 +0,0 @@ 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_DEFS_MAIN_H 5.13 -#define _VMS_DEFS_MAIN_H 5.14 -#define _GNU_SOURCE 5.15 - 5.16 -//=========================== VMS-wide defs =============================== 5.17 - 5.18 -#define SUCCESS 0 5.19 - 5.20 - //only after macro-expansion are the defs of writePrivQ, aso looked up 5.21 - // so these defs can be at the top, and writePrivQ defined later on.. 5.22 -#define writeVMSQ writePrivQ 5.23 -#define readVMSQ readPrivQ 5.24 -#define makeVMSQ makePrivQ 5.25 -#define numInVMSQ numInPrivQ 5.26 -#define VMSQueueStruc PrivQueueStruc 5.27 - 5.28 - 5.29 -/*The language should re-define this, but need a default in case it doesn't*/ 5.30 -#ifndef _LANG_NAME_ 5.31 -#define _LANG_NAME_ "" 5.32 -#endif 5.33 - 5.34 -//====================== Hardware Constants ============================ 5.35 -#include "VMS_defs__HW_constants.h" 5.36 - 5.37 -//====================== Debug, Meas, etc defines ====================== 5.38 -#include "VMS_defs__turn_on_and_off.h" 5.39 -#include "VMS_defs__DEBUG.h" 5.40 -#include "VMS_defs__MEAS.h" 5.41 - 5.42 -//=========================================================================== 5.43 -#endif /* */ 5.44 -
6.1 --- a/Probes/probes.c Tue Mar 13 10:02:06 2012 -0700 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,303 +0,0 @@ 6.4 -/* 6.5 - * Copyright 2010 OpenSourceStewardshipFoundation 6.6 - * 6.7 - * Licensed under BSD 6.8 - */ 6.9 - 6.10 -#include <stdio.h> 6.11 -#include <malloc.h> 6.12 -#include <sys/time.h> 6.13 - 6.14 -#include "../VMS.h" 6.15 - 6.16 - 6.17 - 6.18 -//==================== Probes ================= 6.19 -/* 6.20 - * In practice, probe operations are called from the app, from inside slaves 6.21 - * -- so have to be sure each probe is single-Slv owned, and be sure that 6.22 - * any place common structures are modified it's done inside the master. 6.23 - * So -- the only place common structures are modified is during creation. 6.24 - * after that, all mods are to individual instances. 6.25 - * 6.26 - * Thniking perhaps should change the semantics to be that probes are 6.27 - * attached to the virtual processor -- and then everything is guaranteed 6.28 - * to be isolated -- except then can't take any intervals that span Slvs, 6.29 - * and would have to transfer the probes to Master env when Slv dissipates.. 6.30 - * gets messy.. 6.31 - * 6.32 - * For now, just making so that probe creation causes a suspend, so that 6.33 - * the dynamic array in the master env is only modified from the master 6.34 - * 6.35 - */ 6.36 - 6.37 -//============================ Helpers =========================== 6.38 -inline void 6.39 -doNothing() 6.40 - { 6.41 - } 6.42 - 6.43 -float64 inline 6.44 -giveInterval( struct timeval _start, struct timeval _end ) 6.45 - { float64 start, end; 6.46 - start = _start.tv_sec + _start.tv_usec / 1000000.0; 6.47 - end = _end.tv_sec + _end.tv_usec / 1000000.0; 6.48 - return end - start; 6.49 - } 6.50 - 6.51 -//================================================================= 6.52 -IntervalProbe * 6.53 -create_generic_probe( char *nameStr, SlaveVP *animSlv ) 6.54 - { 6.55 - VMSSemReq reqData; 6.56 - 6.57 - reqData.reqType = createProbe; 6.58 - reqData.nameStr = nameStr; 6.59 - 6.60 - VMS_WL__send_VMSSem_request( &reqData, animSlv ); 6.61 - 6.62 - return animSlv->dataRetFromReq; 6.63 - } 6.64 - 6.65 -/*Use this version from outside VMS -- it uses external malloc, and modifies 6.66 - * dynamic array, so can't be animated in a slave Slv 6.67 - */ 6.68 -IntervalProbe * 6.69 -ext__create_generic_probe( char *nameStr ) 6.70 - { IntervalProbe *newProbe; 6.71 - int32 nameLen; 6.72 - 6.73 - newProbe = malloc( sizeof(IntervalProbe) ); 6.74 - nameLen = strlen( nameStr ); 6.75 - newProbe->nameStr = malloc( nameLen ); 6.76 - memcpy( newProbe->nameStr, nameStr, nameLen ); 6.77 - newProbe->hist = NULL; 6.78 - newProbe->schedChoiceWasRecorded = FALSE; 6.79 - newProbe->probeID = 6.80 - addToDynArray( newProbe, _VMSMasterEnv->dynIntervalProbesInfo ); 6.81 - 6.82 - return newProbe; 6.83 - } 6.84 - 6.85 -//============================ Fns def in header ======================= 6.86 - 6.87 -int32 6.88 -VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ) 6.89 - { IntervalProbe *newProbe; 6.90 - 6.91 - newProbe = create_generic_probe( nameStr, animSlv ); 6.92 - 6.93 - return newProbe->probeID; 6.94 - } 6.95 - 6.96 -int32 6.97 -VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 6.98 - float64 binWidth, char *nameStr, SlaveVP *animSlv ) 6.99 - { IntervalProbe *newProbe; 6.100 - 6.101 - newProbe = create_generic_probe( nameStr, animSlv ); 6.102 - 6.103 -#ifdef PROBES__USE_TIME_OF_DAY_PROBES 6.104 - DblHist *hist; 6.105 - hist = makeDblHistogram( numBins, startValue, binWidth ); 6.106 -#else 6.107 - Histogram *hist; 6.108 - hist = makeHistogram( numBins, startValue, binWidth ); 6.109 -#endif 6.110 - newProbe->hist = hist; 6.111 - return newProbe->probeID; 6.112 - } 6.113 - 6.114 - 6.115 -int32 6.116 -VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv) 6.117 - { IntervalProbe *newProbe; 6.118 - struct timeval *startStamp; 6.119 - float64 startSecs; 6.120 - 6.121 - newProbe = create_generic_probe( nameStr, animSlv ); 6.122 - newProbe->endSecs = 0; 6.123 - 6.124 - 6.125 - gettimeofday( &(newProbe->startStamp), NULL); 6.126 - 6.127 - //turn into a double 6.128 - startStamp = &(newProbe->startStamp); 6.129 - startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); 6.130 - newProbe->startSecs = startSecs; 6.131 - 6.132 - return newProbe->probeID; 6.133 - } 6.134 - 6.135 -int32 6.136 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ) 6.137 - { IntervalProbe *newProbe; 6.138 - struct timeval *startStamp; 6.139 - float64 startSecs; 6.140 - 6.141 - newProbe = ext__create_generic_probe( nameStr ); 6.142 - newProbe->endSecs = 0; 6.143 - 6.144 - gettimeofday( &(newProbe->startStamp), NULL); 6.145 - 6.146 - //turn into a double 6.147 - startStamp = &(newProbe->startStamp); 6.148 - startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); 6.149 - newProbe->startSecs = startSecs; 6.150 - 6.151 - return newProbe->probeID; 6.152 - } 6.153 - 6.154 - 6.155 -/*Only call from inside master or main startup/shutdown thread 6.156 - */ 6.157 -void 6.158 -VMS_impl__free_probe( IntervalProbe *probe ) 6.159 - { if( probe->hist != NULL ) freeDblHist( probe->hist ); 6.160 - if( probe->nameStr != NULL) VMS_int__free( probe->nameStr ); 6.161 - VMS_int__free( probe ); 6.162 - } 6.163 - 6.164 - 6.165 -void 6.166 -VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ) 6.167 - { IntervalProbe *probe; 6.168 - 6.169 - //TODO: fix this To be in Master -- race condition 6.170 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 6.171 - 6.172 - addValueIntoTable(probe->nameStr, probe, _VMSMasterEnv->probeNameHashTbl); 6.173 - } 6.174 - 6.175 - 6.176 -IntervalProbe * 6.177 -VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ) 6.178 - { 6.179 - //TODO: fix this To be in Master -- race condition 6.180 - return getValueFromTable( probeName, _VMSMasterEnv->probeNameHashTbl ); 6.181 - } 6.182 - 6.183 - 6.184 -/*Everything is local to the animating slaveVP, so no need for request, do 6.185 - * work locally, in the anim Slv 6.186 - */ 6.187 -void 6.188 -VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animatingSlv ) 6.189 - { IntervalProbe *probe; 6.190 - 6.191 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 6.192 - probe->schedChoiceWasRecorded = TRUE; 6.193 - probe->coreNum = animatingSlv->coreAnimatedBy; 6.194 - probe->slaveID = animatingSlv->slaveID; 6.195 - probe->slaveCreateSecs = animatingSlv->createPtInSecs; 6.196 - } 6.197 - 6.198 -/*Everything is local to the animating slaveVP, so no need for request, do 6.199 - * work locally, in the anim Slv 6.200 - */ 6.201 -void 6.202 -VMS_impl__record_interval_start_in_probe( int32 probeID ) 6.203 - { IntervalProbe *probe; 6.204 - 6.205 - DEBUG_Print( dbgProbes, "record start of interval\n" ) 6.206 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 6.207 - 6.208 - //record *start* point as last thing, after lookup 6.209 -#ifdef PROBES__USE_TIME_OF_DAY_PROBES 6.210 - gettimeofday( &(probe->startStamp), NULL); 6.211 -#endif 6.212 -#ifdef PROBES__USE_TSC_PROBES 6.213 - probe->startStamp = getTSCount(); 6.214 -#endif 6.215 - } 6.216 - 6.217 - 6.218 -/*Everything is local to the animating slaveVP, except the histogram, so do 6.219 - * work locally, in the anim Slv -- may lose a few histogram counts 6.220 - * 6.221 - *This should be safe to run inside SlaveVP 6.222 - */ 6.223 -void 6.224 -VMS_impl__record_interval_end_in_probe( int32 probeID ) 6.225 - { IntervalProbe *probe; 6.226 - 6.227 - //Record first thing -- before looking up the probe to store it into 6.228 -#ifdef PROBES__USE_TIME_OF_DAY_PROBES 6.229 - struct timeval endStamp; 6.230 - gettimeofday( &(endStamp), NULL); 6.231 -#endif 6.232 -#ifdef PROBES__USE_TSC_PROBES 6.233 - TSCount endStamp, interval; 6.234 - endStamp = getTSCount(); 6.235 -#endif 6.236 -#ifdef PROBES__USE_PERF_CTR_PROBES 6.237 - 6.238 -#endif 6.239 - 6.240 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 6.241 - 6.242 -#ifdef PROBES__USE_TIME_OF_DAY_PROBES 6.243 - if( probe->hist != NULL ) 6.244 - { addToDblHist( giveInterval( probe->startStamp, endStamp), probe->hist ); 6.245 - } 6.246 -#endif 6.247 -#ifdef PROBES__USE_TSC_PROBES 6.248 - if( probe->hist != NULL ) 6.249 - { interval = probe->endStamp - probe->startStamp; 6.250 - //Sanity check for TSC counter overflow: if sane, add to histogram 6.251 - if( interval < probe->hist->endOfRange * 10 ) 6.252 - addToHist( interval, probe->hist ); 6.253 - } 6.254 -#endif 6.255 -#ifdef PROBES__USE_PERF_CTR_PROBES 6.256 - 6.257 -#endif 6.258 - 6.259 - DEBUG_Print( dbgProbes, "record end of interval\n" ) 6.260 - } 6.261 - 6.262 - 6.263 -void 6.264 -print_probe_helper( IntervalProbe *probe ) 6.265 - { 6.266 - printf( "\nprobe: %s, ", probe->nameStr ); 6.267 - 6.268 - 6.269 - if( probe->schedChoiceWasRecorded ) 6.270 - { printf( "coreNum: %d, slaveID: %d, slaveVPCreated: %0.6f | ", 6.271 - probe->coreNum, probe->slaveID, probe->slaveCreateSecs ); 6.272 - } 6.273 - 6.274 - if( probe->endSecs == 0 ) //just a single point in time 6.275 - { 6.276 - printf( " time point: %.6f\n", 6.277 - probe->startSecs - _VMSMasterEnv->createPtInSecs ); 6.278 - } 6.279 - else if( probe->hist == NULL ) //just an interval 6.280 - { 6.281 - printf( " startSecs: %.6f interval: %.6f\n", 6.282 - (probe->startSecs - _VMSMasterEnv->createPtInSecs), probe->interval); 6.283 - } 6.284 - else //a full histogram of intervals 6.285 - { 6.286 - printDblHist( probe->hist ); 6.287 - } 6.288 - } 6.289 - 6.290 -void 6.291 -VMS_impl__print_stats_of_probe( IntervalProbe *probe ) 6.292 - { 6.293 - 6.294 -// probe = _VMSMasterEnv->intervalProbes[ probeID ]; 6.295 - 6.296 - print_probe_helper( probe ); 6.297 - } 6.298 - 6.299 - 6.300 -void 6.301 -VMS_impl__print_stats_of_all_probes() 6.302 - { 6.303 - forAllInDynArrayDo( _VMSMasterEnv->dynIntervalProbesInfo, 6.304 - (DynArrayFnPtr) &VMS_impl__print_stats_of_probe ); 6.305 - fflush( stdout ); 6.306 - }
7.1 --- a/Probes/probes.h Tue Mar 13 10:02:06 2012 -0700 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,179 +0,0 @@ 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 _PROBES_H 7.13 -#define _PROBES_H 7.14 -#define _GNU_SOURCE 7.15 - 7.16 -#include "../VMS_primitive_data_types.h" 7.17 - 7.18 -#include <sys/time.h> 7.19 - 7.20 -/*Note on order of include files: 7.21 - * This file relies on #defines that appear in other files, which must come 7.22 - * first in the #include sequence.. 7.23 - */ 7.24 - 7.25 - 7.26 -/*Use these aliases in application code*/ 7.27 -#define VMS_App__record_time_point_into_new_probe VMS_WL__record_time_point_into_new_probe 7.28 -#define VMS_App__create_single_interval_probe VMS_WL__create_single_interval_probe 7.29 -#define VMS_App__create_histogram_probe VMS_WL__create_histogram_probe 7.30 -#define VMS_App__index_probe_by_its_name VMS_WL__index_probe_by_its_name 7.31 -#define VMS_App__get_probe_by_name VMS_WL__get_probe_by_name 7.32 -#define VMS_App__record_sched_choice_into_probe VMS_WL__record_sched_choice_into_probe 7.33 -#define VMS_App__record_interval_start_in_probe VMS_WL__record_interval_start_in_probe 7.34 -#define VMS_App__record_interval_end_in_probe VMS_WL__record_interval_end_in_probe 7.35 -#define VMS_App__print_stats_of_probe VMS_WL__print_stats_of_probe 7.36 -#define VMS_App__print_stats_of_all_probes VMS_WL__print_stats_of_all_probes 7.37 - 7.38 - 7.39 -//========================== 7.40 -#ifdef PROBES__USE_TSC_PROBES 7.41 - #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ 7.42 - TSCount startStamp; \ 7.43 - TSCount endStamp; \ 7.44 - TSCount interval; \ 7.45 - Histogram *hist; /*if left NULL, then is single interval probe*/ 7.46 -#endif 7.47 -#ifdef PROBES__USE_TIME_OF_DAY_PROBES 7.48 - #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ 7.49 - struct timeval startStamp; \ 7.50 - struct timeval endStamp; \ 7.51 - float64 startSecs; \ 7.52 - float64 endSecs; \ 7.53 - float64 interval; \ 7.54 - DblHist *hist; /*if NULL, then is single interval probe*/ 7.55 -#endif 7.56 -#ifdef PROBES__USE_PERF_CTR_PROBES 7.57 - #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ 7.58 - int64 startStamp; \ 7.59 - int64 endStamp; \ 7.60 - int64 interval; \ 7.61 - Histogram *hist; /*if left NULL, then is single interval probe*/ 7.62 -#endif 7.63 - 7.64 -//typedef struct _IntervalProbe IntervalProbe; -- is in VMS.h 7.65 -struct _IntervalProbe 7.66 - { 7.67 - char *nameStr; 7.68 - int32 probeID; 7.69 - 7.70 - int32 schedChoiceWasRecorded; 7.71 - int32 coreNum; 7.72 - int32 slaveID; 7.73 - float64 slaveCreateSecs; 7.74 - PROBES__Insert_timestamps_and_intervals_into_probe_struct; 7.75 - }; 7.76 - 7.77 -//=========================== NEVER USE THESE ========================== 7.78 -/*NEVER use these in any code!! These are here only for use in the macros 7.79 - * defined in this file!! 7.80 - */ 7.81 -int32 7.82 -VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ); 7.83 - 7.84 -int32 7.85 -VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 7.86 - float64 binWidth, char *nameStr, SlaveVP *animSlv ); 7.87 - 7.88 -int32 7.89 -VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv); 7.90 - 7.91 -int32 7.92 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); 7.93 - 7.94 -void 7.95 -VMS_impl__free_probe( IntervalProbe *probe ); 7.96 - 7.97 -void 7.98 -VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ); 7.99 - 7.100 -IntervalProbe * 7.101 -VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ); 7.102 - 7.103 -void 7.104 -VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animSlv ); 7.105 - 7.106 -void 7.107 -VMS_impl__record_interval_start_in_probe( int32 probeID ); 7.108 - 7.109 -void 7.110 -VMS_impl__record_interval_end_in_probe( int32 probeID ); 7.111 - 7.112 -void 7.113 -VMS_impl__print_stats_of_probe( IntervalProbe *probe ); 7.114 - 7.115 -void 7.116 -VMS_impl__print_stats_of_all_probes(); 7.117 - 7.118 - 7.119 -//======================== Probes ============================= 7.120 -// 7.121 -// Use macros to allow turning probes off with a #define switch 7.122 -// This means probes have zero impact on performance when off 7.123 -//============================================================= 7.124 - 7.125 -#ifdef PROBES__TURN_ON_STATS_PROBES 7.126 - #define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) \ 7.127 - VMS_impl__record_time_point_in_new_probe( nameStr, animSlv ) 7.128 - 7.129 - #define VMS_ext__record_time_point_into_new_probe( nameStr ) \ 7.130 - VMS_ext_impl__record_time_point_into_new_probe( nameStr ) 7.131 - 7.132 - #define VMS_WL__create_single_interval_probe( nameStr, animSlv ) \ 7.133 - VMS_impl__create_single_interval_probe( nameStr, animSlv ) 7.134 - 7.135 - #define VMS_WL__create_histogram_probe( numBins, startValue, \ 7.136 - binWidth, nameStr, animSlv ) \ 7.137 - VMS_impl__create_histogram_probe( numBins, startValue, \ 7.138 - binWidth, nameStr, animSlv ) 7.139 - #define VMS_int__free_probe( probe ) \ 7.140 - VMS_impl__free_probe( probe ) 7.141 - 7.142 - #define VMS_WL__index_probe_by_its_name( probeID, animSlv ) \ 7.143 - VMS_impl__index_probe_by_its_name( probeID, animSlv ) 7.144 - 7.145 - #define VMS_WL__get_probe_by_name( probeID, animSlv ) \ 7.146 - VMS_impl__get_probe_by_name( probeName, animSlv ) 7.147 - 7.148 - #define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) \ 7.149 - VMS_impl__record_sched_choice_into_probe( probeID, animSlv ) 7.150 - 7.151 - #define VMS_WL__record_interval_start_in_probe( probeID ) \ 7.152 - VMS_impl__record_interval_start_in_probe( probeID ) 7.153 - 7.154 - #define VMS_WL__record_interval_end_in_probe( probeID ) \ 7.155 - VMS_impl__record_interval_end_in_probe( probeID ) 7.156 - 7.157 - #define VMS_WL__print_stats_of_probe( probeID ) \ 7.158 - VMS_impl__print_stats_of_probe( probeID ) 7.159 - 7.160 - #define VMS_WL__print_stats_of_all_probes() \ 7.161 - VMS_impl__print_stats_of_all_probes() 7.162 - 7.163 - 7.164 -#else 7.165 - #define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) 0 /* do nothing */ 7.166 - #define VMS_ext__record_time_point_into_new_probe( nameStr ) 0 /* do nothing */ 7.167 - #define VMS_WL__create_single_interval_probe( nameStr, animSlv ) 0 /* do nothing */ 7.168 - #define VMS_WL__create_histogram_probe( numBins, startValue, \ 7.169 - binWidth, nameStr, animSlv ) \ 7.170 - 0 /* do nothing */ 7.171 - #define VMS_WL__index_probe_by_its_name( probeID, animSlv ) /* do nothing */ 7.172 - #define VMS_WL__get_probe_by_name( probeID, animSlv ) NULL /* do nothing */ 7.173 - #define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) /* do nothing */ 7.174 - #define VMS_WL__record_interval_start_in_probe( probeID ) /* do nothing */ 7.175 - #define VMS_WL__record_interval_end_in_probe( probeID ) /* do nothing */ 7.176 - #define VMS_WL__print_stats_of_probe( probeID ) ; /* do nothing */ 7.177 - #define VMS_WL__print_stats_of_all_probes() ;/* do nothing */ 7.178 - 7.179 -#endif /* defined PROBES__TURN_ON_STATS_PROBES */ 7.180 - 7.181 -#endif /* _PROBES_H */ 7.182 -
8.1 --- a/SchedulingMaster.c Tue Mar 13 10:02:06 2012 -0700 8.2 +++ b/SchedulingMaster.c Tue Mar 13 18:28:04 2012 -0700 8.3 @@ -26,18 +26,18 @@ 8.4 *Polls each sched slot exactly once, hands any requests made by a newly 8.5 * done slave to the "request handler" plug-in function 8.6 * 8.7 - *Any slots that need a Slv assigned are given to the "schedule" 8.8 + *Any slots that need a Slv assigned are given to the "assign" 8.9 * plug-in function, which tries to assign a Slv (slave) to it. 8.10 * 8.11 - *When all slots needing a processor have been given to the schedule plug-in, 8.12 - * a fraction of the slaves successfully scheduled are put into the 8.13 + *When all slots needing a processor have been given to the assign plug-in, 8.14 + * a fraction of the slaves successfully assigned are put into the 8.15 * work queue, then a continuation of this function is put in, then the rest 8.16 - * of the Slvs that were successfully scheduled. 8.17 + * of the Slvs that were successfully assigned. 8.18 * 8.19 *The first thing the continuation does is busy-wait until the previous 8.20 * animation completes. This is because an (unlikely) continuation may 8.21 * sneak through queue before previous continuation is done putting second 8.22 - * part of scheduled slaves in, which is the only race condition. 8.23 + * part of assigned slaves in, which is the only race condition. 8.24 * 8.25 */ 8.26 8.27 @@ -78,7 +78,7 @@ 8.28 MasterEnv *masterEnv; 8.29 VMSQueueStruc *readyToAnimateQ; 8.30 8.31 - Sched_Assigner slaveAssigner; 8.32 + SlaveAssigner slaveAssigner; 8.33 RequestHandler requestHandler; 8.34 void *semanticEnv; 8.35 8.36 @@ -143,7 +143,7 @@ 8.37 if( currSlot->needsSlaveAssigned ) 8.38 { //give slot a new Slv 8.39 schedSlaveVP = 8.40 - (*slaveAssigner)( semanticEnv, thisCoresIdx ); 8.41 + (*slaveAssigner)( semanticEnv, thisCoresIdx, currSlot ); 8.42 8.43 if( schedSlaveVP != NULL ) 8.44 { currSlot->slaveAssignedToSlot = schedSlaveVP;
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/Services_Offered_by_VMS/Debugging/DEBUG__macros.h Tue Mar 13 18:28:04 2012 -0700 9.3 @@ -0,0 +1,35 @@ 9.4 +/* 9.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 9.6 + * Licensed under GNU General Public License version 2 9.7 + * 9.8 + * Author: seanhalle@yahoo.com 9.9 + * 9.10 + */ 9.11 + 9.12 +#ifndef _VMS_DEFS_DEBUG_H 9.13 +#define _VMS_DEFS_DEBUG_H 9.14 +#define _GNU_SOURCE 9.15 + 9.16 +/* 9.17 + */ 9.18 +#ifdef DEBUG__TURN_ON_DEBUG_MSGS 9.19 + #define DEBUG_Print( bool, msg) \ 9.20 + if( bool){ printf(msg); fflush(stdin);} 9.21 + #define DEBUG_Print1( bool, msg, param) \ 9.22 + if(bool){printf(msg, param); fflush(stdin);} 9.23 + #define DEBUG_Print2( bool, msg, p1, p2) \ 9.24 + if(bool) {printf(msg, p1, p2); fflush(stdin);} 9.25 +#else 9.26 + #define DEBUG_Print( bool, msg) 9.27 + #define DEBUG_Print1( bool, msg, param) 9.28 + #define DEBUG_Print2( bool, msg, p1, p2) 9.29 +#endif 9.30 + 9.31 +//============================= ERROR MSGs ============================ 9.32 +#define ERROR(msg) printf(msg); 9.33 +#define ERROR1(msg, param) printf(msg, param); 9.34 +#define ERROR2(msg, p1, p2) printf(msg, p1, p2); 9.35 + 9.36 +//=========================================================================== 9.37 +#endif /* _VMS_DEFS_H */ 9.38 +
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/Services_Offered_by_VMS/Lang_Constructs/VMS_Lang.h Tue Mar 13 18:28:04 2012 -0700 10.3 @@ -0,0 +1,44 @@ 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 _VMS_LANG_CONSTRUCTS_H 10.13 +#define _VMS_LANG_CONSTRUCTS_H 10.14 + 10.15 +#include "VMS_impl/VMS_primitive_data_types.h" 10.16 + 10.17 +/*This header defines everything specific to the VMS provided language 10.18 + * constructs. 10.19 + *Such constructs are used in application code, mixed-in with calls to 10.20 + * constructs of the VMS-based language. 10.21 + */ 10.22 +inline void 10.23 +handleMalloc( SSRSemReq *semReq, SlaveVP *requestingSlv, SSRSemEnv *semEnv); 10.24 +inline void 10.25 +handleFree( SSRSemReq *semReq, SlaveVP *requestingSlv, SSRSemEnv *semEnv ); 10.26 +inline void 10.27 +handleTransEnd(SSRSemReq *semReq, SlaveVP *requestingSlv, SSRSemEnv*semEnv); 10.28 +inline void 10.29 +handleTransStart( SSRSemReq *semReq, SlaveVP *requestingSlv, 10.30 + SSRSemEnv *semEnv ); 10.31 +inline void 10.32 +handleAtomic( SSRSemReq *semReq, SlaveVP *requestingSlv, SSRSemEnv *semEnv); 10.33 +inline void 10.34 +handleStartFnSingleton( SSRSemReq *semReq, SlaveVP *reqstingSlv, 10.35 + SSRSemEnv *semEnv ); 10.36 +inline void 10.37 +handleEndFnSingleton( SSRSemReq *semReq, SlaveVP *requestingSlv, 10.38 + SSRSemEnv *semEnv ); 10.39 +inline void 10.40 +handleStartDataSingleton( SSRSemReq *semReq, SlaveVP *reqstingSlv, 10.41 + SSRSemEnv *semEnv ); 10.42 +inline void 10.43 +handleEndDataSingleton( SSRSemReq *semReq, SlaveVP *requestingSlv, 10.44 + SSRSemEnv *semEnv ); 10.45 + 10.46 +#endif /* _VMS_LANG_CONSTRUCTS_H */ 10.47 +
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/Services_Offered_by_VMS/Measurement_and_Stats/MEAS__macros.h Tue Mar 13 18:28:04 2012 -0700 11.3 @@ -0,0 +1,325 @@ 11.4 +/* 11.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 11.6 + * Licensed under GNU General Public License version 2 11.7 + * 11.8 + * Author: seanhalle@yahoo.com 11.9 + * 11.10 + */ 11.11 + 11.12 +#ifndef _VMS_MEAS_MACROS_H 11.13 +#define _VMS_MEAS_MACROS_H 11.14 +#define _GNU_SOURCE 11.15 + 11.16 +//================== Macros define types of meas want ===================== 11.17 +// 11.18 +/*Generic measurement macro -- has name-space collision potential, which 11.19 + * compiler will catch.. so only use one pair inside a given set of 11.20 + * curly braces. 11.21 + */ 11.22 +//TODO: finish generic capture interval in hist 11.23 +enum histograms 11.24 + { generic1 11.25 + }; 11.26 + #define MEAS__Capture_Pre_Point \ 11.27 + int32 startStamp, endStamp; \ 11.28 + saveLowTimeStampCountInto( startStamp ); 11.29 + 11.30 + #define MEAS__Capture_Post_Point( histName ) \ 11.31 + saveLowTimeStampCountInto( endStamp ); \ 11.32 + addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->histName ); 11.33 + 11.34 + 11.35 + 11.36 + 11.37 +//================== Macros define types of meas want ===================== 11.38 + 11.39 +#ifdef MEAS__TURN_ON_SUSP_MEAS 11.40 + #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ 11.41 + uint32 preSuspTSCLow; \ 11.42 + uint32 postSuspTSCLow; 11.43 + 11.44 + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ 11.45 + Histogram *suspLowTimeHist; \ 11.46 + Histogram *suspHighTimeHist; 11.47 + 11.48 + #define MEAS__Make_Meas_Hists_for_Susp_Meas \ 11.49 + _VMSMasterEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 11.50 + "master_low_time_hist");\ 11.51 + _VMSMasterEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 11.52 + "master_high_time_hist"); 11.53 + 11.54 + //record time stamp: compare to time-stamp recorded below 11.55 + #define MEAS__Capture_Pre_Susp_Point \ 11.56 + saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); 11.57 + 11.58 + //NOTE: only take low part of count -- do sanity check when take diff 11.59 + #define MEAS__Capture_Post_Susp_Point \ 11.60 + saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ 11.61 + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 11.62 + _VMSMasterEnv->suspLowTimeHist ); \ 11.63 + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 11.64 + _VMSMasterEnv->suspHighTimeHist ); 11.65 + 11.66 + #define MEAS__Print_Hists_for_Susp_Meas \ 11.67 + printHist( _VMSMasterEnv->pluginTimeHist ); 11.68 + 11.69 +#else 11.70 + #define MEAS__Insert_Susp_Meas_Fields_into_Slave 11.71 + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv 11.72 + #define MEAS__Make_Meas_Hists_for_Susp_Meas 11.73 + #define MEAS__Capture_Pre_Susp_Point 11.74 + #define MEAS__Capture_Post_Susp_Point 11.75 + #define MEAS__Print_Hists_for_Susp_Meas 11.76 +#endif 11.77 + 11.78 +#ifdef MEAS__TURN_ON_MASTER_MEAS 11.79 + #define MEAS__Insert_Master_Meas_Fields_into_Slave \ 11.80 + uint32 startMasterTSCLow; \ 11.81 + uint32 endMasterTSCLow; 11.82 + 11.83 + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ 11.84 + Histogram *masterLowTimeHist; \ 11.85 + Histogram *masterHighTimeHist; 11.86 + 11.87 + #define MEAS__Make_Meas_Hists_for_Master_Meas \ 11.88 + _VMSMasterEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 11.89 + "master_low_time_hist");\ 11.90 + _VMSMasterEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 11.91 + "master_high_time_hist"); 11.92 + 11.93 + //Total Master time includes one coreloop time -- just assume the core 11.94 + // loop time is same for Master as for AppSlvs, even though it may be 11.95 + // smaller due to higher predictability of the fixed jmp. 11.96 + #define MEAS__Capture_Pre_Master_Point\ 11.97 + saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); 11.98 + 11.99 + #define MEAS__Capture_Post_Master_Point \ 11.100 + saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ 11.101 + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 11.102 + _VMSMasterEnv->masterLowTimeHist ); \ 11.103 + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 11.104 + _VMSMasterEnv->masterHighTimeHist ); 11.105 + 11.106 + #define MEAS__Print_Hists_for_Master_Meas \ 11.107 + printHist( _VMSMasterEnv->pluginTimeHist ); 11.108 + 11.109 +#else 11.110 + #define MEAS__Insert_Master_Meas_Fields_into_Slave 11.111 + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv 11.112 + #define MEAS__Make_Meas_Hists_for_Master_Meas 11.113 + #define MEAS__Capture_Pre_Master_Point 11.114 + #define MEAS__Capture_Post_Master_Point 11.115 + #define MEAS__Print_Hists_for_Master_Meas 11.116 +#endif 11.117 + 11.118 + 11.119 +#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS 11.120 + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ 11.121 + Histogram *masterLockLowTimeHist; \ 11.122 + Histogram *masterLockHighTimeHist; 11.123 + 11.124 + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ 11.125 + _VMSMasterEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ 11.126 + "master lock low time hist");\ 11.127 + _VMSMasterEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ 11.128 + "master lock high time hist"); 11.129 + 11.130 + #define MEAS__Capture_Pre_Master_Lock_Point \ 11.131 + int32 startStamp, endStamp; \ 11.132 + saveLowTimeStampCountInto( startStamp ); 11.133 + 11.134 + #define MEAS__Capture_Post_Master_Lock_Point \ 11.135 + saveLowTimeStampCountInto( endStamp ); \ 11.136 + addIntervalToHist( startStamp, endStamp,\ 11.137 + _VMSMasterEnv->masterLockLowTimeHist ); \ 11.138 + addIntervalToHist( startStamp, endStamp,\ 11.139 + _VMSMasterEnv->masterLockHighTimeHist ); 11.140 + 11.141 + #define MEAS__Print_Hists_for_Master_Lock_Meas \ 11.142 + printHist( _VMSMasterEnv->masterLockLowTimeHist ); \ 11.143 + printHist( _VMSMasterEnv->masterLockHighTimeHist ); 11.144 + 11.145 +#else 11.146 + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv 11.147 + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas 11.148 + #define MEAS__Capture_Pre_Master_Lock_Point 11.149 + #define MEAS__Capture_Post_Master_Lock_Point 11.150 + #define MEAS__Print_Hists_for_Master_Lock_Meas 11.151 +#endif 11.152 + 11.153 + 11.154 +#ifdef MEAS__TURN_ON_MALLOC_MEAS 11.155 + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ 11.156 + Histogram *mallocTimeHist; \ 11.157 + Histogram *freeTimeHist; 11.158 + 11.159 + #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ 11.160 + _VMSMasterEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 11.161 + "malloc_time_hist");\ 11.162 + _VMSMasterEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 11.163 + "free_time_hist"); 11.164 + 11.165 + #define MEAS__Capture_Pre_Malloc_Point \ 11.166 + int32 startStamp, endStamp; \ 11.167 + saveLowTimeStampCountInto( startStamp ); 11.168 + 11.169 + #define MEAS__Capture_Post_Malloc_Point \ 11.170 + saveLowTimeStampCountInto( endStamp ); \ 11.171 + addIntervalToHist( startStamp, endStamp,\ 11.172 + _VMSMasterEnv->mallocTimeHist ); 11.173 + 11.174 + #define MEAS__Capture_Pre_Free_Point \ 11.175 + int32 startStamp, endStamp; \ 11.176 + saveLowTimeStampCountInto( startStamp ); 11.177 + 11.178 + #define MEAS__Capture_Post_Free_Point \ 11.179 + saveLowTimeStampCountInto( endStamp ); \ 11.180 + addIntervalToHist( startStamp, endStamp,\ 11.181 + _VMSMasterEnv->freeTimeHist ); 11.182 + 11.183 + #define MEAS__Print_Hists_for_Malloc_Meas \ 11.184 + printHist( _VMSMasterEnv->mallocTimeHist ); \ 11.185 + saveHistToFile( _VMSMasterEnv->mallocTimeHist ); \ 11.186 + printHist( _VMSMasterEnv->freeTimeHist ); \ 11.187 + saveHistToFile( _VMSMasterEnv->freeTimeHist ); \ 11.188 + freeHistExt( _VMSMasterEnv->mallocTimeHist ); \ 11.189 + freeHistExt( _VMSMasterEnv->freeTimeHist ); 11.190 + 11.191 +#else 11.192 + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv 11.193 + #define MEAS__Make_Meas_Hists_for_Malloc_Meas 11.194 + #define MEAS__Capture_Pre_Malloc_Point 11.195 + #define MEAS__Capture_Post_Malloc_Point 11.196 + #define MEAS__Capture_Pre_Free_Point 11.197 + #define MEAS__Capture_Post_Free_Point 11.198 + #define MEAS__Print_Hists_for_Malloc_Meas 11.199 +#endif 11.200 + 11.201 + 11.202 + 11.203 +#ifdef MEAS__TURN_ON_PLUGIN_MEAS 11.204 + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ 11.205 + Histogram *reqHdlrLowTimeHist; \ 11.206 + Histogram *reqHdlrHighTimeHist; 11.207 + 11.208 + #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ 11.209 + _VMSMasterEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 11.210 + "plugin_low_time_hist");\ 11.211 + _VMSMasterEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 11.212 + "plugin_high_time_hist"); 11.213 + 11.214 + #define MEAS__startReqHdlr \ 11.215 + int32 startStamp1, endStamp1; \ 11.216 + saveLowTimeStampCountInto( startStamp1 ); 11.217 + 11.218 + #define MEAS__endReqHdlr \ 11.219 + saveLowTimeStampCountInto( endStamp1 ); \ 11.220 + addIntervalToHist( startStamp1, endStamp1, \ 11.221 + _VMSMasterEnv->reqHdlrLowTimeHist ); \ 11.222 + addIntervalToHist( startStamp1, endStamp1, \ 11.223 + _VMSMasterEnv->reqHdlrHighTimeHist ); 11.224 + 11.225 + #define MEAS__Print_Hists_for_Plugin_Meas \ 11.226 + printHist( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 11.227 + saveHistToFile( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 11.228 + printHist( _VMSMasterEnv->reqHdlrHighTimeHist ); \ 11.229 + saveHistToFile( _VMSMasterEnv->reqHdlrHighTimeHist ); \ 11.230 + freeHistExt( _VMSMasterEnv->reqHdlrLowTimeHist ); \ 11.231 + freeHistExt( _VMSMasterEnv->reqHdlrHighTimeHist ); 11.232 +#else 11.233 + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv 11.234 + #define MEAS__Make_Meas_Hists_for_Plugin_Meas 11.235 + #define MEAS__startReqHdlr 11.236 + #define MEAS__endReqHdlr 11.237 + #define MEAS__Print_Hists_for_Plugin_Meas 11.238 + 11.239 +#endif 11.240 + 11.241 + 11.242 +#ifdef MEAS__TURN_ON_SYSTEM_MEAS 11.243 + #define MEAS__Insert_System_Meas_Fields_into_Slave \ 11.244 + TSCountLowHigh startSusp; \ 11.245 + uint64 totalSuspCycles; \ 11.246 + uint32 numGoodSusp; 11.247 + 11.248 + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ 11.249 + TSCountLowHigh startMaster; \ 11.250 + uint64 totalMasterCycles; \ 11.251 + uint32 numMasterAnimations; \ 11.252 + TSCountLowHigh startReqHdlr; \ 11.253 + uint64 totalPluginCycles; \ 11.254 + uint32 numPluginAnimations; \ 11.255 + uint64 cyclesTillStartMasterLoop; \ 11.256 + TSCountLowHigh endMasterLoop; 11.257 + 11.258 + #define MEAS__startMasterLoop_forSys \ 11.259 + TSCountLowHigh startStamp1, endStamp1; \ 11.260 + saveTSCLowHigh( endStamp1 ); \ 11.261 + _VMSMasterEnv->cyclesTillStartMasterLoop = \ 11.262 + endStamp1.longVal - masterVP->startSusp.longVal; 11.263 + 11.264 + #define Meas_startReqHdlr_forSys \ 11.265 + saveTSCLowHigh( startStamp1 ); \ 11.266 + _VMSMasterEnv->startReqHdlr.longVal = startStamp1.longVal; 11.267 + 11.268 + #define MEAS__endMasterLoop_forSys \ 11.269 + saveTSCLowHigh( startStamp1 ); \ 11.270 + _VMSMasterEnv->endMasterLoop.longVal = startStamp1.longVal; 11.271 + 11.272 + /*A TSC is stored in VP first thing inside wrapper-lib 11.273 + * Now, measures cycles from there to here 11.274 + * Master and Plugin will add this value to other trace-seg measures 11.275 + */ 11.276 + #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys\ 11.277 + saveTSCLowHigh(endSusp); \ 11.278 + numCycles = endSusp.longVal - currVP->startSusp.longVal; \ 11.279 + /*sanity check (400K is about 20K iters)*/ \ 11.280 + if( numCycles < 400000 ) \ 11.281 + { currVP->totalSuspCycles += numCycles; \ 11.282 + currVP->numGoodSusp++; \ 11.283 + } \ 11.284 + /*recorded every time, but only read if currVP == MasterVP*/ \ 11.285 + _VMSMasterEnv->startMaster.longVal = endSusp.longVal; 11.286 + 11.287 +#else 11.288 + #define MEAS__Insert_System_Meas_Fields_into_Slave 11.289 + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv 11.290 + #define MEAS__Make_Meas_Hists_for_System_Meas 11.291 + #define MEAS__startMasterLoop_forSys 11.292 + #define MEAS__startReqHdlr_forSys 11.293 + #define MEAS__endMasterLoop_forSys 11.294 + #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys 11.295 + #define MEAS__Print_Hists_for_System_Meas 11.296 +#endif 11.297 + 11.298 + 11.299 +//Experiment in two-step macros -- if doesn't work, insert each separately 11.300 +#define MEAS__Insert_Meas_Fields_into_Slave \ 11.301 + MEAS__Insert_Susp_Meas_Fields_into_Slave \ 11.302 + MEAS__Insert_Master_Meas_Fields_into_Slave \ 11.303 + MEAS__Insert_System_Meas_Fields_into_Slave 11.304 + 11.305 + 11.306 +//====================== Histogram Macros -- Create ======================== 11.307 +// 11.308 +// 11.309 + 11.310 +//The language implementation should include a definition of this macro, 11.311 +// which creates all the histograms the language uses to collect measurements 11.312 +// of plugin operation -- so, if the language didn't define it, must 11.313 +// define it here (as empty), to avoid compile error 11.314 +#ifndef MEAS__Make_Meas_Hists_for_Language 11.315 +#define MEAS__Make_Meas_Hists_for_Language 11.316 +#endif 11.317 + 11.318 +#define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ 11.319 + makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \ 11.320 + _VMSMasterEnv->measHists[idx] = \ 11.321 + makeFixedBinHist( numBins, startVal, binWidth, name ); 11.322 + 11.323 +//============================== Probes =================================== 11.324 + 11.325 + 11.326 +//=========================================================================== 11.327 +#endif /* _VMS_DEFS_MEAS_H */ 11.328 +
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/Services_Offered_by_VMS/Measurement_and_Stats/probes.c Tue Mar 13 18:28:04 2012 -0700 12.3 @@ -0,0 +1,303 @@ 12.4 +/* 12.5 + * Copyright 2010 OpenSourceStewardshipFoundation 12.6 + * 12.7 + * Licensed under BSD 12.8 + */ 12.9 + 12.10 +#include <stdio.h> 12.11 +#include <malloc.h> 12.12 +#include <sys/time.h> 12.13 + 12.14 +#include "VMS_impl/VMS.h" 12.15 + 12.16 + 12.17 + 12.18 +//==================== Probes ================= 12.19 +/* 12.20 + * In practice, probe operations are called from the app, from inside slaves 12.21 + * -- so have to be sure each probe is single-Slv owned, and be sure that 12.22 + * any place common structures are modified it's done inside the master. 12.23 + * So -- the only place common structures are modified is during creation. 12.24 + * after that, all mods are to individual instances. 12.25 + * 12.26 + * Thniking perhaps should change the semantics to be that probes are 12.27 + * attached to the virtual processor -- and then everything is guaranteed 12.28 + * to be isolated -- except then can't take any intervals that span Slvs, 12.29 + * and would have to transfer the probes to Master env when Slv dissipates.. 12.30 + * gets messy.. 12.31 + * 12.32 + * For now, just making so that probe creation causes a suspend, so that 12.33 + * the dynamic array in the master env is only modified from the master 12.34 + * 12.35 + */ 12.36 + 12.37 +//============================ Helpers =========================== 12.38 +inline void 12.39 +doNothing() 12.40 + { 12.41 + } 12.42 + 12.43 +float64 inline 12.44 +giveInterval( struct timeval _start, struct timeval _end ) 12.45 + { float64 start, end; 12.46 + start = _start.tv_sec + _start.tv_usec / 1000000.0; 12.47 + end = _end.tv_sec + _end.tv_usec / 1000000.0; 12.48 + return end - start; 12.49 + } 12.50 + 12.51 +//================================================================= 12.52 +IntervalProbe * 12.53 +create_generic_probe( char *nameStr, SlaveVP *animSlv ) 12.54 + { 12.55 + VMSSemReq reqData; 12.56 + 12.57 + reqData.reqType = createProbe; 12.58 + reqData.nameStr = nameStr; 12.59 + 12.60 + VMS_WL__send_VMSSem_request( &reqData, animSlv ); 12.61 + 12.62 + return animSlv->dataRetFromReq; 12.63 + } 12.64 + 12.65 +/*Use this version from outside VMS -- it uses external malloc, and modifies 12.66 + * dynamic array, so can't be animated in a slave Slv 12.67 + */ 12.68 +IntervalProbe * 12.69 +ext__create_generic_probe( char *nameStr ) 12.70 + { IntervalProbe *newProbe; 12.71 + int32 nameLen; 12.72 + 12.73 + newProbe = malloc( sizeof(IntervalProbe) ); 12.74 + nameLen = strlen( nameStr ); 12.75 + newProbe->nameStr = malloc( nameLen ); 12.76 + memcpy( newProbe->nameStr, nameStr, nameLen ); 12.77 + newProbe->hist = NULL; 12.78 + newProbe->schedChoiceWasRecorded = FALSE; 12.79 + newProbe->probeID = 12.80 + addToDynArray( newProbe, _VMSMasterEnv->dynIntervalProbesInfo ); 12.81 + 12.82 + return newProbe; 12.83 + } 12.84 + 12.85 +//============================ Fns def in header ======================= 12.86 + 12.87 +int32 12.88 +VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ) 12.89 + { IntervalProbe *newProbe; 12.90 + 12.91 + newProbe = create_generic_probe( nameStr, animSlv ); 12.92 + 12.93 + return newProbe->probeID; 12.94 + } 12.95 + 12.96 +int32 12.97 +VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 12.98 + float64 binWidth, char *nameStr, SlaveVP *animSlv ) 12.99 + { IntervalProbe *newProbe; 12.100 + 12.101 + newProbe = create_generic_probe( nameStr, animSlv ); 12.102 + 12.103 +#ifdef PROBES__USE_TIME_OF_DAY_PROBES 12.104 + DblHist *hist; 12.105 + hist = makeDblHistogram( numBins, startValue, binWidth ); 12.106 +#else 12.107 + Histogram *hist; 12.108 + hist = makeHistogram( numBins, startValue, binWidth ); 12.109 +#endif 12.110 + newProbe->hist = hist; 12.111 + return newProbe->probeID; 12.112 + } 12.113 + 12.114 + 12.115 +int32 12.116 +VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv) 12.117 + { IntervalProbe *newProbe; 12.118 + struct timeval *startStamp; 12.119 + float64 startSecs; 12.120 + 12.121 + newProbe = create_generic_probe( nameStr, animSlv ); 12.122 + newProbe->endSecs = 0; 12.123 + 12.124 + 12.125 + gettimeofday( &(newProbe->startStamp), NULL); 12.126 + 12.127 + //turn into a double 12.128 + startStamp = &(newProbe->startStamp); 12.129 + startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); 12.130 + newProbe->startSecs = startSecs; 12.131 + 12.132 + return newProbe->probeID; 12.133 + } 12.134 + 12.135 +int32 12.136 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ) 12.137 + { IntervalProbe *newProbe; 12.138 + struct timeval *startStamp; 12.139 + float64 startSecs; 12.140 + 12.141 + newProbe = ext__create_generic_probe( nameStr ); 12.142 + newProbe->endSecs = 0; 12.143 + 12.144 + gettimeofday( &(newProbe->startStamp), NULL); 12.145 + 12.146 + //turn into a double 12.147 + startStamp = &(newProbe->startStamp); 12.148 + startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); 12.149 + newProbe->startSecs = startSecs; 12.150 + 12.151 + return newProbe->probeID; 12.152 + } 12.153 + 12.154 + 12.155 +/*Only call from inside master or main startup/shutdown thread 12.156 + */ 12.157 +void 12.158 +VMS_impl__free_probe( IntervalProbe *probe ) 12.159 + { if( probe->hist != NULL ) freeDblHist( probe->hist ); 12.160 + if( probe->nameStr != NULL) VMS_int__free( probe->nameStr ); 12.161 + VMS_int__free( probe ); 12.162 + } 12.163 + 12.164 + 12.165 +void 12.166 +VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ) 12.167 + { IntervalProbe *probe; 12.168 + 12.169 + //TODO: fix this To be in Master -- race condition 12.170 + probe = _VMSMasterEnv->intervalProbes[ probeID ]; 12.171 + 12.172 + addValueIntoTable(probe->nameStr, probe, _VMSMasterEnv->probeNameHashTbl); 12.173 + } 12.174 + 12.175 + 12.176 +IntervalProbe * 12.177 +VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ) 12.178 + { 12.179 + //TODO: fix this To be in Master -- race condition 12.180 + return getValueFromTable( probeName, _VMSMasterEnv->probeNameHashTbl ); 12.181 + } 12.182 + 12.183 + 12.184 +/*Everything is local to the animating slaveVP, so no need for request, do 12.185 + * work locally, in the anim Slv 12.186 + */ 12.187 +void 12.188 +VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animatingSlv ) 12.189 + { IntervalProbe *probe; 12.190 + 12.191 + probe = _VMSMasterEnv->intervalProbes[ probeID ]; 12.192 + probe->schedChoiceWasRecorded = TRUE; 12.193 + probe->coreNum = animatingSlv->coreAnimatedBy; 12.194 + probe->slaveID = animatingSlv->slaveID; 12.195 + probe->slaveCreateSecs = animatingSlv->createPtInSecs; 12.196 + } 12.197 + 12.198 +/*Everything is local to the animating slaveVP, so no need for request, do 12.199 + * work locally, in the anim Slv 12.200 + */ 12.201 +void 12.202 +VMS_impl__record_interval_start_in_probe( int32 probeID ) 12.203 + { IntervalProbe *probe; 12.204 + 12.205 + DEBUG_Print( dbgProbes, "record start of interval\n" ) 12.206 + probe = _VMSMasterEnv->intervalProbes[ probeID ]; 12.207 + 12.208 + //record *start* point as last thing, after lookup 12.209 +#ifdef PROBES__USE_TIME_OF_DAY_PROBES 12.210 + gettimeofday( &(probe->startStamp), NULL); 12.211 +#endif 12.212 +#ifdef PROBES__USE_TSC_PROBES 12.213 + probe->startStamp = getTSCount(); 12.214 +#endif 12.215 + } 12.216 + 12.217 + 12.218 +/*Everything is local to the animating slaveVP, except the histogram, so do 12.219 + * work locally, in the anim Slv -- may lose a few histogram counts 12.220 + * 12.221 + *This should be safe to run inside SlaveVP 12.222 + */ 12.223 +void 12.224 +VMS_impl__record_interval_end_in_probe( int32 probeID ) 12.225 + { IntervalProbe *probe; 12.226 + 12.227 + //Record first thing -- before looking up the probe to store it into 12.228 +#ifdef PROBES__USE_TIME_OF_DAY_PROBES 12.229 + struct timeval endStamp; 12.230 + gettimeofday( &(endStamp), NULL); 12.231 +#endif 12.232 +#ifdef PROBES__USE_TSC_PROBES 12.233 + TSCount endStamp, interval; 12.234 + endStamp = getTSCount(); 12.235 +#endif 12.236 +#ifdef PROBES__USE_PERF_CTR_PROBES 12.237 + 12.238 +#endif 12.239 + 12.240 + probe = _VMSMasterEnv->intervalProbes[ probeID ]; 12.241 + 12.242 +#ifdef PROBES__USE_TIME_OF_DAY_PROBES 12.243 + if( probe->hist != NULL ) 12.244 + { addToDblHist( giveInterval( probe->startStamp, endStamp), probe->hist ); 12.245 + } 12.246 +#endif 12.247 +#ifdef PROBES__USE_TSC_PROBES 12.248 + if( probe->hist != NULL ) 12.249 + { interval = probe->endStamp - probe->startStamp; 12.250 + //Sanity check for TSC counter overflow: if sane, add to histogram 12.251 + if( interval < probe->hist->endOfRange * 10 ) 12.252 + addToHist( interval, probe->hist ); 12.253 + } 12.254 +#endif 12.255 +#ifdef PROBES__USE_PERF_CTR_PROBES 12.256 + 12.257 +#endif 12.258 + 12.259 + DEBUG_Print( dbgProbes, "record end of interval\n" ) 12.260 + } 12.261 + 12.262 + 12.263 +void 12.264 +print_probe_helper( IntervalProbe *probe ) 12.265 + { 12.266 + printf( "\nprobe: %s, ", probe->nameStr ); 12.267 + 12.268 + 12.269 + if( probe->schedChoiceWasRecorded ) 12.270 + { printf( "coreNum: %d, slaveID: %d, slaveVPCreated: %0.6f | ", 12.271 + probe->coreNum, probe->slaveID, probe->slaveCreateSecs ); 12.272 + } 12.273 + 12.274 + if( probe->endSecs == 0 ) //just a single point in time 12.275 + { 12.276 + printf( " time point: %.6f\n", 12.277 + probe->startSecs - _VMSMasterEnv->createPtInSecs ); 12.278 + } 12.279 + else if( probe->hist == NULL ) //just an interval 12.280 + { 12.281 + printf( " startSecs: %.6f interval: %.6f\n", 12.282 + (probe->startSecs - _VMSMasterEnv->createPtInSecs), probe->interval); 12.283 + } 12.284 + else //a full histogram of intervals 12.285 + { 12.286 + printDblHist( probe->hist ); 12.287 + } 12.288 + } 12.289 + 12.290 +void 12.291 +VMS_impl__print_stats_of_probe( IntervalProbe *probe ) 12.292 + { 12.293 + 12.294 +// probe = _VMSMasterEnv->intervalProbes[ probeID ]; 12.295 + 12.296 + print_probe_helper( probe ); 12.297 + } 12.298 + 12.299 + 12.300 +void 12.301 +VMS_impl__print_stats_of_all_probes() 12.302 + { 12.303 + forAllInDynArrayDo( _VMSMasterEnv->dynIntervalProbesInfo, 12.304 + (DynArrayFnPtr) &VMS_impl__print_stats_of_probe ); 12.305 + fflush( stdout ); 12.306 + }
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/Services_Offered_by_VMS/Measurement_and_Stats/probes.h Tue Mar 13 18:28:04 2012 -0700 13.3 @@ -0,0 +1,192 @@ 13.4 +/* 13.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 13.6 + * Licensed under GNU General Public License version 2 13.7 + * 13.8 + * Author: seanhalle@yahoo.com 13.9 + * 13.10 + */ 13.11 + 13.12 +#ifndef _PROBES_H 13.13 +#define _PROBES_H 13.14 +#define _GNU_SOURCE 13.15 + 13.16 +#include "VMS_impl/VMS_primitive_data_types.h" 13.17 + 13.18 +#include <sys/time.h> 13.19 + 13.20 +/*Note on order of include files: 13.21 + * This file relies on #defines that appear in other files, which must come 13.22 + * first in the #include sequence.. 13.23 + */ 13.24 + 13.25 +/*Use these aliases in application code*/ 13.26 +#define VMS_App__record_time_point_into_new_probe VMS_WL__record_time_point_into_new_probe 13.27 +#define VMS_App__create_single_interval_probe VMS_WL__create_single_interval_probe 13.28 +#define VMS_App__create_histogram_probe VMS_WL__create_histogram_probe 13.29 +#define VMS_App__index_probe_by_its_name VMS_WL__index_probe_by_its_name 13.30 +#define VMS_App__get_probe_by_name VMS_WL__get_probe_by_name 13.31 +#define VMS_App__record_sched_choice_into_probe VMS_WL__record_sched_choice_into_probe 13.32 +#define VMS_App__record_interval_start_in_probe VMS_WL__record_interval_start_in_probe 13.33 +#define VMS_App__record_interval_end_in_probe VMS_WL__record_interval_end_in_probe 13.34 +#define VMS_App__print_stats_of_probe VMS_WL__print_stats_of_probe 13.35 +#define VMS_App__print_stats_of_all_probes VMS_WL__print_stats_of_all_probes 13.36 + 13.37 + 13.38 +//========================== 13.39 +#ifdef PROBES__USE_TSC_PROBES 13.40 + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ 13.41 + TSCount startStamp; \ 13.42 + TSCount endStamp; \ 13.43 + TSCount interval; \ 13.44 + Histogram *hist; /*if left NULL, then is single interval probe*/ 13.45 +#endif 13.46 +#ifdef PROBES__USE_TIME_OF_DAY_PROBES 13.47 + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ 13.48 + struct timeval startStamp; \ 13.49 + struct timeval endStamp; \ 13.50 + float64 startSecs; \ 13.51 + float64 endSecs; \ 13.52 + float64 interval; \ 13.53 + DblHist *hist; /*if NULL, then is single interval probe*/ 13.54 +#endif 13.55 +#ifdef PROBES__USE_PERF_CTR_PROBES 13.56 + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ 13.57 + int64 startStamp; \ 13.58 + int64 endStamp; \ 13.59 + int64 interval; \ 13.60 + Histogram *hist; /*if left NULL, then is single interval probe*/ 13.61 +#endif 13.62 + 13.63 +//typedef struct _IntervalProbe IntervalProbe; -- is in VMS.h 13.64 +struct _IntervalProbe 13.65 + { 13.66 + char *nameStr; 13.67 + int32 probeID; 13.68 + 13.69 + int32 schedChoiceWasRecorded; 13.70 + int32 coreNum; 13.71 + int32 slaveID; 13.72 + float64 slaveCreateSecs; 13.73 + PROBES__Insert_timestamps_and_intervals_into_probe_struct; 13.74 + }; 13.75 + 13.76 +//=========================== NEVER USE THESE ========================== 13.77 +/*NEVER use these in any code!! These are here only for use in the macros 13.78 + * defined in this file!! 13.79 + */ 13.80 +int32 13.81 +VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ); 13.82 + 13.83 +int32 13.84 +VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 13.85 + float64 binWidth, char *nameStr, SlaveVP *animSlv ); 13.86 + 13.87 +int32 13.88 +VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv); 13.89 + 13.90 +int32 13.91 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); 13.92 + 13.93 +void 13.94 +VMS_impl__free_probe( IntervalProbe *probe ); 13.95 + 13.96 +void 13.97 +VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ); 13.98 + 13.99 +IntervalProbe * 13.100 +VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ); 13.101 + 13.102 +void 13.103 +VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animSlv ); 13.104 + 13.105 +void 13.106 +VMS_impl__record_interval_start_in_probe( int32 probeID ); 13.107 + 13.108 +void 13.109 +VMS_impl__record_interval_end_in_probe( int32 probeID ); 13.110 + 13.111 +void 13.112 +VMS_impl__print_stats_of_probe( IntervalProbe *probe ); 13.113 + 13.114 +void 13.115 +VMS_impl__print_stats_of_all_probes(); 13.116 + 13.117 + 13.118 +//======================== Probes ============================= 13.119 +// 13.120 +// Use macros to allow turning probes off with a #define switch 13.121 +// This means probes have zero impact on performance when off 13.122 +//============================================================= 13.123 + 13.124 +#ifdef PROBES__TURN_ON_STATS_PROBES 13.125 + 13.126 + #define PROBES__Create_Probe_Bookkeeping_Vars \ 13.127 + _VMSMasterEnv->dynIntervalProbesInfo = \ 13.128 + makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->intervalProbes), 200); \ 13.129 + \ 13.130 + _VMSMasterEnv->probeNameHashTbl = makeHashTable( 1000, &VMS_int__free ); \ 13.131 + \ 13.132 + /*put creation time directly into master env, for fast retrieval*/ \ 13.133 + struct timeval timeStamp; \ 13.134 + gettimeofday( &(timeStamp), NULL); \ 13.135 + _VMSMasterEnv->createPtInSecs = \ 13.136 + timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0); 13.137 + 13.138 + #define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) \ 13.139 + VMS_impl__record_time_point_in_new_probe( nameStr, animSlv ) 13.140 + 13.141 + #define VMS_ext__record_time_point_into_new_probe( nameStr ) \ 13.142 + VMS_ext_impl__record_time_point_into_new_probe( nameStr ) 13.143 + 13.144 + #define VMS_WL__create_single_interval_probe( nameStr, animSlv ) \ 13.145 + VMS_impl__create_single_interval_probe( nameStr, animSlv ) 13.146 + 13.147 + #define VMS_WL__create_histogram_probe( numBins, startValue, \ 13.148 + binWidth, nameStr, animSlv ) \ 13.149 + VMS_impl__create_histogram_probe( numBins, startValue, \ 13.150 + binWidth, nameStr, animSlv ) 13.151 + #define VMS_int__free_probe( probe ) \ 13.152 + VMS_impl__free_probe( probe ) 13.153 + 13.154 + #define VMS_WL__index_probe_by_its_name( probeID, animSlv ) \ 13.155 + VMS_impl__index_probe_by_its_name( probeID, animSlv ) 13.156 + 13.157 + #define VMS_WL__get_probe_by_name( probeID, animSlv ) \ 13.158 + VMS_impl__get_probe_by_name( probeName, animSlv ) 13.159 + 13.160 + #define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) \ 13.161 + VMS_impl__record_sched_choice_into_probe( probeID, animSlv ) 13.162 + 13.163 + #define VMS_WL__record_interval_start_in_probe( probeID ) \ 13.164 + VMS_impl__record_interval_start_in_probe( probeID ) 13.165 + 13.166 + #define VMS_WL__record_interval_end_in_probe( probeID ) \ 13.167 + VMS_impl__record_interval_end_in_probe( probeID ) 13.168 + 13.169 + #define VMS_WL__print_stats_of_probe( probeID ) \ 13.170 + VMS_impl__print_stats_of_probe( probeID ) 13.171 + 13.172 + #define VMS_WL__print_stats_of_all_probes() \ 13.173 + VMS_impl__print_stats_of_all_probes() 13.174 + 13.175 + 13.176 +#else 13.177 + #define PROBES__Create_Probe_Bookkeeping_Vars 13.178 + #define VMS_WL__record_time_point_into_new_probe( nameStr, animSlv ) 0 /* do nothing */ 13.179 + #define VMS_ext__record_time_point_into_new_probe( nameStr ) 0 /* do nothing */ 13.180 + #define VMS_WL__create_single_interval_probe( nameStr, animSlv ) 0 /* do nothing */ 13.181 + #define VMS_WL__create_histogram_probe( numBins, startValue, \ 13.182 + binWidth, nameStr, animSlv ) \ 13.183 + 0 /* do nothing */ 13.184 + #define VMS_WL__index_probe_by_its_name( probeID, animSlv ) /* do nothing */ 13.185 + #define VMS_WL__get_probe_by_name( probeID, animSlv ) NULL /* do nothing */ 13.186 + #define VMS_WL__record_sched_choice_into_probe( probeID, animSlv ) /* do nothing */ 13.187 + #define VMS_WL__record_interval_start_in_probe( probeID ) /* do nothing */ 13.188 + #define VMS_WL__record_interval_end_in_probe( probeID ) /* do nothing */ 13.189 + #define VMS_WL__print_stats_of_probe( probeID ) ; /* do nothing */ 13.190 + #define VMS_WL__print_stats_of_all_probes() ;/* do nothing */ 13.191 + 13.192 +#endif /* defined PROBES__TURN_ON_STATS_PROBES */ 13.193 + 13.194 +#endif /* _PROBES_H */ 13.195 +
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/Services_Offered_by_VMS/Memory_Handling/vmalloc.c Tue Mar 13 18:28:04 2012 -0700 14.3 @@ -0,0 +1,375 @@ 14.4 +/* 14.5 + * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 14.6 + * Licensed under GNU General Public License version 2 14.7 + * 14.8 + * Author: seanhalle@yahoo.com 14.9 + * 14.10 + * Created on November 14, 2009, 9:07 PM 14.11 + */ 14.12 + 14.13 +#include <malloc.h> 14.14 +#include <inttypes.h> 14.15 +#include <stdlib.h> 14.16 +#include <stdio.h> 14.17 +#include <string.h> 14.18 +#include <math.h> 14.19 + 14.20 +#include "VMS_impl/VMS.h" 14.21 +#include "Histogram/Histogram.h" 14.22 + 14.23 +#define MAX_UINT64 0xFFFFFFFFFFFFFFFF 14.24 + 14.25 +//A MallocProlog is a head element if the HigherInMem variable is NULL 14.26 +//A Chunk is free if the prevChunkInFreeList variable is NULL 14.27 + 14.28 +/* 14.29 + * This calculates the container which fits the given size. 14.30 + */ 14.31 +inline 14.32 +uint32 getContainer(size_t size) 14.33 +{ 14.34 + return (log2(size)-LOG128)/LOG54; 14.35 +} 14.36 + 14.37 +/* 14.38 + * Removes the first chunk of a freeList 14.39 + * The chunk is removed but not set as free. There is no check if 14.40 + * the free list is empty, so make sure this is not the case. 14.41 + */ 14.42 +inline 14.43 +MallocProlog *removeChunk(MallocArrays* freeLists, uint32 containerIdx) 14.44 +{ 14.45 + MallocProlog** container = &freeLists->bigChunks[containerIdx]; 14.46 + MallocProlog* removedChunk = *container; 14.47 + *container = removedChunk->nextChunkInFreeList; 14.48 + 14.49 + if(removedChunk->nextChunkInFreeList) 14.50 + removedChunk->nextChunkInFreeList->prevChunkInFreeList = 14.51 + (MallocProlog*)container; 14.52 + 14.53 + if(*container == NULL) 14.54 + { 14.55 + if(containerIdx < 64) 14.56 + freeLists->bigChunksSearchVector[0] &= ~((uint64)1 << containerIdx); 14.57 + else 14.58 + freeLists->bigChunksSearchVector[1] &= ~((uint64)1 << (containerIdx-64)); 14.59 + } 14.60 + 14.61 + return removedChunk; 14.62 +} 14.63 + 14.64 +/* 14.65 + * Removes the first chunk of a freeList 14.66 + * The chunk is removed but not set as free. There is no check if 14.67 + * the free list is empty, so make sure this is not the case. 14.68 + */ 14.69 +inline 14.70 +MallocProlog *removeSmallChunk(MallocArrays* freeLists, uint32 containerIdx) 14.71 +{ 14.72 + MallocProlog** container = &freeLists->smallChunks[containerIdx]; 14.73 + MallocProlog* removedChunk = *container; 14.74 + *container = removedChunk->nextChunkInFreeList; 14.75 + 14.76 + if(removedChunk->nextChunkInFreeList) 14.77 + removedChunk->nextChunkInFreeList->prevChunkInFreeList = 14.78 + (MallocProlog*)container; 14.79 + 14.80 + return removedChunk; 14.81 +} 14.82 + 14.83 +inline 14.84 +size_t getChunkSize(MallocProlog* chunk) 14.85 +{ 14.86 + return (uintptr_t)chunk->nextHigherInMem - 14.87 + (uintptr_t)chunk - sizeof(MallocProlog); 14.88 +} 14.89 + 14.90 +/* 14.91 + * Removes a chunk from a free list. 14.92 + */ 14.93 +inline 14.94 +void extractChunk(MallocProlog* chunk, MallocArrays *freeLists) 14.95 +{ 14.96 + chunk->prevChunkInFreeList->nextChunkInFreeList = chunk->nextChunkInFreeList; 14.97 + if(chunk->nextChunkInFreeList) 14.98 + chunk->nextChunkInFreeList->prevChunkInFreeList = chunk->prevChunkInFreeList; 14.99 + 14.100 + //The last element in the list points to the container. If the container points 14.101 + //to NULL the container is empty 14.102 + if(*((void**)(chunk->prevChunkInFreeList)) == NULL && getChunkSize(chunk) >= BIG_LOWER_BOUND) 14.103 + { 14.104 + //Find the approppiate container because we do not know it 14.105 + uint64 containerIdx = ((uintptr_t)chunk->prevChunkInFreeList - (uintptr_t)freeLists->bigChunks) >> 3; 14.106 + if(containerIdx < (uint32)64) 14.107 + freeLists->bigChunksSearchVector[0] &= ~((uint64)1 << containerIdx); 14.108 + if(containerIdx < 128 && containerIdx >=64) 14.109 + freeLists->bigChunksSearchVector[1] &= ~((uint64)1 << (containerIdx-64)); 14.110 + 14.111 + } 14.112 +} 14.113 + 14.114 +/* 14.115 + * Merges two chunks. 14.116 + * Chunk A has to be before chunk B in memory. Both have to be removed from 14.117 + * a free list 14.118 + */ 14.119 +inline 14.120 +MallocProlog *mergeChunks(MallocProlog* chunkA, MallocProlog* chunkB) 14.121 +{ 14.122 + chunkA->nextHigherInMem = chunkB->nextHigherInMem; 14.123 + chunkB->nextHigherInMem->nextLowerInMem = chunkA; 14.124 + return chunkA; 14.125 +} 14.126 +/* 14.127 + * Inserts a chunk into a free list. 14.128 + */ 14.129 +inline 14.130 +void insertChunk(MallocProlog* chunk, MallocProlog** container) 14.131 +{ 14.132 + chunk->nextChunkInFreeList = *container; 14.133 + chunk->prevChunkInFreeList = (MallocProlog*)container; 14.134 + if(*container) 14.135 + (*container)->prevChunkInFreeList = chunk; 14.136 + *container = chunk; 14.137 +} 14.138 + 14.139 +/* 14.140 + * Divides the chunk that a new chunk of newSize is created. 14.141 + * There is no size check, so make sure the size value is valid. 14.142 + */ 14.143 +inline 14.144 +MallocProlog *divideChunk(MallocProlog* chunk, size_t newSize) 14.145 +{ 14.146 + MallocProlog* newChunk = (MallocProlog*)((uintptr_t)chunk->nextHigherInMem - 14.147 + newSize - sizeof(MallocProlog)); 14.148 + 14.149 + newChunk->nextLowerInMem = chunk; 14.150 + newChunk->nextHigherInMem = chunk->nextHigherInMem; 14.151 + 14.152 + chunk->nextHigherInMem->nextLowerInMem = newChunk; 14.153 + chunk->nextHigherInMem = newChunk; 14.154 + 14.155 + return newChunk; 14.156 +} 14.157 + 14.158 +/* 14.159 + * Search for chunk in the list of big chunks. Split the block if it's too big 14.160 + */ 14.161 +inline 14.162 +MallocProlog *searchChunk(MallocArrays *freeLists, size_t sizeRequested, uint32 containerIdx) 14.163 +{ 14.164 + MallocProlog* foundChunk; 14.165 + 14.166 + uint64 searchVector = freeLists->bigChunksSearchVector[0]; 14.167 + //set small chunk bits to zero 14.168 + searchVector &= MAX_UINT64 << containerIdx; 14.169 + containerIdx = __builtin_ffsl(searchVector); 14.170 + 14.171 + if(containerIdx == 0) 14.172 + { 14.173 + searchVector = freeLists->bigChunksSearchVector[1]; 14.174 + containerIdx = __builtin_ffsl(searchVector); 14.175 + if(containerIdx == 0) 14.176 + { 14.177 + printf("VMS malloc failed: low memory"); 14.178 + exit(1); 14.179 + } 14.180 + containerIdx += 64; 14.181 + } 14.182 + containerIdx--; 14.183 + 14.184 + 14.185 + foundChunk = removeChunk(freeLists, containerIdx); 14.186 + size_t chunkSize = getChunkSize(foundChunk); 14.187 + 14.188 + //If the new chunk is larger than the requested size: split 14.189 + if(chunkSize > sizeRequested + 2 * sizeof(MallocProlog) + BIG_LOWER_BOUND) 14.190 + { 14.191 + MallocProlog *newChunk = divideChunk(foundChunk,sizeRequested); 14.192 + containerIdx = getContainer(getChunkSize(foundChunk)) - 1; 14.193 + insertChunk(foundChunk,&freeLists->bigChunks[containerIdx]); 14.194 + if(containerIdx < 64) 14.195 + freeLists->bigChunksSearchVector[0] |= ((uint64)1 << containerIdx); 14.196 + else 14.197 + freeLists->bigChunksSearchVector[1] |= ((uint64)1 << (containerIdx-64)); 14.198 + foundChunk = newChunk; 14.199 + } 14.200 + 14.201 + return foundChunk; 14.202 +} 14.203 + 14.204 + 14.205 +/* 14.206 + * This is sequential code, meant to only be called from the Master, not from 14.207 + * any slave Slvs. 14.208 + */ 14.209 +void * 14.210 +VMS_int__malloc( size_t sizeRequested ) 14.211 + { 14.212 + MEAS__Capture_Pre_Malloc_Point 14.213 + 14.214 + MallocArrays* freeLists = _VMSMasterEnv->freeLists; 14.215 + MallocProlog* foundChunk; 14.216 + 14.217 + //Return a small chunk if the requested size is smaller than 128B 14.218 + if(sizeRequested <= LOWER_BOUND) 14.219 + { 14.220 + uint32 freeListIdx = (sizeRequested-1)/SMALL_CHUNK_SIZE; 14.221 + if(freeLists->smallChunks[freeListIdx] == NULL) 14.222 + foundChunk = searchChunk(freeLists, SMALL_CHUNK_SIZE*(freeListIdx+1), 0); 14.223 + else 14.224 + foundChunk = removeSmallChunk(freeLists, freeListIdx); 14.225 + 14.226 + //Mark as allocated 14.227 + foundChunk->prevChunkInFreeList = NULL; 14.228 + return foundChunk + 1; 14.229 + } 14.230 + 14.231 + //Calculate the expected container. Start one higher to have a Chunk that's 14.232 + //always big enough. 14.233 + uint32 containerIdx = getContainer(sizeRequested); 14.234 + 14.235 + if(freeLists->bigChunks[containerIdx] == NULL) 14.236 + foundChunk = searchChunk(freeLists, sizeRequested, containerIdx); 14.237 + else 14.238 + foundChunk = removeChunk(freeLists, containerIdx); 14.239 + 14.240 + //Mark as allocated 14.241 + foundChunk->prevChunkInFreeList = NULL; 14.242 + 14.243 + MEAS__Capture_Post_Malloc_Point 14.244 + 14.245 + //skip over the prolog by adding its size to the pointer return 14.246 + return foundChunk + 1; 14.247 + } 14.248 + 14.249 +/* 14.250 + * This is sequential code, meant to only be called from the Master, not from 14.251 + * any slave Slvs. 14.252 + */ 14.253 +void 14.254 +VMS_int__free( void *ptrToFree ) 14.255 + { 14.256 + 14.257 + MEAS__Capture_Pre_Free_Point; 14.258 + 14.259 + MallocArrays* freeLists = _VMSMasterEnv->freeLists; 14.260 + MallocProlog *chunkToFree = (MallocProlog*)ptrToFree - 1; 14.261 + uint32 containerIdx; 14.262 + 14.263 + //Check for free neighbors 14.264 + if(chunkToFree->nextLowerInMem) 14.265 + { 14.266 + if(chunkToFree->nextLowerInMem->prevChunkInFreeList != NULL) 14.267 + {//Chunk is not allocated 14.268 + extractChunk(chunkToFree->nextLowerInMem, freeLists); 14.269 + chunkToFree = mergeChunks(chunkToFree->nextLowerInMem, chunkToFree); 14.270 + } 14.271 + } 14.272 + if(chunkToFree->nextHigherInMem) 14.273 + { 14.274 + if(chunkToFree->nextHigherInMem->prevChunkInFreeList != NULL) 14.275 + {//Chunk is not allocated 14.276 + extractChunk(chunkToFree->nextHigherInMem, freeLists); 14.277 + chunkToFree = mergeChunks(chunkToFree, chunkToFree->nextHigherInMem); 14.278 + } 14.279 + } 14.280 + 14.281 + size_t chunkSize = getChunkSize(chunkToFree); 14.282 + if(chunkSize < BIG_LOWER_BOUND) 14.283 + { 14.284 + containerIdx = (chunkSize/SMALL_CHUNK_SIZE)-1; 14.285 + if(containerIdx > SMALL_CHUNK_COUNT-1) 14.286 + containerIdx = SMALL_CHUNK_COUNT-1; 14.287 + insertChunk(chunkToFree, &freeLists->smallChunks[containerIdx]); 14.288 + } 14.289 + else 14.290 + { 14.291 + containerIdx = getContainer(getChunkSize(chunkToFree)) - 1; 14.292 + insertChunk(chunkToFree, &freeLists->bigChunks[containerIdx]); 14.293 + if(containerIdx < 64) 14.294 + freeLists->bigChunksSearchVector[0] |= (uint64)1 << containerIdx; 14.295 + else 14.296 + freeLists->bigChunksSearchVector[1] |= (uint64)1 << (containerIdx-64); 14.297 + } 14.298 + 14.299 + MEAS__Capture_Post_Free_Point; 14.300 + } 14.301 + 14.302 +/* 14.303 + * Designed to be called from the main thread outside of VMS, during init 14.304 + */ 14.305 +MallocArrays * 14.306 +VMS_ext__create_free_list() 14.307 +{ 14.308 + //Initialize containers for small chunks and fill with zeros 14.309 + _VMSMasterEnv->freeLists = (MallocArrays*)malloc( sizeof(MallocArrays) ); 14.310 + MallocArrays *freeLists = _VMSMasterEnv->freeLists; 14.311 + 14.312 + freeLists->smallChunks = 14.313 + (MallocProlog**)malloc(SMALL_CHUNK_COUNT*sizeof(MallocProlog*)); 14.314 + memset((void*)freeLists->smallChunks, 14.315 + 0,SMALL_CHUNK_COUNT*sizeof(MallocProlog*)); 14.316 + 14.317 + //Calculate number of containers for big chunks 14.318 + uint32 container = getContainer(MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE)+1; 14.319 + freeLists->bigChunks = (MallocProlog**)malloc(container*sizeof(MallocProlog*)); 14.320 + memset((void*)freeLists->bigChunks,0,container*sizeof(MallocProlog*)); 14.321 + freeLists->containerCount = container; 14.322 + 14.323 + //Create first element in lastContainer 14.324 + MallocProlog *firstChunk = malloc( MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE ); 14.325 + if( firstChunk == NULL ) {printf("Can't allocate initial memory\n"); exit(1);} 14.326 + freeLists->memSpace = firstChunk; 14.327 + 14.328 + //Touch memory to avoid page faults 14.329 + void *ptr,*endPtr; 14.330 + endPtr = (void*)firstChunk+MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE; 14.331 + for(ptr = firstChunk; ptr < endPtr; ptr+=PAGE_SIZE) 14.332 + { 14.333 + *(char*)ptr = 0; 14.334 + } 14.335 + 14.336 + firstChunk->nextLowerInMem = NULL; 14.337 + firstChunk->nextHigherInMem = (MallocProlog*)((uintptr_t)firstChunk + 14.338 + MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE - sizeof(MallocProlog)); 14.339 + firstChunk->nextChunkInFreeList = NULL; 14.340 + //previous element in the queue is the container 14.341 + firstChunk->prevChunkInFreeList = &freeLists->bigChunks[container-2]; 14.342 + 14.343 + freeLists->bigChunks[container-2] = firstChunk; 14.344 + //Insert into bit search list 14.345 + if(container <= 65) 14.346 + { 14.347 + freeLists->bigChunksSearchVector[0] = ((uint64)1 << (container-2)); 14.348 + freeLists->bigChunksSearchVector[1] = 0; 14.349 + } 14.350 + else 14.351 + { 14.352 + freeLists->bigChunksSearchVector[0] = 0; 14.353 + freeLists->bigChunksSearchVector[1] = ((uint64)1 << (container-66)); 14.354 + } 14.355 + 14.356 + //Create dummy chunk to mark the top of stack this is of course 14.357 + //never freed 14.358 + MallocProlog *dummyChunk = firstChunk->nextHigherInMem; 14.359 + dummyChunk->nextHigherInMem = dummyChunk+1; 14.360 + dummyChunk->nextLowerInMem = NULL; 14.361 + dummyChunk->nextChunkInFreeList = NULL; 14.362 + dummyChunk->prevChunkInFreeList = NULL; 14.363 + 14.364 + return freeLists; 14.365 + } 14.366 + 14.367 + 14.368 +/*Designed to be called from the main thread outside of VMS, during cleanup 14.369 + */ 14.370 +void 14.371 +VMS_ext__free_free_list( MallocArrays *freeLists ) 14.372 + { 14.373 + free(freeLists->memSpace); 14.374 + free(freeLists->bigChunks); 14.375 + free(freeLists->smallChunks); 14.376 + 14.377 + } 14.378 +
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/Services_Offered_by_VMS/Memory_Handling/vmalloc.h Tue Mar 13 18:28:04 2012 -0700 15.3 @@ -0,0 +1,91 @@ 15.4 +/* 15.5 + * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 15.6 + * Licensed under GNU General Public License version 2 15.7 + * 15.8 + * Author: seanhalle@yahoo.com 15.9 + * 15.10 + * Created on November 14, 2009, 9:07 PM 15.11 + */ 15.12 + 15.13 +#ifndef _VMALLOC_H 15.14 +#define _VMALLOC_H 15.15 + 15.16 +#include <malloc.h> 15.17 +#include <inttypes.h> 15.18 +#include "VMS_impl/VMS_primitive_data_types.h" 15.19 + 15.20 +#define SMALL_CHUNK_SIZE 32 15.21 +#define SMALL_CHUNK_COUNT 4 15.22 +#define LOWER_BOUND 128 //Biggest chunk size that is created for the small chunks 15.23 +#define BIG_LOWER_BOUND 160 //Smallest chunk size that is created for the big chunks 15.24 + 15.25 +#define LOG54 0.3219280948873623 15.26 +#define LOG128 7 15.27 + 15.28 +typedef struct _MallocProlog MallocProlog; 15.29 + 15.30 +struct _MallocProlog 15.31 + { 15.32 + MallocProlog *nextChunkInFreeList; 15.33 + MallocProlog *prevChunkInFreeList; 15.34 + MallocProlog *nextHigherInMem; 15.35 + MallocProlog *nextLowerInMem; 15.36 + }; 15.37 +//MallocProlog 15.38 + 15.39 + typedef struct MallocArrays MallocArrays; 15.40 + 15.41 + struct MallocArrays 15.42 + { 15.43 + MallocProlog **smallChunks; 15.44 + MallocProlog **bigChunks; 15.45 + uint64 bigChunksSearchVector[2]; 15.46 + void *memSpace; 15.47 + uint32 containerCount; 15.48 + }; 15.49 + //MallocArrays 15.50 + 15.51 +typedef struct 15.52 + { 15.53 + MallocProlog *firstChunkInFreeList; 15.54 + int32 numInList; //TODO not used 15.55 + } 15.56 +FreeListHead; 15.57 + 15.58 +void * 15.59 +VMS_int__malloc( size_t sizeRequested ); 15.60 +#define VMS_PI__malloc VMS_int__malloc 15.61 +#define VMS_WL__malloc VMS_int__malloc /*TODO: Bug -- Not protected!! */ 15.62 +#define VMS_App__malloc VMS_int__malloc /*TODO: Bug -- Not protected!! */ 15.63 + 15.64 +void * 15.65 +VMS_int__malloc_aligned( size_t sizeRequested ); 15.66 +#define VMS_PI__malloc_aligned VMS_int__malloc_aligned 15.67 +#define VMS_WL__malloc_aligned VMS_int__malloc_aligned 15.68 + 15.69 +void 15.70 +VMS_int__free( void *ptrToFree ); 15.71 +#define VMS_PI__free VMS_int__free 15.72 +#define VMS_WL__free VMS_int__free /*TODO: Bug -- Not protected!! */ 15.73 +#define VMS_App__free VMS_int__free /*TODO: Bug -- Not protected!! */ 15.74 + 15.75 + 15.76 + 15.77 +/*Allocates memory from the external system -- higher overhead 15.78 + */ 15.79 +void * 15.80 +VMS_ext__malloc_in_ext( size_t sizeRequested ); 15.81 + 15.82 +/*Frees memory that was allocated in the external system -- higher overhead 15.83 + */ 15.84 +void 15.85 +VMS_ext__free_in_ext( void *ptrToFree ); 15.86 + 15.87 + 15.88 +MallocArrays * 15.89 +VMS_ext__create_free_list(); 15.90 + 15.91 +void 15.92 +VMS_ext__free_free_list(MallocArrays *freeLists ); 15.93 + 15.94 +#endif 15.95 \ No newline at end of file
16.1 --- a/VMS.h Tue Mar 13 10:02:06 2012 -0700 16.2 +++ b/VMS.h Tue Mar 13 18:28:04 2012 -0700 16.3 @@ -15,7 +15,7 @@ 16.4 #include "Hash_impl/PrivateHash.h" 16.5 #include "Histogram/Histogram.h" 16.6 #include "Queue_impl/PrivateQueue.h" 16.7 -#include "vmalloc.h" 16.8 +#include "Services_Offered_by_VMS/Memory_Handling/vmalloc.h" 16.9 16.10 #include <pthread.h> 16.11 #include <sys/time.h> 16.12 @@ -24,7 +24,7 @@ 16.13 // 16.14 // Note: ALL defines are in other files, none are in here 16.15 // 16.16 -#include "Defines/VMS_defs__main.h" 16.17 +#include "Defines/VMS_defs.h" 16.18 16.19 16.20 //================================ Typedefs ================================= 16.21 @@ -44,11 +44,11 @@ 16.22 typedef struct _GateStruc GateStruc; 16.23 16.24 16.25 -typedef SlaveVP * (*Sched_Assigner) ( void *, int ); //semEnv, coreIdx 16.26 -typedef void (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv 16.27 -typedef void (*TopLevelFnPtr) ( void *, SlaveVP * ); //initData, animSlv 16.28 -typedef void TopLevelFn ( void *, SlaveVP * ); //initData, animSlv 16.29 -typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); 16.30 +typedef SlaveVP *(*SlaveAssigner) ( void *, int, SchedSlot *); //semEnv, coreIdx, slot for HW info 16.31 +typedef void (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv 16.32 +typedef void (*TopLevelFnPtr) ( void *, SlaveVP * ); //initData, animSlv 16.33 +typedef void TopLevelFn ( void *, SlaveVP * ); //initData, animSlv 16.34 +typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); 16.35 16.36 //============================ HW Dependent Fns ================================ 16.37 16.38 @@ -98,9 +98,10 @@ 16.39 16.40 struct _SchedSlot 16.41 { 16.42 + int slotIdx; //needed by Holistic Model's data gathering 16.43 int workIsDone; 16.44 int needsSlaveAssigned; 16.45 - SlaveVP *slaveAssignedToSlot; 16.46 + SlaveVP *slaveAssignedToSlot; 16.47 }; 16.48 //SchedSlot 16.49 16.50 @@ -140,7 +141,7 @@ 16.51 */ 16.52 typedef struct 16.53 { 16.54 - Sched_Assigner slaveAssigner; 16.55 + SlaveAssigner slaveAssigner; 16.56 RequestHandler requestHandler; 16.57 16.58 SchedSlot ***allSchedSlots; 16.59 @@ -149,13 +150,12 @@ 16.60 16.61 void *semanticEnv; 16.62 void *OSEventStruc; //for future, when add I/O to BLIS 16.63 - MallocArrays *freeLists; 16.64 + MallocArrays *freeLists; 16.65 int32 amtOfOutstandingMem; //total currently allocated 16.66 16.67 void *coreCtlrReturnPt;//addr to jump to to re-enter coreCtlr 16.68 16.69 int32 setupComplete; 16.70 - int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP 16.71 int32 masterLock __align_to_cacheline__; 16.72 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal 16.73 int32 workStealingLock; 16.74 @@ -235,39 +235,6 @@ 16.75 void 16.76 VMS_SS__init(); 16.77 16.78 -//Fix; 16.79 -/*seed-slaveVP creation -- put box around language, have lang register stuff 16.80 - with VMS. 16.81 - have main program explicitly INIT Lang! -- makes more sense to 16.82 - C programmers -- makes it clear that there's a transition. 16.83 -(might need to have the pthreads remain waiting for 16.84 - cond until work is scheduled) 16.85 -Have main do call to tell language to perform work -- like did with DKU 16.86 - 16.87 -Ex: "HWSim__run_a_simulation(netlist, paramBag);" 16.88 - "processID = SSR__run_program(seed_fn, seedData); " 16.89 - "SSR__Wait_for_program_to_end(processID);" 16.90 - "SSR__run_program_and_wait_till_it_ends(seed_fn, seedData);" 16.91 - 16.92 - allows multiple languages to be started, and programs run in several, 16.93 - overlapped, or one program to be run that uses multiple langs..? 16.94 - So, each program is in separate directory: 16.95 - "HWSim_ArchDef__PingPong" "SSR_Program__Blocked_Matrix_Mult" 16.96 - 16.97 - Those programs can talk to each other, via VMS, by handles they each 16.98 - return 16.99 - "processIDs[0] = SSR__run_program(seed_fn1, seedData1);" 16.100 - "processIDs[1] = SSR__run_program(seed_fn2, seedData2);" 16.101 - "SSR__link_programs(processIDs, 2);" 16.102 -or even 16.103 - "processIDs[0] = Vthread__run_program(seed_fn1, seedData1);" 16.104 - "processIDs[1] = SSR__run_program(seed_fn2, seedData2);" 16.105 - "VMS__link_programs(processIDs, 2);" 16.106 - Then, the programs just know they sync with other prog, but use own 16.107 - lang's sync constructs -- VMS uses message system to establish tie-pt, 16.108 - each lang defines what a tie-point means to it.. (work with the 16.109 - diff semantics?) 16.110 -*/ 16.111 void 16.112 VMS_SS__start_the_work_then_wait_until_done(); 16.113 16.114 @@ -360,7 +327,7 @@ 16.115 16.116 16.117 //========================= Probes ======================= 16.118 -#include "Probes/probes.h" 16.119 +#include "Services_Offered_by_VMS/Measurement_and_Stats/probes.h" 16.120 16.121 //================================================ 16.122 #endif /* _VMS_H */
17.1 --- a/VMS__int.c Tue Mar 13 10:02:06 2012 -0700 17.2 +++ b/VMS__int.c Tue Mar 13 18:28:04 2012 -0700 17.3 @@ -64,7 +64,7 @@ 17.4 { 17.5 17.6 //The request to master will cause this suspended Slv to get 17.7 - // scheduled again at some future point -- to resume, core ctlr jumps 17.8 + // assigned again at some future point -- to resume, core ctlr jumps 17.9 // to the resume point (below), which causes restore of saved regs and 17.10 // "return" from this call. 17.11 //animatingSlv->resumeInstrPtr = &&ResumePt; 17.12 @@ -181,8 +181,8 @@ 17.13 VMS_int__strDup( char *str ) 17.14 { char *retStr; 17.15 17.16 + if( str == NULL ) return NULL; 17.17 retStr = (char *)VMS_int__malloc( strlen(str) + 1 ); 17.18 - if( str == NULL ) return str; 17.19 strcpy( retStr, str ); 17.20 17.21 return (char *)retStr;
18.1 --- a/VMS__startup_and_shutdown.c Tue Mar 13 10:02:06 2012 -0700 18.2 +++ b/VMS__startup_and_shutdown.c Tue Mar 13 18:28:04 2012 -0700 18.3 @@ -43,7 +43,7 @@ 18.4 * 1) Semantic layer first calls init_VMS, which creates masterEnv, and puts 18.5 * the master Slv into the work-queue, ready for first "call" 18.6 * 2) Semantic layer then does its own init, which creates the seed virt 18.7 - * slave inside the semantic layer, ready to schedule it when 18.8 + * slave inside the semantic layer, ready to assign it when 18.9 * asked by the first run of the schedulingMaster. 18.10 * 18.11 *This part is bit weird because VMS really wants to be "always there", and 18.12 @@ -52,7 +52,7 @@ 18.13 * 18.14 *The semantic layer is isolated from the VMS internals by making the 18.15 * semantic layer do setup to a state that it's ready with its 18.16 - * initial Slvs, ready to schedule them to slots when the schedulingMaster 18.17 + * initial Slvs, ready to assign them to slots when the schedulingMaster 18.18 * asks. Without this pattern, the semantic layer's setup would 18.19 * have to modify slots directly to assign the initial virt-procrs, and put 18.20 * them into the readyToAnimateQ itself, breaking the isolation completely. 18.21 @@ -113,7 +113,7 @@ 18.22 fprintf(output, "\n"); 18.23 //Meta info gets set by calls from the language during its init, 18.24 // and info registered by calls from inside the application 18.25 - fprintf(output, "# Scheduler: %s\n", _VMSMasterEnv->metaInfo->schedulerInfo); 18.26 + fprintf(output, "# Assigner: %s\n", _VMSMasterEnv->metaInfo->assignerInfo); 18.27 18.28 //-------------------------- 18.29 //Application 18.30 @@ -260,9 +260,9 @@ 18.31 void 18.32 create_masterEnv() 18.33 { MasterEnv *masterEnv; 18.34 - VMSQueueStruc **readyToAnimateQs; 18.35 + VMSQueueStruc **readyToAnimateQs; 18.36 int coreIdx; 18.37 - SlaveVP **masterVPs; 18.38 + SlaveVP **masterVPs; 18.39 SchedSlot ***allSchedSlots; //ptr to array of ptrs 18.40 18.41 18.42 @@ -274,15 +274,15 @@ 18.43 //After this, all other mallocs are VMS__malloc. 18.44 _VMSMasterEnv->freeLists = VMS_ext__create_free_list(); 18.45 18.46 + 18.47 //===================== Only VMS__malloc after this ==================== 18.48 - 18.49 masterEnv = (MasterEnv*)_VMSMasterEnv; 18.50 18.51 //Make a readyToAnimateQ for each core controller 18.52 readyToAnimateQs = VMS_int__malloc( NUM_CORES * sizeof(VMSQueueStruc *) ); 18.53 masterVPs = VMS_int__malloc( NUM_CORES * sizeof(SlaveVP *) ); 18.54 18.55 - //One array for each core, 3 in array, core's masterVP scheds all 18.56 + //One array for each core, several in array, core's masterVP scheds all 18.57 allSchedSlots = VMS_int__malloc( NUM_CORES * sizeof(SchedSlot *) ); 18.58 18.59 _VMSMasterEnv->numSlavesAlive = 0; //used to detect shut-down condition 18.60 @@ -296,7 +296,6 @@ 18.61 masterVPs[ coreIdx ] = VMS_int__create_slaveVP( (TopLevelFnPtr)&schedulingMaster, (void*)masterEnv ); 18.62 masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx; 18.63 allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core 18.64 - _VMSMasterEnv->numMasterInARow[ coreIdx ] = 0; 18.65 _VMSMasterEnv->workStealingGates[ coreIdx ] = NULL; 18.66 } 18.67 _VMSMasterEnv->readyToAnimateQs = readyToAnimateQs; 18.68 @@ -313,19 +312,10 @@ 18.69 MEAS__Make_Meas_Hists_for_Master_Lock_Meas; 18.70 MEAS__Make_Meas_Hists_for_Malloc_Meas; 18.71 MEAS__Make_Meas_Hists_for_Plugin_Meas; 18.72 + MEAS__Make_Meas_Hists_for_Language; 18.73 + 18.74 + PROBES__Create_Probe_Bookkeeping_Vars; 18.75 18.76 - #ifdef PROBES__TURN_ON_STATS_PROBES 18.77 - _VMSMasterEnv->dynIntervalProbesInfo = 18.78 - makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->intervalProbes), 200); 18.79 - 18.80 - _VMSMasterEnv->probeNameHashTbl = makeHashTable( 1000, &VMS_int__free ); 18.81 - 18.82 - //put creation time directly into master env, for fast retrieval 18.83 - struct timeval timeStamp; 18.84 - gettimeofday( &(timeStamp), NULL); 18.85 - _VMSMasterEnv->createPtInSecs = 18.86 - timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0); 18.87 - #endif 18.88 //======================================================================== 18.89 } 18.90 18.91 @@ -343,6 +333,7 @@ 18.92 //Set state to mean "handling requests done, slot needs filling" 18.93 schedSlots[i]->workIsDone = FALSE; 18.94 schedSlots[i]->needsSlaveAssigned = TRUE; 18.95 + schedSlots[i]->slotIdx = i; //quick retrieval of slot pos 18.96 } 18.97 return schedSlots; 18.98 } 18.99 @@ -394,7 +385,7 @@ 18.100 18.101 18.102 void 18.103 -VMS_SS__register_sched_assigner( Sched_Assigner schedAssigner ) 18.104 +VMS_SS__register_sched_assigner( SlaveAssigner schedAssigner ) 18.105 { _VMSMasterEnv->slaveAssigner = schedAssigner; 18.106 } 18.107
19.1 --- a/vmalloc.c Tue Mar 13 10:02:06 2012 -0700 19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 19.3 @@ -1,384 +0,0 @@ 19.4 -/* 19.5 - * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 19.6 - * Licensed under GNU General Public License version 2 19.7 - * 19.8 - * Author: seanhalle@yahoo.com 19.9 - * 19.10 - * Created on November 14, 2009, 9:07 PM 19.11 - */ 19.12 - 19.13 -#include <malloc.h> 19.14 -#include <inttypes.h> 19.15 -#include <stdlib.h> 19.16 -#include <stdio.h> 19.17 -#include <string.h> 19.18 -#include <math.h> 19.19 - 19.20 -#include "VMS.h" 19.21 -#include "Histogram/Histogram.h" 19.22 - 19.23 -#define MAX_UINT64 0xFFFFFFFFFFFFFFFF 19.24 - 19.25 -//A MallocProlog is a head element if the HigherInMem variable is NULL 19.26 -//A Chunk is free if the prevChunkInFreeList variable is NULL 19.27 - 19.28 -/* 19.29 - * This calculates the container which fits the given size. 19.30 - */ 19.31 -inline 19.32 -uint32 getContainer(size_t size) 19.33 -{ 19.34 - return (log2(size)-LOG128)/LOG54; 19.35 -} 19.36 - 19.37 -/* 19.38 - * Removes the first chunk of a freeList 19.39 - * The chunk is removed but not set as free. There is no check if 19.40 - * the free list is empty, so make sure this is not the case. 19.41 - */ 19.42 -inline 19.43 -MallocProlog *removeChunk(MallocArrays* freeLists, uint32 containerIdx) 19.44 -{ 19.45 - MallocProlog** container = &freeLists->bigChunks[containerIdx]; 19.46 - MallocProlog* removedChunk = *container; 19.47 - *container = removedChunk->nextChunkInFreeList; 19.48 - 19.49 - if(removedChunk->nextChunkInFreeList) 19.50 - removedChunk->nextChunkInFreeList->prevChunkInFreeList = 19.51 - (MallocProlog*)container; 19.52 - 19.53 - if(*container == NULL) 19.54 - { 19.55 - if(containerIdx < 64) 19.56 - freeLists->bigChunksSearchVector[0] &= ~((uint64)1 << containerIdx); 19.57 - else 19.58 - freeLists->bigChunksSearchVector[1] &= ~((uint64)1 << (containerIdx-64)); 19.59 - } 19.60 - 19.61 - return removedChunk; 19.62 -} 19.63 - 19.64 -/* 19.65 - * Removes the first chunk of a freeList 19.66 - * The chunk is removed but not set as free. There is no check if 19.67 - * the free list is empty, so make sure this is not the case. 19.68 - */ 19.69 -inline 19.70 -MallocProlog *removeSmallChunk(MallocArrays* freeLists, uint32 containerIdx) 19.71 -{ 19.72 - MallocProlog** container = &freeLists->smallChunks[containerIdx]; 19.73 - MallocProlog* removedChunk = *container; 19.74 - *container = removedChunk->nextChunkInFreeList; 19.75 - 19.76 - if(removedChunk->nextChunkInFreeList) 19.77 - removedChunk->nextChunkInFreeList->prevChunkInFreeList = 19.78 - (MallocProlog*)container; 19.79 - 19.80 - return removedChunk; 19.81 -} 19.82 - 19.83 -inline 19.84 -size_t getChunkSize(MallocProlog* chunk) 19.85 -{ 19.86 - return (uintptr_t)chunk->nextHigherInMem - 19.87 - (uintptr_t)chunk - sizeof(MallocProlog); 19.88 -} 19.89 - 19.90 -/* 19.91 - * Removes a chunk from a free list. 19.92 - */ 19.93 -inline 19.94 -void extractChunk(MallocProlog* chunk, MallocArrays *freeLists) 19.95 -{ 19.96 - chunk->prevChunkInFreeList->nextChunkInFreeList = chunk->nextChunkInFreeList; 19.97 - if(chunk->nextChunkInFreeList) 19.98 - chunk->nextChunkInFreeList->prevChunkInFreeList = chunk->prevChunkInFreeList; 19.99 - 19.100 - //The last element in the list points to the container. If the container points 19.101 - //to NULL the container is empty 19.102 - if(*((void**)(chunk->prevChunkInFreeList)) == NULL && getChunkSize(chunk) >= BIG_LOWER_BOUND) 19.103 - { 19.104 - //Find the approppiate container because we do not know it 19.105 - uint64 containerIdx = ((uintptr_t)chunk->prevChunkInFreeList - (uintptr_t)freeLists->bigChunks) >> 3; 19.106 - if(containerIdx < (uint32)64) 19.107 - freeLists->bigChunksSearchVector[0] &= ~((uint64)1 << containerIdx); 19.108 - if(containerIdx < 128 && containerIdx >=64) 19.109 - freeLists->bigChunksSearchVector[1] &= ~((uint64)1 << (containerIdx-64)); 19.110 - 19.111 - } 19.112 -} 19.113 - 19.114 -/* 19.115 - * Merges two chunks. 19.116 - * Chunk A has to be before chunk B in memory. Both have to be removed from 19.117 - * a free list 19.118 - */ 19.119 -inline 19.120 -MallocProlog *mergeChunks(MallocProlog* chunkA, MallocProlog* chunkB) 19.121 -{ 19.122 - chunkA->nextHigherInMem = chunkB->nextHigherInMem; 19.123 - chunkB->nextHigherInMem->nextLowerInMem = chunkA; 19.124 - return chunkA; 19.125 -} 19.126 -/* 19.127 - * Inserts a chunk into a free list. 19.128 - */ 19.129 -inline 19.130 -void insertChunk(MallocProlog* chunk, MallocProlog** container) 19.131 -{ 19.132 - chunk->nextChunkInFreeList = *container; 19.133 - chunk->prevChunkInFreeList = (MallocProlog*)container; 19.134 - if(*container) 19.135 - (*container)->prevChunkInFreeList = chunk; 19.136 - *container = chunk; 19.137 -} 19.138 - 19.139 -/* 19.140 - * Divides the chunk that a new chunk of newSize is created. 19.141 - * There is no size check, so make sure the size value is valid. 19.142 - */ 19.143 -inline 19.144 -MallocProlog *divideChunk(MallocProlog* chunk, size_t newSize) 19.145 -{ 19.146 - MallocProlog* newChunk = (MallocProlog*)((uintptr_t)chunk->nextHigherInMem - 19.147 - newSize - sizeof(MallocProlog)); 19.148 - 19.149 - newChunk->nextLowerInMem = chunk; 19.150 - newChunk->nextHigherInMem = chunk->nextHigherInMem; 19.151 - 19.152 - chunk->nextHigherInMem->nextLowerInMem = newChunk; 19.153 - chunk->nextHigherInMem = newChunk; 19.154 - 19.155 - return newChunk; 19.156 -} 19.157 - 19.158 -/* 19.159 - * Search for chunk in the list of big chunks. Split the block if it's too big 19.160 - */ 19.161 -inline 19.162 -MallocProlog *searchChunk(MallocArrays *freeLists, size_t sizeRequested, uint32 containerIdx) 19.163 -{ 19.164 - MallocProlog* foundChunk; 19.165 - 19.166 - uint64 searchVector = freeLists->bigChunksSearchVector[0]; 19.167 - //set small chunk bits to zero 19.168 - searchVector &= MAX_UINT64 << containerIdx; 19.169 - containerIdx = __builtin_ffsl(searchVector); 19.170 - 19.171 - if(containerIdx == 0) 19.172 - { 19.173 - searchVector = freeLists->bigChunksSearchVector[1]; 19.174 - containerIdx = __builtin_ffsl(searchVector); 19.175 - if(containerIdx == 0) 19.176 - { 19.177 - printf("VMS malloc failed: low memory"); 19.178 - exit(1); 19.179 - } 19.180 - containerIdx += 64; 19.181 - } 19.182 - containerIdx--; 19.183 - 19.184 - 19.185 - foundChunk = removeChunk(freeLists, containerIdx); 19.186 - size_t chunkSize = getChunkSize(foundChunk); 19.187 - 19.188 - //If the new chunk is larger than the requested size: split 19.189 - if(chunkSize > sizeRequested + 2 * sizeof(MallocProlog) + BIG_LOWER_BOUND) 19.190 - { 19.191 - MallocProlog *newChunk = divideChunk(foundChunk,sizeRequested); 19.192 - containerIdx = getContainer(getChunkSize(foundChunk)) - 1; 19.193 - insertChunk(foundChunk,&freeLists->bigChunks[containerIdx]); 19.194 - if(containerIdx < 64) 19.195 - freeLists->bigChunksSearchVector[0] |= ((uint64)1 << containerIdx); 19.196 - else 19.197 - freeLists->bigChunksSearchVector[1] |= ((uint64)1 << (containerIdx-64)); 19.198 - foundChunk = newChunk; 19.199 - } 19.200 - 19.201 - return foundChunk; 19.202 -} 19.203 - 19.204 - 19.205 -/* 19.206 - * This is sequential code, meant to only be called from the Master, not from 19.207 - * any slave Slvs. 19.208 - */ 19.209 -void *VMS_int__malloc( size_t sizeRequested ) 19.210 - { 19.211 - //============================= MEASUREMENT STUFF ======================== 19.212 - #ifdef MEAS__TIME_MALLOC 19.213 - int32 startStamp, endStamp; 19.214 - saveLowTimeStampCountInto( startStamp ); 19.215 - #endif 19.216 - //======================================================================== 19.217 - 19.218 - MallocArrays* freeLists = _VMSMasterEnv->freeLists; 19.219 - MallocProlog* foundChunk; 19.220 - 19.221 - //Return a small chunk if the requested size is smaller than 128B 19.222 - if(sizeRequested <= LOWER_BOUND) 19.223 - { 19.224 - uint32 freeListIdx = (sizeRequested-1)/SMALL_CHUNK_SIZE; 19.225 - if(freeLists->smallChunks[freeListIdx] == NULL) 19.226 - foundChunk = searchChunk(freeLists, SMALL_CHUNK_SIZE*(freeListIdx+1), 0); 19.227 - else 19.228 - foundChunk = removeSmallChunk(freeLists, freeListIdx); 19.229 - 19.230 - //Mark as allocated 19.231 - foundChunk->prevChunkInFreeList = NULL; 19.232 - return foundChunk + 1; 19.233 - } 19.234 - 19.235 - //Calculate the expected container. Start one higher to have a Chunk that's 19.236 - //always big enough. 19.237 - uint32 containerIdx = getContainer(sizeRequested); 19.238 - 19.239 - if(freeLists->bigChunks[containerIdx] == NULL) 19.240 - foundChunk = searchChunk(freeLists, sizeRequested, containerIdx); 19.241 - else 19.242 - foundChunk = removeChunk(freeLists, containerIdx); 19.243 - 19.244 - //Mark as allocated 19.245 - foundChunk->prevChunkInFreeList = NULL; 19.246 - 19.247 - //============================= MEASUREMENT STUFF ======================== 19.248 - #ifdef MEAS__TIME_MALLOC 19.249 - saveLowTimeStampCountInto( endStamp ); 19.250 - addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->mallocTimeHist ); 19.251 - #endif 19.252 - //======================================================================== 19.253 - 19.254 - //skip over the prolog by adding its size to the pointer return 19.255 - return foundChunk + 1; 19.256 - } 19.257 - 19.258 -/* 19.259 - * This is sequential code, meant to only be called from the Master, not from 19.260 - * any slave Slvs. 19.261 - */ 19.262 -void 19.263 -VMS_int__free( void *ptrToFree ) 19.264 - { 19.265 - 19.266 - MEAS__Capture_Pre_Free_Point; 19.267 - 19.268 - MallocArrays* freeLists = _VMSMasterEnv->freeLists; 19.269 - MallocProlog *chunkToFree = (MallocProlog*)ptrToFree - 1; 19.270 - uint32 containerIdx; 19.271 - 19.272 - //Check for free neighbors 19.273 - if(chunkToFree->nextLowerInMem) 19.274 - { 19.275 - if(chunkToFree->nextLowerInMem->prevChunkInFreeList != NULL) 19.276 - {//Chunk is not allocated 19.277 - extractChunk(chunkToFree->nextLowerInMem, freeLists); 19.278 - chunkToFree = mergeChunks(chunkToFree->nextLowerInMem, chunkToFree); 19.279 - } 19.280 - } 19.281 - if(chunkToFree->nextHigherInMem) 19.282 - { 19.283 - if(chunkToFree->nextHigherInMem->prevChunkInFreeList != NULL) 19.284 - {//Chunk is not allocated 19.285 - extractChunk(chunkToFree->nextHigherInMem, freeLists); 19.286 - chunkToFree = mergeChunks(chunkToFree, chunkToFree->nextHigherInMem); 19.287 - } 19.288 - } 19.289 - 19.290 - size_t chunkSize = getChunkSize(chunkToFree); 19.291 - if(chunkSize < BIG_LOWER_BOUND) 19.292 - { 19.293 - containerIdx = (chunkSize/SMALL_CHUNK_SIZE)-1; 19.294 - if(containerIdx > SMALL_CHUNK_COUNT-1) 19.295 - containerIdx = SMALL_CHUNK_COUNT-1; 19.296 - insertChunk(chunkToFree, &freeLists->smallChunks[containerIdx]); 19.297 - } 19.298 - else 19.299 - { 19.300 - containerIdx = getContainer(getChunkSize(chunkToFree)) - 1; 19.301 - insertChunk(chunkToFree, &freeLists->bigChunks[containerIdx]); 19.302 - if(containerIdx < 64) 19.303 - freeLists->bigChunksSearchVector[0] |= (uint64)1 << containerIdx; 19.304 - else 19.305 - freeLists->bigChunksSearchVector[1] |= (uint64)1 << (containerIdx-64); 19.306 - } 19.307 - 19.308 - MEAS__Capture_Post_Free_Point; 19.309 - } 19.310 - 19.311 -/* 19.312 - * Designed to be called from the main thread outside of VMS, during init 19.313 - */ 19.314 -MallocArrays * 19.315 -VMS_ext__create_free_list() 19.316 -{ 19.317 - //Initialize containers for small chunks and fill with zeros 19.318 - _VMSMasterEnv->freeLists = (MallocArrays*)malloc( sizeof(MallocArrays) ); 19.319 - MallocArrays *freeLists = _VMSMasterEnv->freeLists; 19.320 - 19.321 - freeLists->smallChunks = 19.322 - (MallocProlog**)malloc(SMALL_CHUNK_COUNT*sizeof(MallocProlog*)); 19.323 - memset((void*)freeLists->smallChunks, 19.324 - 0,SMALL_CHUNK_COUNT*sizeof(MallocProlog*)); 19.325 - 19.326 - //Calculate number of containers for big chunks 19.327 - uint32 container = getContainer(MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE)+1; 19.328 - freeLists->bigChunks = (MallocProlog**)malloc(container*sizeof(MallocProlog*)); 19.329 - memset((void*)freeLists->bigChunks,0,container*sizeof(MallocProlog*)); 19.330 - freeLists->containerCount = container; 19.331 - 19.332 - //Create first element in lastContainer 19.333 - MallocProlog *firstChunk = malloc( MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE ); 19.334 - if( firstChunk == NULL ) {printf("Can't allocate initial memory\n"); exit(1);} 19.335 - freeLists->memSpace = firstChunk; 19.336 - 19.337 - //Touch memory to avoid page faults 19.338 - void *ptr,*endPtr; 19.339 - endPtr = (void*)firstChunk+MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE; 19.340 - for(ptr = firstChunk; ptr < endPtr; ptr+=PAGE_SIZE) 19.341 - { 19.342 - *(char*)ptr = 0; 19.343 - } 19.344 - 19.345 - firstChunk->nextLowerInMem = NULL; 19.346 - firstChunk->nextHigherInMem = (MallocProlog*)((uintptr_t)firstChunk + 19.347 - MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE - sizeof(MallocProlog)); 19.348 - firstChunk->nextChunkInFreeList = NULL; 19.349 - //previous element in the queue is the container 19.350 - firstChunk->prevChunkInFreeList = &freeLists->bigChunks[container-2]; 19.351 - 19.352 - freeLists->bigChunks[container-2] = firstChunk; 19.353 - //Insert into bit search list 19.354 - if(container <= 65) 19.355 - { 19.356 - freeLists->bigChunksSearchVector[0] = ((uint64)1 << (container-2)); 19.357 - freeLists->bigChunksSearchVector[1] = 0; 19.358 - } 19.359 - else 19.360 - { 19.361 - freeLists->bigChunksSearchVector[0] = 0; 19.362 - freeLists->bigChunksSearchVector[1] = ((uint64)1 << (container-66)); 19.363 - } 19.364 - 19.365 - //Create dummy chunk to mark the top of stack this is of course 19.366 - //never freed 19.367 - MallocProlog *dummyChunk = firstChunk->nextHigherInMem; 19.368 - dummyChunk->nextHigherInMem = dummyChunk+1; 19.369 - dummyChunk->nextLowerInMem = NULL; 19.370 - dummyChunk->nextChunkInFreeList = NULL; 19.371 - dummyChunk->prevChunkInFreeList = NULL; 19.372 - 19.373 - return freeLists; 19.374 - } 19.375 - 19.376 - 19.377 -/*Designed to be called from the main thread outside of VMS, during cleanup 19.378 - */ 19.379 -void 19.380 -VMS_ext__free_free_list( MallocArrays *freeLists ) 19.381 - { 19.382 - free(freeLists->memSpace); 19.383 - free(freeLists->bigChunks); 19.384 - free(freeLists->smallChunks); 19.385 - 19.386 - } 19.387 -
20.1 --- a/vmalloc.h Tue Mar 13 10:02:06 2012 -0700 20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 20.3 @@ -1,91 +0,0 @@ 20.4 -/* 20.5 - * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 20.6 - * Licensed under GNU General Public License version 2 20.7 - * 20.8 - * Author: seanhalle@yahoo.com 20.9 - * 20.10 - * Created on November 14, 2009, 9:07 PM 20.11 - */ 20.12 - 20.13 -#ifndef _VMALLOC_H 20.14 -#define _VMALLOC_H 20.15 - 20.16 -#include <malloc.h> 20.17 -#include <inttypes.h> 20.18 -#include "VMS_primitive_data_types.h" 20.19 - 20.20 -#define SMALL_CHUNK_SIZE 32 20.21 -#define SMALL_CHUNK_COUNT 4 20.22 -#define LOWER_BOUND 128 //Biggest chunk size that is created for the small chunks 20.23 -#define BIG_LOWER_BOUND 160 //Smallest chunk size that is created for the big chunks 20.24 - 20.25 -#define LOG54 0.3219280948873623 20.26 -#define LOG128 7 20.27 - 20.28 -typedef struct _MallocProlog MallocProlog; 20.29 - 20.30 -struct _MallocProlog 20.31 - { 20.32 - MallocProlog *nextChunkInFreeList; 20.33 - MallocProlog *prevChunkInFreeList; 20.34 - MallocProlog *nextHigherInMem; 20.35 - MallocProlog *nextLowerInMem; 20.36 - }; 20.37 -//MallocProlog 20.38 - 20.39 - typedef struct MallocArrays MallocArrays; 20.40 - 20.41 - struct MallocArrays 20.42 - { 20.43 - MallocProlog **smallChunks; 20.44 - MallocProlog **bigChunks; 20.45 - uint64 bigChunksSearchVector[2]; 20.46 - void *memSpace; 20.47 - uint32 containerCount; 20.48 - }; 20.49 - //MallocArrays 20.50 - 20.51 -typedef struct 20.52 - { 20.53 - MallocProlog *firstChunkInFreeList; 20.54 - int32 numInList; //TODO not used 20.55 - } 20.56 -FreeListHead; 20.57 - 20.58 -void * 20.59 -VMS_int__malloc( size_t sizeRequested ); 20.60 -#define VMS_PI__malloc VMS_int__malloc 20.61 -#define VMS_WL__malloc VMS_int__malloc /*TODO: Bug -- Not protected!! */ 20.62 -#define VMS_App__malloc VMS_int__malloc /*TODO: Bug -- Not protected!! */ 20.63 - 20.64 -void * 20.65 -VMS_int__malloc_aligned( size_t sizeRequested ); 20.66 -#define VMS_PI__malloc_aligned VMS_int__malloc_aligned 20.67 -#define VMS_WL__malloc_aligned VMS_int__malloc_aligned 20.68 - 20.69 -void 20.70 -VMS_int__free( void *ptrToFree ); 20.71 -#define VMS_PI__free VMS_int__free 20.72 -#define VMS_WL__free VMS_int__free /*TODO: Bug -- Not protected!! */ 20.73 -#define VMS_App__free VMS_int__free /*TODO: Bug -- Not protected!! */ 20.74 - 20.75 - 20.76 - 20.77 -/*Allocates memory from the external system -- higher overhead 20.78 - */ 20.79 -void * 20.80 -VMS_ext__malloc_in_ext( size_t sizeRequested ); 20.81 - 20.82 -/*Frees memory that was allocated in the external system -- higher overhead 20.83 - */ 20.84 -void 20.85 -VMS_ext__free_in_ext( void *ptrToFree ); 20.86 - 20.87 - 20.88 -MallocArrays * 20.89 -VMS_ext__create_free_list(); 20.90 - 20.91 -void 20.92 -VMS_ext__free_free_list(MallocArrays *freeLists ); 20.93 - 20.94 -#endif 20.95 \ No newline at end of file