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