| 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 * );
|
|
msach@94
|
133
|
|
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 //
|
|
engelhardt@108
|
213 CounterRecord** counter_history;
|
|
engelhardt@108
|
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 //
|
|
Nina@131
|
279 CounterRecord** counter_history;
|
|
Nina@131
|
280 PrivDynArrayInfo* counter_history_array_info;
|
|
Nina@131
|
281 #endif
|
|
msach@94
|
282 }
|
|
msach@94
|
283 MasterEnv;
|
|
msach@94
|
284
|
|
msach@94
|
285 //========================= Extra Stuff Data Strucs =======================
|
|
msach@94
|
286 typedef struct
|
|
msach@94
|
287 {
|
|
msach@94
|
288
|
|
msach@94
|
289 }
|
|
msach@94
|
290 VMSExcp;
|
|
msach@94
|
291
|
|
msach@94
|
292 struct _GateStruc
|
|
msach@94
|
293 {
|
|
msach@94
|
294 int32 gateClosed;
|
|
msach@94
|
295 int32 preGateProgress;
|
|
msach@94
|
296 int32 waitProgress;
|
|
msach@94
|
297 int32 exitProgress;
|
|
msach@94
|
298 };
|
|
msach@94
|
299 //GateStruc
|
|
msach@94
|
300
|
|
msach@94
|
301 //======================= OS Thread related ===============================
|
|
msach@94
|
302
|
|
msach@94
|
303 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
|
|
msach@94
|
304 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype
|
|
msach@94
|
305 void masterLoop( void *initData, VirtProcr *masterPr );
|
|
msach@94
|
306
|
|
msach@94
|
307
|
|
msach@94
|
308 typedef struct
|
|
msach@94
|
309 {
|
|
msach@94
|
310 void *endThdPt;
|
|
msach@94
|
311 unsigned int coreNum;
|
|
msach@94
|
312 }
|
|
msach@94
|
313 ThdParams;
|
|
msach@94
|
314
|
|
msach@94
|
315 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state
|
|
msach@94
|
316 ThdParams *coreLoopThdParams [ NUM_CORES ];
|
|
msach@94
|
317 pthread_mutex_t suspendLock;
|
|
msach@94
|
318 pthread_cond_t suspend_cond;
|
|
msach@94
|
319
|
|
msach@94
|
320
|
|
msach@94
|
321
|
|
msach@94
|
322 //===================== Global Vars ===================
|
|
msach@94
|
323
|
|
msach@94
|
324 volatile MasterEnv *_VMSMasterEnv;
|
|
msach@94
|
325
|
|
msach@94
|
326
|
|
msach@94
|
327
|
|
msach@94
|
328
|
|
msach@94
|
329 //=========================== Function Prototypes =========================
|
|
msach@94
|
330
|
|
msach@94
|
331
|
|
msach@94
|
332 //========== Setup and shutdown ==========
|
|
msach@94
|
333 void
|
|
msach@94
|
334 VMS__init();
|
|
msach@94
|
335
|
|
msach@94
|
336 void
|
|
msach@94
|
337 VMS__init_Seq();
|
|
msach@94
|
338
|
|
msach@94
|
339 void
|
|
msach@94
|
340 VMS__start_the_work_then_wait_until_done();
|
|
msach@94
|
341
|
|
msach@94
|
342 void
|
|
msach@94
|
343 VMS__start_the_work_then_wait_until_done_Seq();
|
|
msach@94
|
344
|
|
msach@94
|
345 inline VirtProcr *
|
|
msach@94
|
346 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
|
|
msach@94
|
347
|
|
msach@94
|
348 void
|
|
msach@94
|
349 VMS__dissipate_procr( VirtProcr *procrToDissipate );
|
|
msach@94
|
350
|
|
msach@94
|
351 //Use this to create processor inside entry point & other places outside
|
|
msach@94
|
352 // the VMS system boundary (IE, not run in slave nor Master)
|
|
msach@94
|
353 VirtProcr *
|
|
msach@94
|
354 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
|
|
msach@94
|
355
|
|
msach@94
|
356 void
|
|
msach@94
|
357 VMS_ext__dissipate_procr( VirtProcr *procrToDissipate );
|
|
msach@94
|
358
|
|
msach@94
|
359 void
|
|
msach@94
|
360 VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData );
|
|
msach@94
|
361
|
|
msach@94
|
362 void
|
|
msach@94
|
363 VMS__shutdown();
|
|
msach@94
|
364
|
|
msach@94
|
365 void
|
|
msach@94
|
366 VMS__cleanup_at_end_of_shutdown();
|
|
msach@94
|
367
|
|
msach@94
|
368 void *
|
|
msach@94
|
369 VMS__give_sem_env_for( VirtProcr *animPr );
|
|
msach@94
|
370
|
|
msach@94
|
371
|
|
msach@94
|
372 //============== Request Related ===============
|
|
msach@94
|
373
|
|
msach@94
|
374 void
|
|
msach@94
|
375 VMS__suspend_procr( VirtProcr *callingPr );
|
|
msach@94
|
376
|
|
msach@94
|
377 inline void
|
|
msach@94
|
378 VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr );
|
|
msach@94
|
379
|
|
nengel@182
|
380 inline void
|
|
msach@94
|
381 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
|
|
msach@94
|
382
|
|
msach@94
|
383 void
|
|
msach@94
|
384 VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr );
|
|
msach@94
|
385
|
|
nengel@182
|
386 void inline
|
|
msach@94
|
387 VMS__send_dissipate_req( VirtProcr *prToDissipate );
|
|
msach@94
|
388
|
|
nengel@182
|
389 inline void
|
|
msach@94
|
390 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr );
|
|
msach@94
|
391
|
|
msach@94
|
392 VMSReqst *
|
|
msach@94
|
393 VMS__take_next_request_out_of( VirtProcr *procrWithReq );
|
|
msach@94
|
394
|
|
msach@94
|
395 inline void *
|
|
msach@94
|
396 VMS__take_sem_reqst_from( VMSReqst *req );
|
|
msach@94
|
397
|
|
msach@94
|
398 void inline
|
|
msach@94
|
399 VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv,
|
|
msach@94
|
400 ResumePrFnPtr resumePrFnPtr );
|
|
msach@94
|
401
|
|
msach@94
|
402 //======================== STATS ======================
|
|
msach@94
|
403
|
|
msach@94
|
404 //===== RDTSC wrapper ===== //Also runs with x86_64 code
|
|
msach@94
|
405
|
|
msach@94
|
406 #define saveTimeStampCountInto(low, high) \
|
|
msach@94
|
407 asm volatile("RDTSC; \
|
|
msach@94
|
408 movl %%eax, %0; \
|
|
msach@94
|
409 movl %%edx, %1;" \
|
|
msach@94
|
410 /* outputs */ : "=m" (low), "=m" (high)\
|
|
msach@94
|
411 /* inputs */ : \
|
|
msach@94
|
412 /* clobber */ : "%eax", "%edx" \
|
|
msach@94
|
413 );
|
|
msach@94
|
414
|
|
msach@94
|
415 #define saveLowTimeStampCountInto(low) \
|
|
msach@94
|
416 asm volatile("RDTSC; \
|
|
msach@94
|
417 movl %%eax, %0;" \
|
|
msach@94
|
418 /* outputs */ : "=m" (low) \
|
|
msach@94
|
419 /* inputs */ : \
|
|
msach@94
|
420 /* clobber */ : "%eax", "%edx" \
|
|
msach@94
|
421 );
|
|
msach@94
|
422
|
|
msach@94
|
423 //====================
|
|
msach@94
|
424 #define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \
|
|
msach@94
|
425 makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \
|
|
msach@94
|
426 _VMSMasterEnv->measHists[idx] = \
|
|
msach@94
|
427 makeFixedBinHist( numBins, startVal, binWidth, name );
|
|
msach@94
|
428
|
|
Nina@109
|
429 #define saveCyclesAndInstrs(core,cycles,instrs) do{ \
|
|
Nina@109
|
430 int cycles_fd = _VMSMasterEnv->cycles_counter_fd[core]; \
|
|
Nina@109
|
431 int instrs_fd = _VMSMasterEnv->instrs_counter_fd[core]; \
|
|
Nina@109
|
432 int nread; \
|
|
Nina@109
|
433 \
|
|
Nina@109
|
434 nread = read(cycles_fd,&(cycles),sizeof(cycles)); \
|
|
Nina@109
|
435 if(nread<0){ \
|
|
Nina@109
|
436 perror("Error reading cycles counter"); \
|
|
Nina@109
|
437 cycles = 0; \
|
|
Nina@109
|
438 } \
|
|
Nina@109
|
439 \
|
|
Nina@109
|
440 nread = read(instrs_fd,&(instrs),sizeof(instrs)); \
|
|
Nina@109
|
441 if(nread<0){ \
|
|
Nina@109
|
442 perror("Error reading cycles counter"); \
|
|
Nina@109
|
443 instrs = 0; \
|
|
Nina@109
|
444 } \
|
|
Nina@109
|
445 } while (0)
|
|
Nina@109
|
446
|
|
Nina@111
|
447 #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \
|
|
Nina@111
|
448 void* frame_ptr0 = vp_ptr->framePtr; \
|
|
Nina@110
|
449 void* frame_ptr1 = *((void**)frame_ptr0); \
|
|
Nina@110
|
450 void* frame_ptr2 = *((void**)frame_ptr1); \
|
|
Nina@110
|
451 void* frame_ptr3 = *((void**)frame_ptr2); \
|
|
Nina@111
|
452 void* ret_addr = *((void**)frame_ptr3 + 1); \
|
|
Nina@111
|
453 *res_ptr = ret_addr; \
|
|
Nina@110
|
454 } while (0)
|
|
msach@94
|
455
|
|
msach@94
|
456 #define MEAS__SUB_CREATE /*turn on/off subtraction of create from plugin*/
|
|
msach@94
|
457
|
|
msach@94
|
458 #ifdef VPTHREAD
|
|
msach@94
|
459
|
|
msach@94
|
460 //VPThread
|
|
nengel@182
|
461 #define createHistIdx 0
|
|
nengel@182
|
462 #define mutexLockHistIdx 1
|
|
nengel@182
|
463 #define mutexUnlockHistIdx 2
|
|
nengel@182
|
464 #define condWaitHistIdx 3
|
|
nengel@182
|
465 #define condSignalHistIdx 4
|
|
msach@94
|
466
|
|
msach@94
|
467 #define MakeTheMeasHists() \
|
|
msach@94
|
468 _VMSMasterEnv->measHistsInfo = \
|
|
msach@94
|
469 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
|
|
msach@94
|
470 makeAMeasHist( createHistIdx, "create", 250, 0, 100 ) \
|
|
msach@94
|
471 makeAMeasHist( mutexLockHistIdx, "mutex_lock", 50, 0, 100 ) \
|
|
msach@94
|
472 makeAMeasHist( mutexUnlockHistIdx, "mutex_unlock", 50, 0, 100 ) \
|
|
msach@94
|
473 makeAMeasHist( condWaitHistIdx, "cond_wait", 50, 0, 100 ) \
|
|
msach@94
|
474 makeAMeasHist( condSignalHistIdx, "cond_signal", 50, 0, 100 )
|
|
msach@94
|
475
|
|
msach@94
|
476 #endif
|
|
msach@94
|
477
|
|
msach@94
|
478
|
|
msach@94
|
479 #ifdef VCILK
|
|
msach@94
|
480
|
|
msach@94
|
481 //VCilk
|
|
nengel@182
|
482 #define spawnHistIdx 0
|
|
nengel@182
|
483 #define syncHistIdx 1
|
|
msach@94
|
484
|
|
msach@94
|
485 #define MakeTheMeasHists() \
|
|
msach@94
|
486 _VMSMasterEnv->measHistsInfo = \
|
|
msach@94
|
487 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
|
|
msach@94
|
488 makeAMeasHist( spawnHistIdx, "Spawn", 50, 0, 200 ) \
|
|
msach@94
|
489 makeAMeasHist( syncHistIdx, "Sync", 50, 0, 200 )
|
|
msach@94
|
490
|
|
msach@94
|
491
|
|
msach@94
|
492 #endif
|
|
msach@94
|
493
|
|
msach@94
|
494 #ifdef SSR
|
|
msach@94
|
495
|
|
msach@94
|
496 //SSR
|
|
nengel@182
|
497 #define SendFromToHistIdx 0
|
|
nengel@182
|
498 #define SendOfTypeHistIdx 1
|
|
nengel@182
|
499 #define ReceiveFromToHistIdx 2
|
|
nengel@182
|
500 #define ReceiveOfTypeHistIdx 3
|
|
msach@94
|
501
|
|
msach@94
|
502 #define MakeTheMeasHists() \
|
|
msach@94
|
503 _VMSMasterEnv->measHistsInfo = \
|
|
msach@94
|
504 makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
|
|
msach@94
|
505 makeAMeasHist( SendFromToHistIdx, "SendFromTo", 50, 0, 100 ) \
|
|
msach@94
|
506 makeAMeasHist( SendOfTypeHistIdx, "SendOfType", 50, 0, 100 ) \
|
|
msach@94
|
507 makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \
|
|
msach@94
|
508 makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 )
|
|
msach@94
|
509
|
|
msach@94
|
510 #endif
|
|
msach@94
|
511
|
|
msach@94
|
512 //===========================================================================
|
|
msach@94
|
513 //VPThread
|
|
msach@94
|
514
|
|
msach@94
|
515
|
|
msach@94
|
516 #define Meas_startCreate \
|
|
msach@94
|
517 int32 startStamp, endStamp; \
|
|
msach@94
|
518 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
519
|
|
msach@94
|
520 #define Meas_endCreate \
|
|
msach@94
|
521 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
522 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
523 _VMSMasterEnv->measHists[ createHistIdx ] );
|
|
msach@94
|
524
|
|
msach@94
|
525 #define Meas_startMutexLock \
|
|
msach@94
|
526 int32 startStamp, endStamp; \
|
|
msach@94
|
527 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
528
|
|
msach@94
|
529 #define Meas_endMutexLock \
|
|
msach@94
|
530 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
531 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
532 _VMSMasterEnv->measHists[ mutexLockHistIdx ] );
|
|
msach@94
|
533
|
|
msach@94
|
534 #define Meas_startMutexUnlock \
|
|
msach@94
|
535 int32 startStamp, endStamp; \
|
|
msach@94
|
536 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
537
|
|
msach@94
|
538 #define Meas_endMutexUnlock \
|
|
msach@94
|
539 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
540 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
541 _VMSMasterEnv->measHists[ mutexUnlockHistIdx ] );
|
|
msach@94
|
542
|
|
msach@94
|
543 #define Meas_startCondWait \
|
|
msach@94
|
544 int32 startStamp, endStamp; \
|
|
msach@94
|
545 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
546
|
|
msach@94
|
547 #define Meas_endCondWait \
|
|
msach@94
|
548 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
549 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
550 _VMSMasterEnv->measHists[ condWaitHistIdx ] );
|
|
msach@94
|
551
|
|
msach@94
|
552 #define Meas_startCondSignal \
|
|
msach@94
|
553 int32 startStamp, endStamp; \
|
|
msach@94
|
554 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
555
|
|
msach@94
|
556 #define Meas_endCondSignal \
|
|
msach@94
|
557 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
558 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
559 _VMSMasterEnv->measHists[ condSignalHistIdx ] );
|
|
msach@94
|
560
|
|
msach@94
|
561 //===========================================================================
|
|
msach@94
|
562 // VCilk
|
|
msach@94
|
563 #define Meas_startSpawn \
|
|
msach@94
|
564 int32 startStamp, endStamp; \
|
|
msach@94
|
565 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
566
|
|
msach@94
|
567 #define Meas_endSpawn \
|
|
msach@94
|
568 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
569 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
570 _VMSMasterEnv->measHists[ spawnHistIdx ] );
|
|
msach@94
|
571
|
|
msach@94
|
572 #define Meas_startSync \
|
|
msach@94
|
573 int32 startStamp, endStamp; \
|
|
msach@94
|
574 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
575
|
|
msach@94
|
576 #define Meas_endSync \
|
|
msach@94
|
577 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
578 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
579 _VMSMasterEnv->measHists[ syncHistIdx ] );
|
|
msach@94
|
580
|
|
msach@94
|
581 //===========================================================================
|
|
msach@94
|
582 // SSR
|
|
msach@94
|
583 #define Meas_startSendFromTo \
|
|
msach@94
|
584 int32 startStamp, endStamp; \
|
|
msach@94
|
585 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
586
|
|
msach@94
|
587 #define Meas_endSendFromTo \
|
|
msach@94
|
588 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
589 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
590 _VMSMasterEnv->measHists[ SendFromToHistIdx ] );
|
|
msach@94
|
591
|
|
msach@94
|
592 #define Meas_startSendOfType \
|
|
msach@94
|
593 int32 startStamp, endStamp; \
|
|
msach@94
|
594 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
595
|
|
msach@94
|
596 #define Meas_endSendOfType \
|
|
msach@94
|
597 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
598 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
599 _VMSMasterEnv->measHists[ SendOfTypeHistIdx ] );
|
|
msach@94
|
600
|
|
msach@94
|
601 #define Meas_startReceiveFromTo \
|
|
msach@94
|
602 int32 startStamp, endStamp; \
|
|
msach@94
|
603 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
604
|
|
msach@94
|
605 #define Meas_endReceiveFromTo \
|
|
msach@94
|
606 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
607 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
608 _VMSMasterEnv->measHists[ ReceiveFromToHistIdx ] );
|
|
msach@94
|
609
|
|
msach@94
|
610 #define Meas_startReceiveOfType \
|
|
msach@94
|
611 int32 startStamp, endStamp; \
|
|
msach@94
|
612 saveLowTimeStampCountInto( startStamp ); \
|
|
msach@94
|
613
|
|
msach@94
|
614 #define Meas_endReceiveOfType \
|
|
msach@94
|
615 saveLowTimeStampCountInto( endStamp ); \
|
|
msach@94
|
616 addIntervalToHist( startStamp, endStamp, \
|
|
msach@94
|
617 _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] );
|
|
msach@94
|
618
|
|
msach@94
|
619 //=====
|
|
msach@94
|
620
|
|
msach@94
|
621 #include "ProcrContext.h"
|
|
msach@94
|
622 #include "probes.h"
|
|
msach@94
|
623 #include "vutilities.h"
|
|
msach@94
|
624
|
|
msach@94
|
625 #endif /* _VMS_H */
|
|
msach@94
|
626
|