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