comparison VMS.h @ 170:92d97c6c09d6

Added tag version_that_goes_into_paper for changeset d1dd9e6ee72c
author Merten Sach <msach@mailbox.tu-berlin.de>
date Fri, 16 Dec 2011 20:01:36 +0100
parents c57bc4d530d0
children 5161414caa3e
comparison
equal deleted inserted replaced
74:9e7632e73e64 78:b4b3802c0a2e
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 ===========
24 //=============================== Debug ===================================
25 // 24 //
26 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread 25 #include "VMS_defs.h"
27 // It still does co-routines and all the mechanisms are the same, it just
28 // has only a single thread and animates VPs one at a time
29 //#define SEQUENTIAL
30
31 //#define USE_WORK_STEALING
32
33 //turns on the probe-instrumentation in the application -- when not
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 26
109 27
110 28
111 //=========================================================================== 29 //===========================================================================
112 typedef unsigned long long TSCount; 30 typedef unsigned long long TSCount;
31 typedef union
32 { uint32 lowHigh[2];
33 uint64 longVal;
34 }
35 TSCountLowHigh;
113 36
114 typedef struct _SchedSlot SchedSlot; 37 typedef struct _SchedSlot SchedSlot;
115 typedef struct _VMSReqst VMSReqst; 38 typedef struct _VMSReqst VMSReqst;
116 typedef struct _VirtProcr VirtProcr; 39 typedef struct _VirtProcr VirtProcr;
117 typedef struct _IntervalProbe IntervalProbe; 40 typedef struct _IntervalProbe IntervalProbe;
192 115
193 void *semanticData; //this livesUSE_GNU here for the life of VP 116 void *semanticData; //this livesUSE_GNU here for the life of VP
194 void *dataRetFromReq;//values returned from plugin to VP go here 117 void *dataRetFromReq;//values returned from plugin to VP go here
195 118
196 //=========== MEASUREMENT STUFF ========== 119 //=========== MEASUREMENT STUFF ==========
197 #ifdef MEAS__TIME_STAMP_SUSP 120 #ifdef MEAS__TIME_STAMP_SUSP
198 unsigned int preSuspTSCLow; 121 uint32 preSuspTSCLow;
199 unsigned int postSuspTSCLow; 122 uint32 postSuspTSCLow;
200 #endif 123 #endif
201 #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/ 124 #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/
202 unsigned int startMasterTSCLow;USE_GNU 125 uint32 startMasterTSCLow;USE_GNU
203 unsigned int endMasterTSCLow; 126 uint32 endMasterTSCLow;
204 #endif 127 #endif
128 #ifdef MEAS__TIME_2011_SYS
129 TSCountLowHigh startSusp;
130 uint64 totalSuspCycles;
131 uint32 numGoodSusp;
132 #endif
205 //======================================== 133 //========================================
206 134
207 float64 createPtInSecs; //have space but don't use on some configs 135 float64 createPtInSecs; //have space but don't use on some configs
208 }; 136 };
209 //VirtProcr 137 //VirtProcr
237 int32 workStealingLock; 165 int32 workStealingLock;
238 166
239 int32 numProcrsCreated; //gives ordering to processor creation 167 int32 numProcrsCreated; //gives ordering to processor creation
240 168
241 //=========== MEASUREMENT STUFF ============= 169 //=========== MEASUREMENT STUFF =============
242 IntervalProbe **intervalProbes; 170 IntervalProbe **intervalProbes;
243 PrivDynArrayInfo *dynIntervalProbesInfo; 171 PrivDynArrayInfo *dynIntervalProbesInfo;
244 HashTable *probeNameHashTbl; 172 HashTable *probeNameHashTbl;
245 int32 masterCreateProbeID; 173 int32 masterCreateProbeID;
246 float64 createPtInSecs; 174 float64 createPtInSecs;
247 Histogram **measHists; 175 Histogram **measHists;
248 PrivDynArrayInfo *measHistsInfo; 176 PrivDynArrayInfo *measHistsInfo;
249 #ifdef MEAS__TIME_PLUGIN 177 #ifdef MEAS__TIME_PLUGIN
250 Histogram *reqHdlrLowTimeHist; 178 Histogram *reqHdlrLowTimeHist;
251 Histogram *reqHdlrHighTimeHist; 179 Histogram *reqHdlrHighTimeHist;
252 #endif 180 #endif
253 #ifdef MEAS__TIME_MALLOC 181 #ifdef MEAS__TIME_MALLOC
254 Histogram *mallocTimeHist; 182 Histogram *mallocTimeHist;
255 Histogram *freeTimeHist; 183 Histogram *freeTimeHist;
256 #endif 184 #endif
257 #ifdef MEAS__TIME_MASTER_LOCK 185 #ifdef MEAS__TIME_MASTER_LOCK
258 Histogram *masterLockLowTimeHist; 186 Histogram *masterLockLowTimeHist;
259 Histogram *masterLockHighTimeHist; 187 Histogram *masterLockHighTimeHist;
260 #endif 188 #endif
189 #ifdef MEAS__TIME_2011_SYS
190 TSCountLowHigh startMaster;
191 uint64 totalMasterCycles;
192 uint32 numMasterAnimations;
193 TSCountLowHigh startReqHdlr;
194 uint64 totalPluginCycles;
195 uint32 numPluginAnimations;
196 uint64 cyclesTillStartMasterLoop;
197 TSCountLowHigh endMasterLoop;
198 #endif
199 //==========================================
261 } 200 }
262 MasterEnv; 201 MasterEnv;
263 202
264 //========================= Extra Stuff Data Strucs ======================= 203 //========================= Extra Stuff Data Strucs =======================
265 typedef struct 204 typedef struct
279 218
280 //======================= OS Thread related =============================== 219 //======================= OS Thread related ===============================
281 220
282 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype 221 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
283 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype 222 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype
284 void masterLoop( void *initData, VirtProcr *masterPr ); 223 void masterLoop( void *initData, VirtProcr *masterVP );
285 224
286 225
287 typedef struct 226 typedef struct
288 { 227 {
289 void *endThdPt; 228 void *endThdPt;
376 315
377 void inline 316 void inline
378 VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv, 317 VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv,
379 ResumePrFnPtr resumePrFnPtr ); 318 ResumePrFnPtr resumePrFnPtr );
380 319
381 //======================== STATS ====================== 320 //======================== MEASUREMENT ======================
382 321 uint64
383 //===== RDTSC wrapper ===== //Also runs with x86_64 code 322 VMS__give_num_plugin_cycles();
384 323 uint32
385 #define saveTimeStampCountInto(low, high) \ 324 VMS__give_num_plugin_animations();
386 asm volatile("RDTSC; \ 325
387 movl %%eax, %0; \ 326
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 1
415 #define mutexLockHistIdx 2
416 #define mutexUnlockHistIdx 3
417 #define condWaitHistIdx 4
418 #define condSignalHistIdx 5
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 1
436 #define syncHistIdx 2
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 1
451 #define SendOfTypeHistIdx 2
452 #define ReceiveFromToHistIdx 3
453 #define ReceiveOfTypeHistIdx 4
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 327
574 #include "ProcrContext.h" 328 #include "ProcrContext.h"
575 #include "probes.h" 329 #include "probes.h"
576 #include "vutilities.h" 330 #include "vutilities.h"
577 331 #include "../VMS_lang_specific_defines.h"
578 #endif /* _VMS_H */ 332 #endif /* _VMS_H */
579 333