Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison VMS.h @ 200:6db9e4898978
VMS name chgs -- added "WL" "PI" and "int" and split vms.h up
| author | Me@portablequad |
|---|---|
| date | Sun, 12 Feb 2012 01:49:33 -0800 |
| parents | 1738f190b7bb |
| children | cb888346c3e0 |
comparison
equal
deleted
inserted
replaced
| 88:3f9faf34ec2a | 92:69353e6ee338 |
|---|---|
| 9 #ifndef _VMS_H | 9 #ifndef _VMS_H |
| 10 #define _VMS_H | 10 #define _VMS_H |
| 11 #define _GNU_SOURCE | 11 #define _GNU_SOURCE |
| 12 | 12 |
| 13 #include "VMS_primitive_data_types.h" | 13 #include "VMS_primitive_data_types.h" |
| 14 #include "../../C_Libraries/Queue_impl/PrivateQueue.h" | |
| 15 #include "../../C_Libraries/Histogram/Histogram.h" | |
| 16 #include "../../C_Libraries/DynArray/DynArray.h" | 14 #include "../../C_Libraries/DynArray/DynArray.h" |
| 17 #include "../../C_Libraries/Hash_impl/PrivateHash.h" | 15 #include "../../C_Libraries/Hash_impl/PrivateHash.h" |
| 16 #include "../../C_Libraries/Histogram/Histogram.h" | |
| 17 #include "../../C_Libraries/Queue_impl/PrivateQueue.h" | |
| 18 #include "vmalloc.h" | 18 #include "vmalloc.h" |
| 19 | 19 |
| 20 #include <pthread.h> | 20 #include <pthread.h> |
| 21 #include <sys/time.h> | 21 #include <sys/time.h> |
| 22 | 22 |
| 23 | 23 //================= Defines: included from separate files ================= |
| 24 //=============================== Debug =================================== | |
| 25 // | 24 // |
| 26 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread | 25 // Note: ALL defines are in other files, none are in here |
| 27 // It still does co-routines and all the mechanisms are the same, it just | 26 // |
| 28 // has only a single thread and animates VPs one at a time | 27 #include "VMS_defs.h" |
| 29 //#define SEQUENTIAL | 28 |
| 30 | 29 |
| 31 //#define USE_WORK_STEALING | 30 |
| 32 | 31 //================================ Typedefs ================================= |
| 33 //turns on the probe-instrumentation in the application -- when not | 32 // |
| 34 // defined, the calls to the probe functions turn into comments | |
| 35 #define STATS__ENABLE_PROBES | |
| 36 //#define TURN_ON_DEBUG_PROBES | |
| 37 | |
| 38 //These defines turn types of bug messages on and off | |
| 39 // be sure debug messages are un-commented (next block of defines) | |
| 40 #define dbgAppFlow TRUE /* Top level flow of application code -- general*/ | |
| 41 #define dbgProbes FALSE /* for issues inside probes themselves*/ | |
| 42 #define dbgB2BMaster FALSE /* in coreloop, back to back master VPs*/ | |
| 43 #define dbgRqstHdlr FALSE /* in request handler code*/ | |
| 44 | |
| 45 //Comment or un- the substitute half to turn on/off types of debug message | |
| 46 #define DEBUG( bool, msg) \ | |
| 47 // if( bool){ printf(msg); fflush(stdin);} | |
| 48 #define DEBUG1( bool, msg, param) \ | |
| 49 // if(bool){printf(msg, param); fflush(stdin);} | |
| 50 #define DEBUG2( bool, msg, p1, p2) \ | |
| 51 // if(bool) {printf(msg, p1, p2); fflush(stdin);} | |
| 52 | |
| 53 #define ERROR(msg) printf(msg); | |
| 54 #define ERROR1(msg, param) printf(msg, param); | |
| 55 #define ERROR2(msg, p1, p2) printf(msg, p1, p2); | |
| 56 | |
| 57 //=========================== STATS ======================= | |
| 58 | |
| 59 //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and | |
| 60 // compiled-in that saves the low part of the time stamp count just before | |
| 61 // suspending a processor and just after resuming that processorsrc/VPThread_lib/VMS/VMS.h:322: warning: previous declaration of ‘VMS__create_procr’ was here. It is | |
| 62 // saved into a field added to VirtProcr. Have to sanity-check for | |
| 63 // rollover of low portion into high portion. | |
| 64 //#define MEAS__TIME_STAMP_SUSP | |
| 65 //#define MEAS__TIME_MASTER | |
| 66 #define MEAS__TIME_PLUGIN | |
| 67 #define MEAS__TIME_MALLOC | |
| 68 //#define MEAS__TIME_MASTER_LOCK | |
| 69 #define MEAS__NUM_TIMES_TO_RUN 100000 | |
| 70 | |
| 71 //For code that calculates normalization-offset between TSC counts of | |
| 72 // different cores. | |
| 73 #define NUM_TSC_ROUND_TRIPS 10 | |
| 74 | |
| 75 | |
| 76 //========================= Hardware related Constants ===================== | |
| 77 //This value is the number of hardware threads in the shared memory | |
| 78 // machine | |
| 79 //#define NUM_CORES 8 | |
| 80 | |
| 81 // tradeoff amortizing master fixed overhead vs imbalance potential | |
| 82 // when work-stealing, can make bigger, at risk of losing cache affinity | |
| 83 #define NUM_SCHED_SLOTS 5 | |
| 84 | |
| 85 #define MIN_WORK_UNIT_CYCLES 20000 | |
| 86 | |
| 87 #define MASTERLOCK_RETRIES 10000 | |
| 88 | |
| 89 // stack size in virtual processors created | |
| 90 #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ | |
| 91 | |
| 92 // memory for VMS__malloc | |
| 93 #define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */ | |
| 94 | |
| 95 #define CACHE_LINE 64 | |
| 96 #define PAGE_SIZE 4096 | |
| 97 | |
| 98 | |
| 99 //============================== | |
| 100 | |
| 101 #define SUCCESS 0 | |
| 102 | |
| 103 #define writeVMSQ writePrivQ | |
| 104 #define readVMSQ readPrivQ | |
| 105 #define makeVMSQ makeVMSPrivQ | |
| 106 #define numInVMSQ numInPrivQ | |
| 107 #define VMSQueueStruc PrivQueueStruc | |
| 108 | |
| 109 | |
| 110 | |
| 111 //=========================================================================== | |
| 112 typedef unsigned long long TSCount; | 33 typedef unsigned long long TSCount; |
| 34 typedef union | |
| 35 { uint32 lowHigh[2]; | |
| 36 uint64 longVal; | |
| 37 } | |
| 38 TSCountLowHigh; | |
| 113 | 39 |
| 114 typedef struct _SchedSlot SchedSlot; | 40 typedef struct _SchedSlot SchedSlot; |
| 115 typedef struct _VMSReqst VMSReqst; | 41 typedef struct _VMSReqst VMSReqst; |
| 116 typedef struct _VirtProcr VirtProcr; | 42 typedef struct _SlaveVP SlaveVP; |
| 117 typedef struct _IntervalProbe IntervalProbe; | 43 typedef struct _IntervalProbe IntervalProbe; |
| 118 typedef struct _GateStruc GateStruc; | 44 typedef struct _GateStruc GateStruc; |
| 119 | 45 |
| 120 | 46 |
| 121 typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx | 47 typedef SlaveVP * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx |
| 122 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv | 48 typedef void (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv |
| 123 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr | 49 typedef void (*VirtProcrFnPtr) ( void *, SlaveVP * ); //initData, animPr |
| 124 typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr | 50 typedef void VirtProcrFn ( void *, SlaveVP * ); //initData, animPr |
| 125 typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); | 51 typedef void (*ResumeVPFnPtr) ( SlaveVP *, void * ); |
| 126 | 52 |
| 127 | 53 |
| 128 //============= Requests =========== | 54 //============= Request Related =========== |
| 129 // | 55 // |
| 130 | 56 |
| 131 enum VMSReqstType //avoid starting enums at 0, for debug reasons | 57 enum VMSReqstType //avoid starting enums at 0, for debug reasons |
| 132 { | 58 { |
| 133 semantic = 1, | 59 semantic = 1, |
| 152 otherIO | 78 otherIO |
| 153 }; | 79 }; |
| 154 | 80 |
| 155 typedef struct | 81 typedef struct |
| 156 { enum VMSSemReqstType reqType; | 82 { enum VMSSemReqstType reqType; |
| 157 VirtProcr *requestingPr; | 83 SlaveVP *requestingPr; |
| 158 char *nameStr; //for create probe | 84 char *nameStr; //for create probe |
| 159 } | 85 } |
| 160 VMSSemReq; | 86 VMSSemReq; |
| 161 | 87 |
| 162 | 88 |
| 164 | 90 |
| 165 struct _SchedSlot | 91 struct _SchedSlot |
| 166 { | 92 { |
| 167 int workIsDone; | 93 int workIsDone; |
| 168 int needsProcrAssigned; | 94 int needsProcrAssigned; |
| 169 VirtProcr *procrAssignedToSlot; | 95 SlaveVP *procrAssignedToSlot; |
| 170 }; | 96 }; |
| 171 //SchedSlot | 97 //SchedSlot |
| 172 | 98 |
| 173 /*WARNING: re-arranging this data structure could cause VP switching | 99 /*WARNING: re-arranging this data structure could cause VP switching |
| 174 * assembly code to fail -- hard-codes offsets of fields | 100 * assembly code to fail -- hard-codes offsets of fields |
| 175 */ | 101 */ |
| 176 struct _VirtProcr | 102 struct _SlaveVP |
| 177 { int procrID; //for debugging -- count up each time create | 103 { int procrID; //for debugging -- count up each time create |
| 178 int coreAnimatedBy; | 104 int coreAnimatedBy; |
| 179 void *startOfStack; | 105 void *startOfStack; |
| 180 void *stackPtr; | 106 void *stackPtr; |
| 181 void *framePtr; | 107 void *framePtr; |
| 192 | 118 |
| 193 void *semanticData; //this livesUSE_GNU here for the life of VP | 119 void *semanticData; //this livesUSE_GNU here for the life of VP |
| 194 void *dataRetFromReq;//values returned from plugin to VP go here | 120 void *dataRetFromReq;//values returned from plugin to VP go here |
| 195 | 121 |
| 196 //=========== MEASUREMENT STUFF ========== | 122 //=========== MEASUREMENT STUFF ========== |
| 197 #ifdef MEAS__TIME_STAMP_SUSP | 123 #ifdef MEAS__TIME_STAMP_SUSP |
| 198 unsigned int preSuspTSCLow; | 124 uint32 preSuspTSCLow; |
| 199 unsigned int postSuspTSCLow; | 125 uint32 postSuspTSCLow; |
| 200 #endif | 126 #endif |
| 201 #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/ | 127 #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/ |
| 202 unsigned int startMasterTSCLow;USE_GNU | 128 uint32 startMasterTSCLow;USE_GNU |
| 203 unsigned int endMasterTSCLow; | 129 uint32 endMasterTSCLow; |
| 204 #endif | 130 #endif |
| 131 #ifdef MEAS__TIME_2011_SYS | |
| 132 TSCountLowHigh startSusp; | |
| 133 uint64 totalSuspCycles; | |
| 134 uint32 numGoodSusp; | |
| 135 #endif | |
| 205 //======================================== | 136 //======================================== |
| 206 | 137 |
| 207 float64 createPtInSecs; //have space but don't use on some configs | 138 float64 createPtInSecs; //have space but don't use on some configs |
| 208 }; | 139 }; |
| 209 //VirtProcr | 140 //VirtProcr |
| 213 * assembly code to fail -- hard-codes offsets of fields | 144 * assembly code to fail -- hard-codes offsets of fields |
| 214 * (because -O3 messes with things otherwise) | 145 * (because -O3 messes with things otherwise) |
| 215 */ | 146 */ |
| 216 typedef struct | 147 typedef struct |
| 217 { | 148 { |
| 149 union{ //adds padding to put masterLock on its own cache-line to elim | |
| 150 // false sharing (masterLock is most-accessed var in VMS) | |
| 151 volatile int32 masterLock; | |
| 152 char padding[CACHELINE_SIZE]; | |
| 153 } masterLockUnion; | |
| 218 SlaveScheduler slaveScheduler; | 154 SlaveScheduler slaveScheduler; |
| 219 RequestHandler requestHandler; | 155 RequestHandler requestHandler; |
| 220 | 156 |
| 221 SchedSlot ***allSchedSlots; | 157 SchedSlot ***allSchedSlots; |
| 222 VMSQueueStruc **readyToAnimateQs; | 158 VMSQueueStruc **readyToAnimateQs; |
| 223 VirtProcr **masterVPs; | 159 SlaveVP **masterVPs; |
| 224 | 160 |
| 225 void *semanticEnv; | 161 void *semanticEnv; |
| 226 void *OSEventStruc; //for future, when add I/O to BLIS | 162 void *OSEventStruc; //for future, when add I/O to BLIS |
| 227 MallocProlog *freeListHead; | 163 MallocArrays *freeLists; |
| 228 int32 amtOfOutstandingMem; //total currently allocated | 164 int32 amtOfOutstandingMem; //total currently allocated |
| 229 | 165 |
| 230 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop | 166 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop |
| 231 | 167 |
| 232 int32 setupComplete; | 168 int32 setupComplete; |
| 233 volatile int32 masterLock; | 169 //int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP |
| 234 | |
| 235 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP | |
| 236 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal | 170 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal |
| 237 int32 workStealingLock; | 171 int32 workStealingLock; |
| 238 | 172 |
| 239 int32 numProcrsCreated; //gives ordering to processor creation | 173 int32 numVPsCreated; //gives ordering to processor creation |
| 240 | 174 |
| 241 //=========== MEASUREMENT STUFF ============= | 175 //=========== MEASUREMENT STUFF ============= |
| 242 IntervalProbe **intervalProbes; | 176 IntervalProbe **intervalProbes; |
| 243 PrivDynArrayInfo *dynIntervalProbesInfo; | 177 PrivDynArrayInfo *dynIntervalProbesInfo; |
| 244 HashTable *probeNameHashTbl; | 178 HashTable *probeNameHashTbl; |
| 245 int32 masterCreateProbeID; | 179 int32 masterCreateProbeID; |
| 246 float64 createPtInSecs; | 180 float64 createPtInSecs; |
| 247 Histogram **measHists; | 181 Histogram **measHists; |
| 248 PrivDynArrayInfo *measHistsInfo; | 182 PrivDynArrayInfo *measHistsInfo; |
| 249 #ifdef MEAS__TIME_PLUGIN | 183 #ifdef MEAS__TIME_PLUGIN |
| 250 Histogram *reqHdlrLowTimeHist; | 184 Histogram *reqHdlrLowTimeHist; |
| 251 Histogram *reqHdlrHighTimeHist; | 185 Histogram *reqHdlrHighTimeHist; |
| 252 #endif | 186 #endif |
| 253 #ifdef MEAS__TIME_MALLOC | 187 #ifdef MEAS__TIME_MALLOC |
| 254 Histogram *mallocTimeHist; | 188 Histogram *mallocTimeHist; |
| 255 Histogram *freeTimeHist; | 189 Histogram *freeTimeHist; |
| 256 #endif | 190 #endif |
| 257 #ifdef MEAS__TIME_MASTER_LOCK | 191 #ifdef MEAS__TIME_MASTER_LOCK |
| 258 Histogram *masterLockLowTimeHist; | 192 Histogram *masterLockLowTimeHist; |
| 259 Histogram *masterLockHighTimeHist; | 193 Histogram *masterLockHighTimeHist; |
| 260 #endif | 194 #endif |
| 195 #ifdef MEAS__TIME_2011_SYS | |
| 196 TSCountLowHigh startMaster; | |
| 197 uint64 totalMasterCycles; | |
| 198 uint32 numMasterAnimations; | |
| 199 TSCountLowHigh startReqHdlr; | |
| 200 uint64 totalPluginCycles; | |
| 201 uint32 numPluginAnimations; | |
| 202 uint64 cyclesTillStartMasterLoop; | |
| 203 TSCountLowHigh endMasterLoop; | |
| 204 #endif | |
| 205 //========================================== | |
| 261 } | 206 } |
| 262 MasterEnv; | 207 MasterEnv; |
| 263 | 208 |
| 264 //========================= Extra Stuff Data Strucs ======================= | 209 //========================= Extra Stuff Data Strucs ======================= |
| 265 typedef struct | 210 typedef struct |
| 279 | 224 |
| 280 //======================= OS Thread related =============================== | 225 //======================= OS Thread related =============================== |
| 281 | 226 |
| 282 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype | 227 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype |
| 283 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype | 228 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype |
| 284 void masterLoop( void *initData, VirtProcr *masterPr ); | 229 void masterLoop( void *initData, SlaveVP *masterVP ); |
| 285 | 230 |
| 286 | 231 |
| 287 typedef struct | 232 typedef struct |
| 288 { | 233 { |
| 289 void *endThdPt; | 234 void *endThdPt; |
| 296 pthread_mutex_t suspendLock; | 241 pthread_mutex_t suspendLock; |
| 297 pthread_cond_t suspend_cond; | 242 pthread_cond_t suspend_cond; |
| 298 | 243 |
| 299 | 244 |
| 300 | 245 |
| 301 //===================== Global Vars =================== | 246 //============================= Global Vars ================================ |
| 302 | 247 |
| 303 volatile MasterEnv *_VMSMasterEnv; | 248 volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__; |
| 304 | 249 |
| 305 | 250 |
| 306 | 251 |
| 307 | 252 |
| 308 //=========================== Function Prototypes ========================= | 253 //========================= Function Prototypes =========================== |
| 309 | 254 |
| 310 | 255 |
| 311 //========== Setup and shutdown ========== | 256 //========== Setup and shutdown ========== |
| 312 void | 257 void |
| 313 VMS__init(); | 258 VMS_int__init(); |
| 314 | 259 |
| 315 void | 260 void |
| 316 VMS__init_Seq(); | 261 VMS_int__init_Seq(); |
| 317 | 262 |
| 318 void | 263 void |
| 319 VMS__start_the_work_then_wait_until_done(); | 264 VMS_WL__start_the_work_then_wait_until_done(); |
| 320 | 265 |
| 321 void | 266 void |
| 322 VMS__start_the_work_then_wait_until_done_Seq(); | 267 VMS_WL__start_the_work_then_wait_until_done_Seq(); |
| 323 | 268 |
| 324 inline VirtProcr * | 269 inline SlaveVP * |
| 325 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); | 270 VMS_int__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); |
| 326 | 271 |
| 327 void | 272 void |
| 328 VMS__dissipate_procr( VirtProcr *procrToDissipate ); | 273 VMS_int__dissipate_procr( SlaveVP *procrToDissipate ); |
| 329 | 274 |
| 330 //Use this to create processor inside entry point & other places outside | 275 //Use this to create processor inside entry point & other places outside |
| 331 // the VMS system boundary (IE, not run in slave nor Master) | 276 // the VMS system boundary (IE, not run in slave nor Master) |
| 332 VirtProcr * | 277 SlaveVP * |
| 333 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); | 278 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); |
| 334 | 279 |
| 335 void | 280 void |
| 336 VMS_ext__dissipate_procr( VirtProcr *procrToDissipate ); | 281 VMS_ext__dissipate_procr( SlaveVP *procrToDissipate ); |
| 337 | 282 |
| 338 void | 283 void |
| 339 VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData ); | 284 VMS_PI__throw_exception( char *msgStr, SlaveVP *reqstPr, VMSExcp *excpData ); |
| 340 | 285 |
| 341 void | 286 void |
| 342 VMS__shutdown(); | 287 VMS_int__shutdown(); |
| 343 | 288 |
| 344 void | 289 void |
| 345 VMS__cleanup_at_end_of_shutdown(); | 290 VMS_int__cleanup_at_end_of_shutdown(); |
| 346 | 291 |
| 347 void * | 292 void * |
| 348 VMS__give_sem_env_for( VirtProcr *animPr ); | 293 VMS_WL__give_sem_env_for( SlaveVP *animPr ); |
| 349 | 294 |
| 350 | 295 |
| 351 //============== Request Related =============== | 296 //============== Request Related =============== |
| 352 | 297 |
| 353 void | 298 void |
| 354 VMS__suspend_procr( VirtProcr *callingPr ); | 299 VMS_int__suspend_procr( SlaveVP *callingPr ); |
| 355 | 300 |
| 356 inline void | 301 inline void |
| 357 VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr ); | 302 VMS_WL__add_sem_request_in_mallocd_VMSReqst( void *semReqData, SlaveVP *callingPr ); |
| 358 | 303 |
| 359 inline void | 304 inline void |
| 360 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ); | 305 VMS_WL__send_sem_request( void *semReqData, SlaveVP *callingPr ); |
| 361 | 306 |
| 362 void | 307 void |
| 363 VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ); | 308 VMS_WL__send_create_procr_req( void *semReqData, SlaveVP *reqstingPr ); |
| 364 | 309 |
| 365 void inline | 310 void inline |
| 366 VMS__send_dissipate_req( VirtProcr *prToDissipate ); | 311 VMS_WL__send_dissipate_req( SlaveVP *prToDissipate ); |
| 367 | 312 |
| 368 inline void | 313 inline void |
| 369 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ); | 314 VMS_WL__send_VMSSem_request( void *semReqData, SlaveVP *callingPr ); |
| 370 | 315 |
| 371 VMSReqst * | 316 VMSReqst * |
| 372 VMS__take_next_request_out_of( VirtProcr *procrWithReq ); | 317 VMS_PI__take_next_request_out_of( SlaveVP *procrWithReq ); |
| 373 | 318 |
| 374 inline void * | 319 inline void * |
| 375 VMS__take_sem_reqst_from( VMSReqst *req ); | 320 VMS_PI__take_sem_reqst_from( VMSReqst *req ); |
| 376 | 321 |
| 377 void inline | 322 void inline |
| 378 VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv, | 323 VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingPr, void *semEnv, |
| 379 ResumePrFnPtr resumePrFnPtr ); | 324 ResumeVPFnPtr resumePrFnPtr ); |
| 380 | 325 |
| 381 //======================== STATS ====================== | 326 //======================== MEASUREMENT ====================== |
| 382 | 327 uint64 |
| 383 //===== RDTSC wrapper ===== //Also runs with x86_64 code | 328 VMS_WL__give_num_plugin_cycles(); |
| 384 | 329 uint32 |
| 385 #define saveTimeStampCountInto(low, high) \ | 330 VMS_WL__give_num_plugin_animations(); |
| 386 asm volatile("RDTSC; \ | 331 |
| 387 movl %%eax, %0; \ | 332 |
| 388 movl %%edx, %1;" \ | |
| 389 /* outputs */ : "=m" (low), "=m" (high)\ | |
| 390 /* inputs */ : \ | |
| 391 /* clobber */ : "%eax", "%edx" \ | |
| 392 ); | |
| 393 | |
| 394 #define saveLowTimeStampCountInto(low) \ | |
| 395 asm volatile("RDTSC; \ | |
| 396 movl %%eax, %0;" \ | |
| 397 /* outputs */ : "=m" (low) \ | |
| 398 /* inputs */ : \ | |
| 399 /* clobber */ : "%eax", "%edx" \ | |
| 400 ); | |
| 401 | |
| 402 //==================== | |
| 403 #define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ | |
| 404 makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \ | |
| 405 _VMSMasterEnv->measHists[idx] = \ | |
| 406 makeFixedBinHist( numBins, startVal, binWidth, name ); | |
| 407 | |
| 408 | |
| 409 #define MEAS__SUB_CREATE /*turn on/off subtraction of create from plugin*/ | |
| 410 | |
| 411 #ifdef VPTHREAD | |
| 412 | |
| 413 //VPThread | |
| 414 #define createHistIdx 0 | |
| 415 #define mutexLockHistIdx 1 | |
| 416 #define mutexUnlockHistIdx 2 | |
| 417 #define condWaitHistIdx 3 | |
| 418 #define condSignalHistIdx 4 | |
| 419 | |
| 420 #define MakeTheMeasHists() \ | |
| 421 _VMSMasterEnv->measHistsInfo = \ | |
| 422 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ | |
| 423 makeAMeasHist( createHistIdx, "create", 250, 0, 100 ) \ | |
| 424 makeAMeasHist( mutexLockHistIdx, "mutex_lock", 50, 0, 100 ) \ | |
| 425 makeAMeasHist( mutexUnlockHistIdx, "mutex_unlock", 50, 0, 100 ) \ | |
| 426 makeAMeasHist( condWaitHistIdx, "cond_wait", 50, 0, 100 ) \ | |
| 427 makeAMeasHist( condSignalHistIdx, "cond_signal", 50, 0, 100 ) | |
| 428 | |
| 429 #endif | |
| 430 | |
| 431 | |
| 432 #ifdef VCILK | |
| 433 | |
| 434 //VCilk | |
| 435 #define spawnHistIdx 0 | |
| 436 #define syncHistIdx 1 | |
| 437 | |
| 438 #define MakeTheMeasHists() \ | |
| 439 _VMSMasterEnv->measHistsInfo = \ | |
| 440 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ | |
| 441 makeAMeasHist( spawnHistIdx, "Spawn", 50, 0, 200 ) \ | |
| 442 makeAMeasHist( syncHistIdx, "Sync", 50, 0, 200 ) | |
| 443 | |
| 444 | |
| 445 #endif | |
| 446 | |
| 447 #ifdef SSR | |
| 448 | |
| 449 //SSR | |
| 450 #define SendFromToHistIdx 0 | |
| 451 #define SendOfTypeHistIdx 1 | |
| 452 #define ReceiveFromToHistIdx 2 | |
| 453 #define ReceiveOfTypeHistIdx 3 | |
| 454 | |
| 455 #define MakeTheMeasHists() \ | |
| 456 _VMSMasterEnv->measHistsInfo = \ | |
| 457 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \ | |
| 458 makeAMeasHist( SendFromToHistIdx, "SendFromTo", 50, 0, 100 ) \ | |
| 459 makeAMeasHist( SendOfTypeHistIdx, "SendOfType", 50, 0, 100 ) \ | |
| 460 makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \ | |
| 461 makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 ) | |
| 462 | |
| 463 #endif | |
| 464 | |
| 465 //=========================================================================== | |
| 466 //VPThread | |
| 467 | |
| 468 | |
| 469 #define Meas_startCreate \ | |
| 470 int32 startStamp, endStamp; \ | |
| 471 saveLowTimeStampCountInto( startStamp ); \ | |
| 472 | |
| 473 #define Meas_endCreate \ | |
| 474 saveLowTimeStampCountInto( endStamp ); \ | |
| 475 addIntervalToHist( startStamp, endStamp, \ | |
| 476 _VMSMasterEnv->measHists[ createHistIdx ] ); | |
| 477 | |
| 478 #define Meas_startMutexLock \ | |
| 479 int32 startStamp, endStamp; \ | |
| 480 saveLowTimeStampCountInto( startStamp ); \ | |
| 481 | |
| 482 #define Meas_endMutexLock \ | |
| 483 saveLowTimeStampCountInto( endStamp ); \ | |
| 484 addIntervalToHist( startStamp, endStamp, \ | |
| 485 _VMSMasterEnv->measHists[ mutexLockHistIdx ] ); | |
| 486 | |
| 487 #define Meas_startMutexUnlock \ | |
| 488 int32 startStamp, endStamp; \ | |
| 489 saveLowTimeStampCountInto( startStamp ); \ | |
| 490 | |
| 491 #define Meas_endMutexUnlock \ | |
| 492 saveLowTimeStampCountInto( endStamp ); \ | |
| 493 addIntervalToHist( startStamp, endStamp, \ | |
| 494 _VMSMasterEnv->measHists[ mutexUnlockHistIdx ] ); | |
| 495 | |
| 496 #define Meas_startCondWait \ | |
| 497 int32 startStamp, endStamp; \ | |
| 498 saveLowTimeStampCountInto( startStamp ); \ | |
| 499 | |
| 500 #define Meas_endCondWait \ | |
| 501 saveLowTimeStampCountInto( endStamp ); \ | |
| 502 addIntervalToHist( startStamp, endStamp, \ | |
| 503 _VMSMasterEnv->measHists[ condWaitHistIdx ] ); | |
| 504 | |
| 505 #define Meas_startCondSignal \ | |
| 506 int32 startStamp, endStamp; \ | |
| 507 saveLowTimeStampCountInto( startStamp ); \ | |
| 508 | |
| 509 #define Meas_endCondSignal \ | |
| 510 saveLowTimeStampCountInto( endStamp ); \ | |
| 511 addIntervalToHist( startStamp, endStamp, \ | |
| 512 _VMSMasterEnv->measHists[ condSignalHistIdx ] ); | |
| 513 | |
| 514 //=========================================================================== | |
| 515 // VCilk | |
| 516 #define Meas_startSpawn \ | |
| 517 int32 startStamp, endStamp; \ | |
| 518 saveLowTimeStampCountInto( startStamp ); \ | |
| 519 | |
| 520 #define Meas_endSpawn \ | |
| 521 saveLowTimeStampCountInto( endStamp ); \ | |
| 522 addIntervalToHist( startStamp, endStamp, \ | |
| 523 _VMSMasterEnv->measHists[ spawnHistIdx ] ); | |
| 524 | |
| 525 #define Meas_startSync \ | |
| 526 int32 startStamp, endStamp; \ | |
| 527 saveLowTimeStampCountInto( startStamp ); \ | |
| 528 | |
| 529 #define Meas_endSync \ | |
| 530 saveLowTimeStampCountInto( endStamp ); \ | |
| 531 addIntervalToHist( startStamp, endStamp, \ | |
| 532 _VMSMasterEnv->measHists[ syncHistIdx ] ); | |
| 533 | |
| 534 //=========================================================================== | |
| 535 // SSR | |
| 536 #define Meas_startSendFromTo \ | |
| 537 int32 startStamp, endStamp; \ | |
| 538 saveLowTimeStampCountInto( startStamp ); \ | |
| 539 | |
| 540 #define Meas_endSendFromTo \ | |
| 541 saveLowTimeStampCountInto( endStamp ); \ | |
| 542 addIntervalToHist( startStamp, endStamp, \ | |
| 543 _VMSMasterEnv->measHists[ SendFromToHistIdx ] ); | |
| 544 | |
| 545 #define Meas_startSendOfType \ | |
| 546 int32 startStamp, endStamp; \ | |
| 547 saveLowTimeStampCountInto( startStamp ); \ | |
| 548 | |
| 549 #define Meas_endSendOfType \ | |
| 550 saveLowTimeStampCountInto( endStamp ); \ | |
| 551 addIntervalToHist( startStamp, endStamp, \ | |
| 552 _VMSMasterEnv->measHists[ SendOfTypeHistIdx ] ); | |
| 553 | |
| 554 #define Meas_startReceiveFromTo \ | |
| 555 int32 startStamp, endStamp; \ | |
| 556 saveLowTimeStampCountInto( startStamp ); \ | |
| 557 | |
| 558 #define Meas_endReceiveFromTo \ | |
| 559 saveLowTimeStampCountInto( endStamp ); \ | |
| 560 addIntervalToHist( startStamp, endStamp, \ | |
| 561 _VMSMasterEnv->measHists[ ReceiveFromToHistIdx ] ); | |
| 562 | |
| 563 #define Meas_startReceiveOfType \ | |
| 564 int32 startStamp, endStamp; \ | |
| 565 saveLowTimeStampCountInto( startStamp ); \ | |
| 566 | |
| 567 #define Meas_endReceiveOfType \ | |
| 568 saveLowTimeStampCountInto( endStamp ); \ | |
| 569 addIntervalToHist( startStamp, endStamp, \ | |
| 570 _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); | |
| 571 | |
| 572 //===== | |
| 573 | 333 |
| 574 #include "ProcrContext.h" | 334 #include "ProcrContext.h" |
| 575 #include "probes.h" | 335 #include "probes.h" |
| 576 #include "vutilities.h" | 336 #include "vutilities.h" |
| 577 | 337 |
