| rev |
line source |
|
Me@42
|
1 /*
|
|
Me@42
|
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
|
|
Me@42
|
3 * Licensed under GNU General Public License version 2
|
|
Me@42
|
4 *
|
|
Me@42
|
5 * Author: seanhalle@yahoo.com
|
|
Me@42
|
6 *
|
|
Me@42
|
7 */
|
|
Me@42
|
8 #ifndef _VMS_H
|
|
Me@42
|
9 #define _VMS_H
|
|
msach@76
|
10 #define _GNU_SOURCE
|
|
Me@42
|
11
|
|
Me@42
|
12 #include "VMS_primitive_data_types.h"
|
|
Me@55
|
13 #include "Queue_impl/PrivateQueue.h"
|
|
Me@42
|
14 #include "Histogram/Histogram.h"
|
|
Me@50
|
15 #include "DynArray/DynArray.h"
|
|
Me@50
|
16 #include "Hash_impl/PrivateHash.h"
|
|
Me@50
|
17 #include "vmalloc.h"
|
|
Me@50
|
18
|
|
Me@42
|
19 #include <pthread.h>
|
|
Me@50
|
20 #include <sys/time.h>
|
|
Me@42
|
21
|
|
Me@50
|
22
|
|
Me@50
|
23 //=============================== Debug ===================================
|
|
Me@55
|
24 //
|
|
msach@76
|
25 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread
|
|
msach@76
|
26 // It still does co-routines and all the mechanisms are the same, it just
|
|
msach@76
|
27 // has only a single thread and animates VPs one at a time
|
|
Me@45
|
28 //#define SEQUENTIAL
|
|
Me@42
|
29
|
|
Me@55
|
30 //#define USE_WORK_STEALING
|
|
Me@55
|
31
|
|
msach@76
|
32 //turns on the probe-instrumentation in the application -- when not
|
|
msach@76
|
33 // defined, the calls to the probe functions turn into comments
|
|
Me@52
|
34 #define STATS__ENABLE_PROBES
|
|
Me@60
|
35 //#define TURN_ON_DEBUG_PROBES
|
|
Me@52
|
36
|
|
msach@76
|
37 //These defines turn types of bug messages on and off
|
|
msach@76
|
38 // be sure debug messages are un-commented (next block of defines)
|
|
Me@68
|
39 #define dbgAppFlow TRUE /* Top level flow of application code -- general*/
|
|
Me@60
|
40 #define dbgProbes FALSE /* for issues inside probes themselves*/
|
|
Me@60
|
41 #define dbgB2BMaster FALSE /* in coreloop, back to back master VPs*/
|
|
Me@60
|
42 #define dbgRqstHdlr FALSE /* in request handler code*/
|
|
Me@52
|
43
|
|
msach@76
|
44 //Comment or un- the substitute half to turn on/off types of debug message
|
|
Me@55
|
45 #define DEBUG( bool, msg) \
|
|
Me@68
|
46 // if( bool){ printf(msg); fflush(stdin);}
|
|
Me@55
|
47 #define DEBUG1( bool, msg, param) \
|
|
Me@60
|
48 // if(bool){printf(msg, param); fflush(stdin);}
|
|
Me@55
|
49 #define DEBUG2( bool, msg, p1, p2) \
|
|
Me@60
|
50 // if(bool) {printf(msg, p1, p2); fflush(stdin);}
|
|
Me@45
|
51
|
|
msach@70
|
52 #define ERROR(msg) printf(msg);
|
|
msach@76
|
53 #define ERROR1(msg, param) printf(msg, param);
|
|
msach@70
|
54 #define ERROR2(msg, p1, p2) printf(msg, p1, p2);
|
|
Me@50
|
55
|
|
Me@50
|
56 //=========================== STATS =======================
|
|
Me@50
|
57
|
|
Me@45
|
58 //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and
|
|
Me@42
|
59 // compiled-in that saves the low part of the time stamp count just before
|
|
msach@76
|
60 // 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
|
|
Me@42
|
61 // saved into a field added to VirtProcr. Have to sanity-check for
|
|
Me@42
|
62 // rollover of low portion into high portion.
|
|
Me@65
|
63 //#define MEAS__TIME_STAMP_SUSP
|
|
Me@65
|
64 //#define MEAS__TIME_MASTER
|
|
Me@67
|
65 #define MEAS__TIME_PLUGIN
|
|
Me@67
|
66 #define MEAS__TIME_MALLOC
|
|
Me@68
|
67 //#define MEAS__TIME_MASTER_LOCK
|
|
Me@42
|
68 #define MEAS__NUM_TIMES_TO_RUN 100000
|
|
Me@42
|
69
|
|
Me@55
|
70 //For code that calculates normalization-offset between TSC counts of
|
|
Me@55
|
71 // different cores.
|
|
Me@45
|
72 #define NUM_TSC_ROUND_TRIPS 10
|
|
Me@45
|
73
|
|
Me@50
|
74
|
|
Me@50
|
75 //========================= Hardware related Constants =====================
|
|
Me@42
|
76 //This value is the number of hardware threads in the shared memory
|
|
Me@42
|
77 // machine
|
|
msach@69
|
78 #define NUM_CORES 8
|
|
Me@42
|
79
|
|
Me@55
|
80 // tradeoff amortizing master fixed overhead vs imbalance potential
|
|
Me@55
|
81 // when work-stealing, can make bigger, at risk of losing cache affinity
|
|
Me@55
|
82 #define NUM_SCHED_SLOTS 5
|
|
Me@42
|
83
|
|
Me@45
|
84 #define MIN_WORK_UNIT_CYCLES 20000
|
|
Me@45
|
85
|
|
Me@53
|
86 #define MASTERLOCK_RETRIES 10000
|
|
Me@42
|
87
|
|
Me@54
|
88 // stack size in virtual processors created
|
|
msach@78
|
89 #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */
|
|
Me@42
|
90
|
|
Me@54
|
91 // memory for VMS__malloc
|
|
Me@54
|
92 #define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */
|
|
Me@42
|
93
|
|
msach@78
|
94 #define CACHE_LINE 64
|
|
msach@79
|
95 #define PAGE_SIZE 4096
|
|
msach@78
|
96
|
|
Me@50
|
97
|
|
Me@50
|
98 //==============================
|
|
Me@42
|
99
|
|
Me@42
|
100 #define SUCCESS 0
|
|
Me@42
|
101
|
|
Me@55
|
102 #define writeVMSQ writePrivQ
|
|
Me@55
|
103 #define readVMSQ readPrivQ
|
|
Me@64
|
104 #define makeVMSQ makeVMSPrivQ
|
|
Me@55
|
105 #define numInVMSQ numInPrivQ
|
|
Me@55
|
106 #define VMSQueueStruc PrivQueueStruc
|
|
Me@42
|
107
|
|
Me@42
|
108
|
|
Me@50
|
109
|
|
Me@50
|
110 //===========================================================================
|
|
Me@50
|
111 typedef unsigned long long TSCount;
|
|
Me@50
|
112
|
|
Me@50
|
113 typedef struct _VMSReqst VMSReqst;
|
|
Me@120
|
114 typedef struct _InterMasterReqst InterMasterReqst;
|
|
Me@50
|
115 typedef struct _IntervalProbe IntervalProbe;
|
|
Me@55
|
116 typedef struct _GateStruc GateStruc;
|
|
Me@55
|
117
|
|
Me@42
|
118
|
|
Me@42
|
119 typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx
|
|
Me@42
|
120 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv
|
|
Me@42
|
121 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr
|
|
Me@42
|
122 typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr
|
|
Me@50
|
123 typedef void (*ResumePrFnPtr) ( VirtProcr *, void * );
|
|
Me@50
|
124
|
|
Me@50
|
125
|
|
Me@50
|
126 //============= Requests ===========
|
|
Me@50
|
127 //
|
|
Me@50
|
128
|
|
Me@120
|
129 //VMS Request is the carrier for Slave to Master requests
|
|
Me@120
|
130 // it has an embedded sub-type request that is pulled out
|
|
Me@120
|
131 // inside the plugin's request handler
|
|
Me@120
|
132 enum VMSReqstType //For Slave->Master requests
|
|
Me@120
|
133 {
|
|
Me@120
|
134 semantic = 1, //avoid starting enums at 0, for debug reasons
|
|
Me@50
|
135 createReq,
|
|
Me@50
|
136 dissipate,
|
|
Me@50
|
137 VMSSemantic //goes with VMSSemReqst below
|
|
Me@50
|
138 };
|
|
Me@50
|
139
|
|
Me@50
|
140 struct _VMSReqst
|
|
Me@50
|
141 {
|
|
Me@50
|
142 enum VMSReqstType reqType;//used for dissipate and in future for IO requests
|
|
Me@50
|
143 void *semReqData;
|
|
Me@50
|
144
|
|
Me@50
|
145 VMSReqst *nextReqst;
|
|
Me@50
|
146 };
|
|
Me@50
|
147 //VMSReqst
|
|
Me@50
|
148
|
|
Me@120
|
149 //This is a sub-type of Slave->Master requests.
|
|
Me@120
|
150 // It's for Slaves to invoke built-in VMS-core functions that have language-like
|
|
Me@120
|
151 // behavior.
|
|
Me@50
|
152 enum VMSSemReqstType //These are equivalent to semantic requests, but for
|
|
Me@50
|
153 { // VMS's services available directly to app, like OS
|
|
Me@50
|
154 createProbe = 1, // and probe services -- like a VMS-wide built-in lang
|
|
Me@50
|
155 openFile,
|
|
Me@50
|
156 otherIO
|
|
Me@50
|
157 };
|
|
Me@42
|
158
|
|
Me@42
|
159 typedef struct
|
|
Me@50
|
160 { enum VMSSemReqstType reqType;
|
|
Me@50
|
161 VirtProcr *requestingPr;
|
|
Me@50
|
162 char *nameStr; //for create probe
|
|
Me@42
|
163 }
|
|
Me@120
|
164 VMSSemReq;
|
|
Me@120
|
165
|
|
Me@120
|
166 //These are for Master to Master requests
|
|
Me@120
|
167 // They get re-cast to the appropriate sub-type of request
|
|
Me@120
|
168 enum InterMasterReqstType //For Master->Master
|
|
Me@120
|
169 {
|
|
Me@120
|
170 destVMSCore = 1, //avoid starting enums at 0, for debug reasons
|
|
Me@120
|
171 destPlugin
|
|
Me@120
|
172 };
|
|
Me@120
|
173
|
|
Me@120
|
174 struct _InterMasterReqst //Doing a trick to save space & time -- allocate
|
|
Me@120
|
175 { // space for a sub-type then cast first as InterMaster then as sub-type
|
|
Me@120
|
176 enum InterMasterReqstType reqType;
|
|
Me@120
|
177 InterMasterReqst *nextReqst;
|
|
Me@120
|
178 };
|
|
Me@120
|
179 //InterMasterReqst (defined above in typedef block)
|
|
Me@120
|
180
|
|
Me@120
|
181
|
|
Me@120
|
182 //These are a sub-type of InterMaster requests. The inter-master req gets
|
|
Me@120
|
183 // re-cast to be of this type, after checking
|
|
Me@120
|
184 //This ones for requests between internals of VMS-core.. such as malloc
|
|
Me@120
|
185 enum InterVMSCoreReqType
|
|
Me@120
|
186 {
|
|
Me@120
|
187 transfer_free_ptr = 1 //avoid starting enums at 0, for debug reasons
|
|
Me@120
|
188 };
|
|
Me@120
|
189
|
|
msach@127
|
190 //Doing a trick to save space & time -- allocate space
|
|
msach@127
|
191 // for this, cast first as InterMaster then as this
|
|
msach@127
|
192 typedef struct
|
|
msach@127
|
193 {
|
|
Me@120
|
194 enum InterMasterReqstType reqType; //duplicate InterMasterReqst at top
|
|
Me@120
|
195 InterMasterReqst *nextReqst;
|
|
Me@120
|
196
|
|
Me@120
|
197 enum InterVMSCoreReqType secondReqType;
|
|
Me@120
|
198 void *freePtr; //pile up fields, add as needed
|
|
msach@127
|
199 } InterVMSCoreReqst;
|
|
Me@120
|
200
|
|
Me@120
|
201 //This is for requests between plugins on different cores
|
|
Me@120
|
202 // Here, after casting, the pluginReq is extracted and handed to plugin
|
|
msach@127
|
203 //Doing a trick to save space & time -- allocate space
|
|
msach@127
|
204 // for this, cast first as InterMaster then as this
|
|
msach@127
|
205 typedef struct
|
|
msach@127
|
206 {
|
|
Me@120
|
207 enum InterMasterReqstType reqType; //copy InterMasterReqst at top
|
|
Me@120
|
208 InterMasterReqst *nextReqst;
|
|
Me@120
|
209
|
|
Me@120
|
210 void *pluginReq; //plugin will cast to approp type
|
|
msach@127
|
211 } InterPluginReqst;
|
|
Me@42
|
212
|
|
Me@50
|
213 //==================== Core data structures ===================
|
|
Me@50
|
214
|
|
Me@120
|
215 /*Master Env is the only global variable -- has entry points for any other
|
|
Me@120
|
216 * data needed.
|
|
Me@62
|
217 */
|
|
Me@42
|
218 typedef struct
|
|
Me@42
|
219 {
|
|
Me@42
|
220 SlaveScheduler slaveScheduler;
|
|
Me@42
|
221 RequestHandler requestHandler;
|
|
Me@42
|
222
|
|
Me@42
|
223 SchedSlot ***allSchedSlots;
|
|
msach@127
|
224 VMSQueueStruc **readyToAnimateQs;
|
|
Me@42
|
225 VirtProcr **masterVPs;
|
|
Me@42
|
226
|
|
Me@42
|
227 void *semanticEnv;
|
|
Me@42
|
228 void *OSEventStruc; //for future, when add I/O to BLIS
|
|
Me@42
|
229
|
|
msach@73
|
230 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
|
|
Me@42
|
231
|
|
Me@50
|
232 int32 setupComplete;
|
|
msach@71
|
233 volatile int32 masterLock;
|
|
msach@132
|
234
|
|
msach@132
|
235 MallocProlog *freeListHead[NUM_CORES];
|
|
msach@132
|
236 int32 amtOfOutstandingMem; //total currently allocated
|
|
Me@42
|
237
|
|
Me@50
|
238 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP
|
|
msach@132
|
239 GateStruc *workStealingGates[NUM_CORES]; //concurrent work-steal
|
|
Me@55
|
240 int32 workStealingLock;
|
|
Me@55
|
241
|
|
msach@127
|
242 InterMasterReqst* interMasterRequestsFor[NUM_CORES];
|
|
msach@127
|
243 RequestHandler interPluginReqHdlr;
|
|
msach@127
|
244
|
|
msach@127
|
245 int32 numProcrsCreated; //gives ordering to processor creation
|
|
msach@132
|
246
|
|
msach@132
|
247 int32 currentMasterProcrID;
|
|
Me@50
|
248
|
|
Me@50
|
249 //=========== MEASUREMENT STUFF =============
|
|
msach@127
|
250 IntervalProbe **intervalProbes;
|
|
msach@127
|
251 PrivDynArrayInfo *dynIntervalProbesInfo;
|
|
msach@127
|
252 HashTable *probeNameHashTbl;
|
|
msach@127
|
253 int32 masterCreateProbeID;
|
|
msach@127
|
254 float64 createPtInSecs;
|
|
msach@127
|
255 Histogram **measHists;
|
|
msach@127
|
256 PrivDynArrayInfo *measHistsInfo;
|
|
Me@65
|
257 #ifdef MEAS__TIME_PLUGIN
|
|
msach@127
|
258 Histogram *reqHdlrLowTimeHist;
|
|
msach@127
|
259 Histogram *reqHdlrHighTimeHist;
|
|
Me@65
|
260 #endif
|
|
Me@65
|
261 #ifdef MEAS__TIME_MALLOC
|
|
msach@127
|
262 Histogram *mallocTimeHist;
|
|
msach@127
|
263 Histogram *freeTimeHist;
|
|
Me@65
|
264 #endif
|
|
Me@65
|
265 #ifdef MEAS__TIME_MASTER_LOCK
|
|
msach@127
|
266 Histogram *masterLockLowTimeHist;
|
|
msach@127
|
267 Histogram *masterLockHighTimeHist;
|
|
Me@65
|
268 #endif
|
|
Me@42
|
269 }
|
|
Me@42
|
270 MasterEnv;
|
|
Me@42
|
271
|
|
Me@55
|
272 //========================= Extra Stuff Data Strucs =======================
|
|
Me@54
|
273 typedef struct
|
|
Me@54
|
274 {
|
|
Me@42
|
275
|
|
Me@54
|
276 }
|
|
Me@54
|
277 VMSExcp;
|
|
Me@50
|
278
|
|
Me@55
|
279 struct _GateStruc
|
|
Me@55
|
280 {
|
|
Me@55
|
281 int32 gateClosed;
|
|
Me@55
|
282 int32 preGateProgress;
|
|
Me@55
|
283 int32 waitProgress;
|
|
Me@55
|
284 int32 exitProgress;
|
|
Me@55
|
285 };
|
|
Me@55
|
286 //GateStruc
|
|
Me@50
|
287
|
|
Me@50
|
288 //======================= OS Thread related ===============================
|
|
Me@42
|
289
|
|
msach@69
|
290 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
|
|
Me@42
|
291 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype
|
|
Me@42
|
292 void masterLoop( void *initData, VirtProcr *masterPr );
|
|
Me@42
|
293
|
|
msach@69
|
294
|
|
Me@50
|
295 typedef struct
|
|
Me@50
|
296 {
|
|
Me@50
|
297 void *endThdPt;
|
|
Me@50
|
298 unsigned int coreNum;
|
|
Me@50
|
299 }
|
|
Me@50
|
300 ThdParams;
|
|
Me@42
|
301
|
|
Me@42
|
302 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state
|
|
Me@42
|
303 ThdParams *coreLoopThdParams [ NUM_CORES ];
|
|
Me@42
|
304 pthread_mutex_t suspendLock;
|
|
Me@42
|
305 pthread_cond_t suspend_cond;
|
|
Me@42
|
306
|
|
Me@50
|
307
|
|
msach@69
|
308
|
|
Me@50
|
309 //===================== Global Vars ===================
|
|
Me@50
|
310
|
|
Me@42
|
311 volatile MasterEnv *_VMSMasterEnv;
|
|
Me@42
|
312
|
|
Me@50
|
313
|
|
Me@50
|
314
|
|
Me@50
|
315
|
|
Me@50
|
316 //=========================== Function Prototypes =========================
|
|
Me@50
|
317
|
|
Me@53
|
318
|
|
Me@53
|
319 //========== Setup and shutdown ==========
|
|
Me@42
|
320 void
|
|
Me@42
|
321 VMS__init();
|
|
Me@42
|
322
|
|
Me@42
|
323 void
|
|
Me@42
|
324 VMS__init_Seq();
|
|
Me@42
|
325
|
|
Me@42
|
326 void
|
|
Me@42
|
327 VMS__start_the_work_then_wait_until_done();
|
|
Me@42
|
328
|
|
Me@42
|
329 void
|
|
Me@42
|
330 VMS__start_the_work_then_wait_until_done_Seq();
|
|
Me@42
|
331
|
|
msach@76
|
332 inline VirtProcr *
|
|
Me@42
|
333 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
|
|
Me@42
|
334
|
|
Me@53
|
335 void
|
|
Me@53
|
336 VMS__dissipate_procr( VirtProcr *procrToDissipate );
|
|
Me@53
|
337
|
|
Me@50
|
338 //Use this to create processor inside entry point & other places outside
|
|
Me@50
|
339 // the VMS system boundary (IE, not run in slave nor Master)
|
|
Me@50
|
340 VirtProcr *
|
|
Me@50
|
341 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
|
|
Me@50
|
342
|
|
Me@53
|
343 void
|
|
Me@53
|
344 VMS_ext__dissipate_procr( VirtProcr *procrToDissipate );
|
|
Me@42
|
345
|
|
Me@50
|
346 void
|
|
Me@54
|
347 VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData );
|
|
Me@54
|
348
|
|
Me@54
|
349 void
|
|
Me@53
|
350 VMS__shutdown();
|
|
Me@53
|
351
|
|
Me@53
|
352 void
|
|
Me@53
|
353 VMS__cleanup_at_end_of_shutdown();
|
|
Me@50
|
354
|
|
Me@64
|
355 void *
|
|
Me@64
|
356 VMS__give_sem_env_for( VirtProcr *animPr );
|
|
Me@64
|
357
|
|
Me@50
|
358
|
|
Me@50
|
359 //============== Request Related ===============
|
|
Me@50
|
360
|
|
Me@50
|
361 void
|
|
Me@50
|
362 VMS__suspend_procr( VirtProcr *callingPr );
|
|
Me@50
|
363
|
|
Me@42
|
364 inline void
|
|
Me@53
|
365 VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr );
|
|
Me@53
|
366
|
|
Me@53
|
367 inline void
|
|
Me@53
|
368 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
|
|
Me@42
|
369
|
|
Me@42
|
370 void
|
|
Me@50
|
371 VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr );
|
|
Me@42
|
372
|
|
Me@53
|
373 void inline
|
|
Me@53
|
374 VMS__send_dissipate_req( VirtProcr *prToDissipate );
|
|
Me@53
|
375
|
|
Me@52
|
376 inline void
|
|
Me@52
|
377 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr );
|
|
Me@52
|
378
|
|
Me@120
|
379
|
|
Me@120
|
380 void inline
|
|
Me@120
|
381 VMS__send_inter_plugin_req( void *reqData, int32 targetMaster,
|
|
Me@120
|
382 VirtProcr *requestingMaster );
|
|
Me@120
|
383 void inline
|
|
Me@120
|
384 VMS__send_inter_VMSCore_req( InterVMSCoreReqst *reqData, int32 targetMaster,
|
|
Me@120
|
385 VirtProcr *requestingMaster );
|
|
Me@120
|
386
|
|
Me@42
|
387 VMSReqst *
|
|
Me@50
|
388 VMS__take_next_request_out_of( VirtProcr *procrWithReq );
|
|
Me@42
|
389
|
|
Me@42
|
390 inline void *
|
|
Me@42
|
391 VMS__take_sem_reqst_from( VMSReqst *req );
|
|
Me@42
|
392
|
|
msach@78
|
393 void inline
|
|
msach@78
|
394 VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv,
|
|
msach@78
|
395 ResumePrFnPtr resumePrFnPtr );
|
|
msach@78
|
396
|
|
Me@53
|
397 //======================== STATS ======================
|
|
Me@42
|
398
|
|
msach@76
|
399 //===== RDTSC wrapper ===== //Also runs with x86_64 code
|
|
Me@42
|
400
|
|
Me@42
|
401 #define saveTimeStampCountInto(low, high) \
|
|
Me@42
|
402 asm volatile("RDTSC; \
|
|
Me@42
|
403 movl %%eax, %0; \
|
|
Me@42
|
404 movl %%edx, %1;" \
|
|
Me@42
|
405 /* outputs */ : "=m" (low), "=m" (high)\
|
|
Me@42
|
406 /* inputs */ : \
|
|
Me@42
|
407 /* clobber */ : "%eax", "%edx" \
|
|
Me@42
|
408 );
|
|
Me@42
|
409
|
|
Me@42
|
410 #define saveLowTimeStampCountInto(low) \
|
|
Me@42
|
411 asm volatile("RDTSC; \
|
|
Me@42
|
412 movl %%eax, %0;" \
|
|
Me@42
|
413 /* outputs */ : "=m" (low) \
|
|
Me@42
|
414 /* inputs */ : \
|
|
Me@42
|
415 /* clobber */ : "%eax", "%edx" \
|
|
Me@42
|
416 );
|
|
Me@68
|
417
|
|
Me@68
|
418 //====================
|
|
Me@68
|
419 #define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \
|
|
Me@68
|
420 makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \
|
|
Me@68
|
421 _VMSMasterEnv->measHists[idx] = \
|
|
Me@68
|
422 makeFixedBinHist( numBins, startVal, binWidth, name );
|
|
Me@68
|
423
|
|
Me@68
|
424
|
|
Me@68
|
425 #define MEAS__SUB_CREATE /*turn on/off subtraction of create from plugin*/
|
|
msach@69
|
426
|
|
msach@73
|
427 #ifdef VPTHREAD
|
|
msach@73
|
428
|
|
msach@69
|
429 //VPThread
|
|
Me@68
|
430 #define createHistIdx 1
|
|
Me@68
|
431 #define mutexLockHistIdx 2
|
|
Me@68
|
432 #define mutexUnlockHistIdx 3
|
|
Me@68
|
433 #define condWaitHistIdx 4
|
|
Me@68
|
434 #define condSignalHistIdx 5
|
|
Me@68
|
435
|
|
msach@76
|
436 #define MakeTheMeasHists() \
|
|
msach@73
|
437 _VMSMasterEnv->measHistsInfo = \
|
|
msach@73
|
438 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
|
|
msach@84
|
439 makeAMeasHist( createHistIdx, "create", 250, 0, 100 ) \
|
|
msach@78
|
440 makeAMeasHist( mutexLockHistIdx, "mutex_lock", 50, 0, 100 ) \
|
|
msach@78
|
441 makeAMeasHist( mutexUnlockHistIdx, "mutex_unlock", 50, 0, 100 ) \
|
|
msach@78
|
442 makeAMeasHist( condWaitHistIdx, "cond_wait", 50, 0, 100 ) \
|
|
msach@78
|
443 makeAMeasHist( condSignalHistIdx, "cond_signal", 50, 0, 100 )
|
|
msach@73
|
444
|
|
msach@73
|
445 #endif
|
|
msach@73
|
446
|
|
msach@73
|
447
|
|
msach@73
|
448 #ifdef VCILK
|
|
msach@73
|
449
|
|
msach@69
|
450 //VCilk
|
|
msach@69
|
451 #define spawnHistIdx 1
|
|
msach@69
|
452 #define syncHistIdx 2
|
|
msach@69
|
453
|
|
msach@76
|
454 #define MakeTheMeasHists() \
|
|
msach@73
|
455 _VMSMasterEnv->measHistsInfo = \
|
|
msach@73
|
456 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
|
|
msach@73
|
457 makeAMeasHist( spawnHistIdx, "Spawn", 50, 0, 200 ) \
|
|
msach@73
|
458 makeAMeasHist( syncHistIdx, "Sync", 50, 0, 200 )
|
|
msach@73
|
459
|
|
msach@73
|
460
|
|
msach@73
|
461 #endif
|
|
msach@73
|
462
|
|
msach@73
|
463 #ifdef SSR
|
|
msach@73
|
464
|
|
msach@69
|
465 //SSR
|
|
msach@69
|
466 #define SendFromToHistIdx 1
|
|
msach@69
|
467 #define SendOfTypeHistIdx 2
|
|
msach@69
|
468 #define ReceiveFromToHistIdx 3
|
|
msach@69
|
469 #define ReceiveOfTypeHistIdx 4
|
|
msach@69
|
470
|
|
msach@76
|
471 #define MakeTheMeasHists() \
|
|
msach@69
|
472 _VMSMasterEnv->measHistsInfo = \
|
|
msach@73
|
473 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
|
|
msach@73
|
474 makeAMeasHist( SendFromToHistIdx, "SendFromTo", 50, 0, 100 ) \
|
|
msach@73
|
475 makeAMeasHist( SendOfTypeHistIdx, "SendOfType", 50, 0, 100 ) \
|
|
msach@73
|
476 makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \
|
|
msach@73
|
477 makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 )
|
|
Me@68
|
478
|
|
msach@73
|
479 #endif
|
|
msach@69
|
480
|
|
msach@69
|
481 //===========================================================================
|
|
msach@69
|
482 //VPThread
|
|
msach@69
|
483
|
|
Me@68
|
484
|
|
Me@68
|
485 #define Meas_startCreate \
|
|
Me@68
|
486 int32 startStamp, endStamp; \
|
|
Me@68
|
487 saveLowTimeStampCountInto( startStamp ); \
|
|
Me@68
|
488
|
|
Me@68
|
489 #define Meas_endCreate \
|
|
Me@68
|
490 saveLowTimeStampCountInto( endStamp ); \
|
|
Me@68
|
491 addIntervalToHist( startStamp, endStamp, \
|
|
Me@68
|
492 _VMSMasterEnv->measHists[ createHistIdx ] );
|
|
Me@68
|
493
|
|
Me@68
|
494 #define Meas_startMutexLock \
|
|
Me@68
|
495 int32 startStamp, endStamp; \
|
|
Me@68
|
496 saveLowTimeStampCountInto( startStamp ); \
|
|
Me@68
|
497
|
|
Me@68
|
498 #define Meas_endMutexLock \
|
|
Me@68
|
499 saveLowTimeStampCountInto( endStamp ); \
|
|
Me@68
|
500 addIntervalToHist( startStamp, endStamp, \
|
|
Me@68
|
501 _VMSMasterEnv->measHists[ mutexLockHistIdx ] );
|
|
Me@68
|
502
|
|
Me@68
|
503 #define Meas_startMutexUnlock \
|
|
Me@68
|
504 int32 startStamp, endStamp; \
|
|
Me@68
|
505 saveLowTimeStampCountInto( startStamp ); \
|
|
Me@68
|
506
|
|
Me@68
|
507 #define Meas_endMutexUnlock \
|
|
Me@68
|
508 saveLowTimeStampCountInto( endStamp ); \
|
|
Me@68
|
509 addIntervalToHist( startStamp, endStamp, \
|
|
Me@68
|
510 _VMSMasterEnv->measHists[ mutexUnlockHistIdx ] );
|
|
Me@68
|
511
|
|
Me@68
|
512 #define Meas_startCondWait \
|
|
Me@68
|
513 int32 startStamp, endStamp; \
|
|
Me@68
|
514 saveLowTimeStampCountInto( startStamp ); \
|
|
Me@68
|
515
|
|
Me@68
|
516 #define Meas_endCondWait \
|
|
Me@68
|
517 saveLowTimeStampCountInto( endStamp ); \
|
|
Me@68
|
518 addIntervalToHist( startStamp, endStamp, \
|
|
Me@68
|
519 _VMSMasterEnv->measHists[ condWaitHistIdx ] );
|
|
Me@68
|
520
|
|
Me@68
|
521 #define Meas_startCondSignal \
|
|
Me@68
|
522 int32 startStamp, endStamp; \
|
|
Me@68
|
523 saveLowTimeStampCountInto( startStamp ); \
|
|
Me@68
|
524
|
|
Me@68
|
525 #define Meas_endCondSignal \
|
|
Me@68
|
526 saveLowTimeStampCountInto( endStamp ); \
|
|
Me@68
|
527 addIntervalToHist( startStamp, endStamp, \
|
|
Me@68
|
528 _VMSMasterEnv->measHists[ condSignalHistIdx ] );
|
|
Me@68
|
529
|
|
msach@69
|
530 //===========================================================================
|
|
msach@69
|
531 // VCilk
|
|
msach@69
|
532 #define Meas_startSpawn \
|
|
msach@69
|
533 int32 startStamp, endStamp; \
|
|
msach@69
|
534 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@69
|
535
|
|
msach@69
|
536 #define Meas_endSpawn \
|
|
msach@69
|
537 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@69
|
538 addIntervalToHist( startStamp, endStamp, \
|
|
msach@69
|
539 _VMSMasterEnv->measHists[ spawnHistIdx ] );
|
|
msach@69
|
540
|
|
msach@69
|
541 #define Meas_startSync \
|
|
msach@69
|
542 int32 startStamp, endStamp; \
|
|
msach@69
|
543 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@69
|
544
|
|
msach@69
|
545 #define Meas_endSync \
|
|
msach@69
|
546 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@69
|
547 addIntervalToHist( startStamp, endStamp, \
|
|
msach@69
|
548 _VMSMasterEnv->measHists[ syncHistIdx ] );
|
|
msach@69
|
549
|
|
msach@69
|
550 //===========================================================================
|
|
msach@69
|
551 // SSR
|
|
msach@69
|
552 #define Meas_startSendFromTo \
|
|
msach@69
|
553 int32 startStamp, endStamp; \
|
|
msach@69
|
554 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@69
|
555
|
|
msach@69
|
556 #define Meas_endSendFromTo \
|
|
msach@69
|
557 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@69
|
558 addIntervalToHist( startStamp, endStamp, \
|
|
msach@69
|
559 _VMSMasterEnv->measHists[ SendFromToHistIdx ] );
|
|
msach@69
|
560
|
|
msach@69
|
561 #define Meas_startSendOfType \
|
|
msach@69
|
562 int32 startStamp, endStamp; \
|
|
msach@69
|
563 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@69
|
564
|
|
msach@69
|
565 #define Meas_endSendOfType \
|
|
msach@69
|
566 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@69
|
567 addIntervalToHist( startStamp, endStamp, \
|
|
msach@69
|
568 _VMSMasterEnv->measHists[ SendOfTypeHistIdx ] );
|
|
msach@69
|
569
|
|
msach@69
|
570 #define Meas_startReceiveFromTo \
|
|
msach@69
|
571 int32 startStamp, endStamp; \
|
|
msach@69
|
572 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@69
|
573
|
|
msach@69
|
574 #define Meas_endReceiveFromTo \
|
|
msach@69
|
575 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@69
|
576 addIntervalToHist( startStamp, endStamp, \
|
|
msach@69
|
577 _VMSMasterEnv->measHists[ ReceiveFromToHistIdx ] );
|
|
msach@69
|
578
|
|
msach@69
|
579 #define Meas_startReceiveOfType \
|
|
msach@69
|
580 int32 startStamp, endStamp; \
|
|
msach@69
|
581 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@69
|
582
|
|
msach@69
|
583 #define Meas_endReceiveOfType \
|
|
msach@69
|
584 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@69
|
585 addIntervalToHist( startStamp, endStamp, \
|
|
msach@69
|
586 _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] );
|
|
Me@68
|
587
|
|
Me@53
|
588 //=====
|
|
Me@42
|
589
|
|
msach@77
|
590 #include "ProcrContext.h"
|
|
Me@50
|
591 #include "probes.h"
|
|
Me@65
|
592 #include "vutilities.h"
|
|
Me@42
|
593
|
|
Me@42
|
594 #endif /* _VMS_H */
|
|
Me@42
|
595
|