comparison VMS.h @ 70:f9b60012fd74

working ucontext version
author Merten Sach <msach@mailbox.tu-berlin.de>
date Fri, 27 May 2011 12:35:40 +0200
parents 11bfe9d136ed
children efb55f1b5fb9
comparison
equal deleted inserted replaced
37:ffb803f3f0ad 38:dea7a4babd2b
15 #include "Histogram/Histogram.h" 15 #include "Histogram/Histogram.h"
16 #include "DynArray/DynArray.h" 16 #include "DynArray/DynArray.h"
17 #include "Hash_impl/PrivateHash.h" 17 #include "Hash_impl/PrivateHash.h"
18 #include "vmalloc.h" 18 #include "vmalloc.h"
19 19
20 //#include <stdio.h>
21 #include <pthread.h> 20 #include <pthread.h>
22 #include <sys/time.h> 21 #include <sys/time.h>
22 #include <ucontext.h>
23 23
24 24
25 //=============================== Debug =================================== 25 //=============================== Debug ===================================
26 // 26 //
27 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread 27 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread
49 #define DEBUG1( bool, msg, param) \ 49 #define DEBUG1( bool, msg, param) \
50 // if(bool){printf(msg, param); fflush(stdin);} 50 // if(bool){printf(msg, param); fflush(stdin);}
51 #define DEBUG2( bool, msg, p1, p2) \ 51 #define DEBUG2( bool, msg, p1, p2) \
52 // if(bool) {printf(msg, p1, p2); fflush(stdin);} 52 // if(bool) {printf(msg, p1, p2); fflush(stdin);}
53 53
54 #define ERROR(msg) printf(msg); //fflush(stdin); 54 #define ERROR(msg) printf(msg);
55 #define ERROR1(msg, param) printf(msg, param); fflush(stdin); 55 #define ERROR1(msg, param) printf(msg, param);
56 #define ERROR2(msg, p1, p2) printf(msg, p1, p2); fflush(stdin); 56 #define ERROR2(msg, p1, p2) printf(msg, p1, p2);
57 57
58 //=========================== STATS ======================= 58 //=========================== STATS =======================
59 59
60 //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and 60 //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and
61 // compiled-in that saves the low part of the time stamp count just before 61 // compiled-in that saves the low part of the time stamp count just before
173 */ 173 */
174 struct _VirtProcr 174 struct _VirtProcr
175 { int procrID; //for debugging -- count up each time create 175 { int procrID; //for debugging -- count up each time create
176 int coreAnimatedBy; 176 int coreAnimatedBy;
177 void *startOfStack; 177 void *startOfStack;
178 void *stackPtr; 178 //void *stackPtr;
179 void *framePtr; 179 //void *framePtr;
180 void *nextInstrPt; 180 //void *nextInstrPt;
181 ucontext_t *savedVPStatus;
181 182
182 void *coreLoopStartPt; //allows proto-runtime to be linked later 183 //void *coreLoopStartPt; //allows proto-runtime to be linked later
183 void *coreLoopFramePtr; //restore before jmp back to core loop 184 //void *coreLoopFramePtr; //restore before jmp back to core loop
184 void *coreLoopStackPtr; //restore before jmp back to core loop 185 //void *coreLoopStackPtr; //restore before jmp back to core loop
186 ucontext_t *savedCoreLoopStatus;
185 187
186 void *initialData; 188 void *initialData;
187 189
188 SchedSlot *schedSlot; 190 SchedSlot *schedSlot;
189 VMSReqst *requests; 191 VMSReqst *requests;
223 void *semanticEnv; 225 void *semanticEnv;
224 void *OSEventStruc; //for future, when add I/O to BLIS 226 void *OSEventStruc; //for future, when add I/O to BLIS
225 MallocProlog *freeListHead; 227 MallocProlog *freeListHead;
226 int32 amtOfOutstandingMem; //total currently allocated 228 int32 amtOfOutstandingMem; //total currently allocated
227 229
228 void *coreLoopStartPt;//addr to jump to to re-enter coreLoop 230 //void *coreLoopStartPt;//addr to jump to to re-enter coreLoop
229 void *coreLoopEndPt; //addr to jump to to shut down a coreLoop 231 //void *coreLoopEndPt; //addr to jump to to shut down a coreLoop
230 232
231 int32 setupComplete; 233 int32 setupComplete;
232 int32 masterLock; 234 volatile int32 masterLock;
233 235
234 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP 236 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP
235 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal 237 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal
236 int32 workStealingLock; 238 int32 workStealingLock;
237 239
276 }; 278 };
277 //GateStruc 279 //GateStruc
278 280
279 //======================= OS Thread related =============================== 281 //======================= OS Thread related ===============================
280 282
281 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype 283 void coreLoop( void *paramsIn ); //standard PThreads fn prototype
282 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype 284 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype
285 void terminateCoreLoop(VirtProcr *currPr);
283 void masterLoop( void *initData, VirtProcr *masterPr ); 286 void masterLoop( void *initData, VirtProcr *masterPr );
284
285 287
286 typedef struct 288 typedef struct
287 { 289 {
288 void *endThdPt; 290 void *endThdPt;
289 unsigned int coreNum; 291 unsigned int coreNum;
292 294
293 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state 295 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state
294 ThdParams *coreLoopThdParams [ NUM_CORES ]; 296 ThdParams *coreLoopThdParams [ NUM_CORES ];
295 pthread_mutex_t suspendLock; 297 pthread_mutex_t suspendLock;
296 pthread_cond_t suspend_cond; 298 pthread_cond_t suspend_cond;
297
298 299
299 300
300 //===================== Global Vars =================== 301 //===================== Global Vars ===================
301 302
302 volatile MasterEnv *_VMSMasterEnv; 303 volatile MasterEnv *_VMSMasterEnv;
546 addIntervalToHist( startStamp, endStamp, \ 547 addIntervalToHist( startStamp, endStamp, \
547 _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); 548 _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] );
548 549
549 //===== 550 //=====
550 551
552 //======= Utilities ======
553 /*
554 * This Macro makes the gcc reload all variables from Stack after this function.
555 * This is necessary because we jmp into the masterLoop and the variables are
556 * kept in Registers for optimization.
557 */
558 #define flushRegisters() \
559 asm volatile ("" /*no instr needed*/ \
560 ::: /*no output and input*/ \
561 "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi")
562 //========
563
551 #include "SwitchAnimators.h" 564 #include "SwitchAnimators.h"
552 #include "probes.h" 565 #include "probes.h"
553 #include "vutilities.h" 566 #include "vutilities.h"
554 567
555 #endif /* _VMS_H */ 568 #endif /* _VMS_H */