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