comparison VMS.h @ 57:85b731b290f8

Merge between VCilk and SSR intermediate Nov 4
author Me
date Thu, 04 Nov 2010 18:27:27 -0700
parents 420a09d3f32a f8508572f3de
children 26d53313a8f2
comparison
equal deleted inserted replaced
24:a79cbab31599 25:7e269ea5c1ac
20 #include <pthread.h> 20 #include <pthread.h>
21 #include <sys/time.h> 21 #include <sys/time.h>
22 22
23 23
24 //=============================== Debug =================================== 24 //=============================== Debug ===================================
25 //These defines turn types of bug messages on and off
26 #define dbgProbes FALSE
27 #define dbgAppFlow FALSE
28
25 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread 29 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread
26 // It still does co-routines and all the mechanisms are the same, it just 30 // It still does co-routines and all the mechanisms are the same, it just
27 // has only a single thread and animates VPs one at a time 31 // has only a single thread and animates VPs one at a time
28 //#define SEQUENTIAL 32 //#define SEQUENTIAL
29 33
30 //turns on the probe-instrumentation in the application -- when not 34 //turns on the probe-instrumentation in the application -- when not
31 // defined, the calls to the probe functions turn into comments 35 // defined, the calls to the probe functions turn into comments
32 #define STATS__ENABLE_PROBES 36 #define STATS__ENABLE_PROBES
33 37
34 38
35 #define PRINT_DEBUG(msg)// printf(msg); fflush(stdin); 39 #define DEBUG(msg)// printf(msg); fflush(stdin);
40 #define DEBUG_MSG( bool, msg) //if( bool){ printf(msg); fflush(stdin);}
36 #define PRINT1_DEBUG(msg, param) //printf(msg, param); fflush(stdin); 41 #define PRINT1_DEBUG(msg, param) //printf(msg, param); fflush(stdin);
37 #define PRINT2_DEBUG(msg, p1, p2) //printf(msg, p1, p2); fflush(stdin); 42 #define PRINT2_DEBUG(msg, p1, p2) //printf(msg, p1, p2); fflush(stdin);
38 43
39 #define PRINT_ERROR(msg) printf(msg); fflush(stdin); 44 #define PRINT_ERROR(msg) printf(msg); fflush(stdin);
40 #define PRINT1_ERROR(msg, param) printf(msg, param); fflush(stdin); 45 #define PRINT1_ERROR(msg, param) printf(msg, param); fflush(stdin);
41 #define PRINT2_ERROR(msg, p1, p2) printf(msg, p1, p2); fflush(stdin); 46 #define PRINT2_ERROR(msg, p1, p2) printf(msg, p1, p2); fflush(stdin);
42
43 47
44 //=========================== STATS ======================= 48 //=========================== STATS =======================
45 49
46 //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and 50 //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and
47 // compiled-in that saves the low part of the time stamp count just before 51 // compiled-in that saves the low part of the time stamp count just before
63 // balance amortizing master fixed overhead vs imbalance potential 67 // balance amortizing master fixed overhead vs imbalance potential
64 #define NUM_SCHED_SLOTS 3 68 #define NUM_SCHED_SLOTS 3
65 69
66 #define MIN_WORK_UNIT_CYCLES 20000 70 #define MIN_WORK_UNIT_CYCLES 20000
67 71
68 #define READYTOANIMATE_RETRIES 10000 72 #define MASTERLOCK_RETRIES 10000
69 73
70 // stack 74 // stack size in virtual processors created
71 #define VIRT_PROCR_STACK_SIZE 0x4000 75 #define VIRT_PROCR_STACK_SIZE 0x4000 /* 16K */
72 76
73 // memory for VMS__malloc -- 256M 77 // memory for VMS__malloc
74 #define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 78 #define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */
75 79
76 80
77 //============================== 81 //==============================
78 82
79 #define SUCCESS 0 83 #define SUCCESS 0
161 165
162 SchedSlot *schedSlot; 166 SchedSlot *schedSlot;
163 VMSReqst *requests; 167 VMSReqst *requests;
164 168
165 void *semanticData; //this lives here for the life of VP 169 void *semanticData; //this lives here for the life of VP
166 void *dataReturnedFromReq;//values returned from plugin to VP go here 170 void *dataRetFromReq;//values returned from plugin to VP go here
167 171
168 //=========== MEASUREMENT STUFF ========== 172 //=========== MEASUREMENT STUFF ==========
169 #ifdef MEAS__TIME_STAMP_SUSP 173 #ifdef MEAS__TIME_STAMP_SUSP
170 unsigned int preSuspTSCLow; 174 unsigned int preSuspTSCLow;
171 unsigned int postSuspTSCLow; 175 unsigned int postSuspTSCLow;
203 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP 207 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP
204 int32 numProcrsCreated; //gives ordering to processor creation 208 int32 numProcrsCreated; //gives ordering to processor creation
205 209
206 //=========== MEASUREMENT STUFF ============= 210 //=========== MEASUREMENT STUFF =============
207 IntervalProbe **intervalProbes; 211 IntervalProbe **intervalProbes;
208 DynArrayInfo *dynIntervalProbesInfo; 212 PrivDynArrayInfo *dynIntervalProbesInfo;
209 HashTable *probeNameHashTbl; 213 HashTable *probeNameHashTbl;
210 int32 masterCreateProbeID; 214 int32 masterCreateProbeID;
211 float64 createPtInSecs; 215 float64 createPtInSecs;
212 } 216 }
213 MasterEnv; 217 MasterEnv;
214 218
215 219 //=============================
220 typedef struct
221 {
222
223 }
224 VMSExcp;
216 225
217 226
218 //======================= OS Thread related =============================== 227 //======================= OS Thread related ===============================
219 228
220 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype 229 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
243 252
244 253
245 254
246 //=========================== Function Prototypes ========================= 255 //=========================== Function Prototypes =========================
247 256
248 //============== Setup and shutdown ============= 257
258 //========== Setup and shutdown ==========
249 void 259 void
250 VMS__init(); 260 VMS__init();
251 261
252 void 262 void
253 VMS__init_Seq(); 263 VMS__init_Seq();
258 void 268 void
259 VMS__start_the_work_then_wait_until_done_Seq(); 269 VMS__start_the_work_then_wait_until_done_Seq();
260 270
261 VirtProcr * 271 VirtProcr *
262 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); 272 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
273
274 void
275 VMS__dissipate_procr( VirtProcr *procrToDissipate );
263 276
264 //Use this to create processor inside entry point & other places outside 277 //Use this to create processor inside entry point & other places outside
265 // the VMS system boundary (IE, not run in slave nor Master) 278 // the VMS system boundary (IE, not run in slave nor Master)
266 VirtProcr * 279 VirtProcr *
267 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); 280 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
268 281
269 VirtProcr * 282 void
270 VMS__create_the_shutdown_procr(); 283 VMS_ext__dissipate_procr( VirtProcr *procrToDissipate );
271 284
272 void 285 void
273 VMS__cleanup_after_shutdown(); 286 VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData );
287
288 void
289 VMS__shutdown();
290
291 void
292 VMS__cleanup_at_end_of_shutdown();
274 293
275 294
276 //============== Request Related =============== 295 //============== Request Related ===============
277 296
278 void 297 void
279 VMS__suspend_procr( VirtProcr *callingPr ); 298 VMS__suspend_procr( VirtProcr *callingPr );
280 299
281 inline void 300 inline void
282 VMS__add_sem_request( void *semReqData, VirtProcr *callingPr ); 301 VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr );
302
303 inline void
304 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
283 305
284 void 306 void
285 VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ); 307 VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr );
308
309 void inline
310 VMS__send_dissipate_req( VirtProcr *prToDissipate );
286 311
287 inline void 312 inline void
288 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ); 313 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr );
289 314
290 void
291 VMS__free_request( VMSReqst *req );
292
293 void
294 VMS__remove_and_free_top_request( VirtProcr *reqstingPr );
295
296 VMSReqst * 315 VMSReqst *
297 VMS__take_next_request_out_of( VirtProcr *procrWithReq ); 316 VMS__take_next_request_out_of( VirtProcr *procrWithReq );
298 317
299 inline void * 318 inline void *
300 VMS__take_sem_reqst_from( VMSReqst *req ); 319 VMS__take_sem_reqst_from( VMSReqst *req );
301 // 320
302 //VMSReqst * 321 //======================== STATS ======================
303 //VMS__take_top_request_from( VirtProcr *reqstingPr ); 322
304 // 323 //===== RDTSC wrapper =====
305 //inline int
306 //VMS__isSemanticReqst( VMSReqst *req );
307 //
308 //inline int
309 //VMS__isDissipateReqst( VMSReqst *req );
310 //
311 //inline int
312 //VMS__isCreateReqst( VMSReqst *req );
313
314 //==========================
315
316 void inline
317 VMS__send_dissipate_req( VirtProcr *prToDissipate );
318
319 void
320 VMS__dissipate_procr( VirtProcr *procrToDissipate );
321
322
323
324 //===================== RDTSC wrapper ==================
325 324
326 #define saveTimeStampCountInto(low, high) \ 325 #define saveTimeStampCountInto(low, high) \
327 asm volatile("RDTSC; \ 326 asm volatile("RDTSC; \
328 movl %%eax, %0; \ 327 movl %%eax, %0; \
329 movl %%edx, %1;" \ 328 movl %%edx, %1;" \
337 movl %%eax, %0;" \ 336 movl %%eax, %0;" \
338 /* outputs */ : "=m" (low) \ 337 /* outputs */ : "=m" (low) \
339 /* inputs */ : \ 338 /* inputs */ : \
340 /* clobber */ : "%eax", "%edx" \ 339 /* clobber */ : "%eax", "%edx" \
341 ); 340 );
342 341 //=====
343 //======================== STATS ======================
344 342
345 #include "probes.h" 343 #include "probes.h"
346 344
347 #endif /* _VMS_H */ 345 #endif /* _VMS_H */
348 346