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