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