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