Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view VMS.h @ 205:cb888346c3e0
Changed include paths, but version still does not work because of accidental merge
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Fri, 17 Feb 2012 18:28:59 +0100 |
| parents | 6db9e4898978 |
| children |
line source
1 /*
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
3 * Licensed under GNU General Public License version 2
4 *
5 * Author: seanhalle@yahoo.com
6 *
7 */
9 #ifndef _VMS_H
10 #define _VMS_H
11 #define _GNU_SOURCE
13 #include "VMS_primitive_data_types.h"
14 #include "C_Libraries/DynArray/DynArray.h"
15 #include "C_Libraries/Hash_impl/PrivateHash.h"
16 #include "C_Libraries/Histogram/Histogram.h"
17 #include "C_Libraries/Queue_impl/PrivateQueue.h"
18 #include "vmalloc.h"
20 #include <pthread.h>
21 #include <sys/time.h>
23 //================= Defines: included from separate files =================
24 //
25 // Note: ALL defines are in other files, none are in here
26 //
27 #include "VMS_defs.h"
30 //================================ Typedefs =================================
31 //
32 typedef unsigned long long TSCount;
33 typedef union
34 { uint32 lowHigh[2];
35 uint64 longVal;
36 }
37 TSCountLowHigh;
39 typedef struct _SchedSlot SchedSlot;
40 typedef struct _VMSReqst VMSReqst;
41 typedef struct _SlaveVP SlaveVP;
42 typedef struct _IntervalProbe IntervalProbe;
43 typedef struct _GateStruc GateStruc;
46 typedef SlaveVP * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx
47 typedef void (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv
48 typedef void (*VirtProcrFnPtr) ( void *, SlaveVP * ); //initData, animPr
49 typedef void VirtProcrFn ( void *, SlaveVP * ); //initData, animPr
50 typedef void (*ResumeVPFnPtr) ( SlaveVP *, void * );
52 //============================= Statistics ==================================
54 inline TSCount getTSCount();
56 //============= Request Related ===========
57 //
59 enum VMSReqstType //avoid starting enums at 0, for debug reasons
60 {
61 semantic = 1,
62 createReq,
63 dissipate,
64 VMSSemantic //goes with VMSSemReqst below
65 };
67 struct _VMSReqst
68 {
69 enum VMSReqstType reqType;//used for dissipate and in future for IO requests
70 void *semReqData;
72 VMSReqst *nextReqst;
73 };
74 //VMSReqst
76 enum VMSSemReqstType //These are equivalent to semantic requests, but for
77 { // VMS's services available directly to app, like OS
78 createProbe = 1, // and probe services -- like a VMS-wide built-in lang
79 openFile,
80 otherIO
81 };
83 typedef struct
84 { enum VMSSemReqstType reqType;
85 SlaveVP *requestingPr;
86 char *nameStr; //for create probe
87 }
88 VMSSemReq;
91 //==================== Core data structures ===================
93 struct _SchedSlot
94 {
95 int workIsDone;
96 int needsProcrAssigned;
97 SlaveVP *procrAssignedToSlot;
98 };
99 //SchedSlot
101 /*WARNING: re-arranging this data structure could cause VP switching
102 * assembly code to fail -- hard-codes offsets of fields
103 */
104 struct _SlaveVP
105 { int procrID; //for debugging -- count up each time create
106 int coreAnimatedBy;
107 void *startOfStack;
108 void *stackPtr;
109 void *framePtr;
110 void *nextInstrPt;
112 void *coreLoopStartPt; //allows proto-runtime to be linked later
113 void *coreLoopFramePtr; //restore before jmp back to core loop
114 void *coreLoopStackPtr; //restore before jmp back to core loop
116 void *initialData;
118 SchedSlot *schedSlot;
119 VMSReqst *requests;
121 void *semanticData; //this livesUSE_GNU here for the life of VP
122 void *dataRetFromReq;//values returned from plugin to VP go here
124 //=========== MEASUREMENT STUFF ==========
125 #ifdef MEAS__TIME_STAMP_SUSP
126 uint32 preSuspTSCLow;
127 uint32 postSuspTSCLow;
128 #endif
129 #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/
130 uint32 startMasterTSCLow;USE_GNU
131 uint32 endMasterTSCLow;
132 #endif
133 #ifdef MEAS__TIME_2011_SYS
134 TSCountLowHigh startSusp;
135 uint64 totalSuspCycles;
136 uint32 numGoodSusp;
137 #endif
138 //========================================
140 float64 createPtInSecs; //have space but don't use on some configs
141 };
142 //VirtProcr
145 /*WARNING: re-arranging this data structure could cause VP-switching
146 * assembly code to fail -- hard-codes offsets of fields
147 * (because -O3 messes with things otherwise)
148 */
149 typedef struct
150 {
151 union{ //adds padding to put masterLock on its own cache-line to elim
152 // false sharing (masterLock is most-accessed var in VMS)
153 volatile int32 masterLock;
154 char padding[CACHELINE_SIZE];
155 } masterLockUnion;
156 SlaveScheduler slaveScheduler;
157 RequestHandler requestHandler;
159 SchedSlot ***allSchedSlots;
160 VMSQueueStruc **readyToAnimateQs;
161 SlaveVP **masterVPs;
163 void *semanticEnv;
164 void *OSEventStruc; //for future, when add I/O to BLIS
165 MallocArrays *freeLists;
166 int32 amtOfOutstandingMem; //total currently allocated
168 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
170 int32 setupComplete;
171 //int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP
172 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal
173 int32 workStealingLock;
175 int32 numVPsCreated; //gives ordering to processor creation
177 //=========== MEASUREMENT STUFF =============
178 IntervalProbe **intervalProbes;
179 PrivDynArrayInfo *dynIntervalProbesInfo;
180 HashTable *probeNameHashTbl;
181 int32 masterCreateProbeID;
182 float64 createPtInSecs;
183 Histogram **measHists;
184 PrivDynArrayInfo *measHistsInfo;
185 #ifdef MEAS__TIME_PLUGIN
186 Histogram *reqHdlrLowTimeHist;
187 Histogram *reqHdlrHighTimeHist;
188 #endif
189 #ifdef MEAS__TIME_MALLOC
190 Histogram *mallocTimeHist;
191 Histogram *freeTimeHist;
192 #endif
193 #ifdef MEAS__TIME_MASTER_LOCK
194 Histogram *masterLockLowTimeHist;
195 Histogram *masterLockHighTimeHist;
196 #endif
197 #ifdef MEAS__TIME_2011_SYS
198 TSCountLowHigh startMaster;
199 uint64 totalMasterCycles;
200 uint32 numMasterAnimations;
201 TSCountLowHigh startReqHdlr;
202 uint64 totalPluginCycles;
203 uint32 numPluginAnimations;
204 uint64 cyclesTillStartMasterLoop;
205 TSCountLowHigh endMasterLoop;
206 #endif
207 //==========================================
208 }
209 MasterEnv;
211 //========================= Extra Stuff Data Strucs =======================
212 typedef struct
213 {
215 }
216 VMSExcp;
218 struct _GateStruc
219 {
220 int32 gateClosed;
221 int32 preGateProgress;
222 int32 waitProgress;
223 int32 exitProgress;
224 };
225 //GateStruc
227 //======================= OS Thread related ===============================
229 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
230 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype
231 void masterLoop( void *initData, SlaveVP *masterVP );
234 typedef struct
235 {
236 void *endThdPt;
237 unsigned int coreNum;
238 }
239 ThdParams;
241 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state
242 ThdParams *coreLoopThdParams [ NUM_CORES ];
243 pthread_mutex_t suspendLock;
244 pthread_cond_t suspend_cond;
248 //============================= Global Vars ================================
250 volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__;
255 //========================= Function Prototypes ===========================
258 //========== Setup and shutdown ==========
259 void
260 VMS_int__init();
262 void
263 VMS_int__init_Seq();
265 void
266 VMS_WL__start_the_work_then_wait_until_done();
268 void
269 VMS_WL__start_the_work_then_wait_until_done_Seq();
271 inline SlaveVP *
272 VMS_int__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
274 void
275 VMS_int__dissipate_procr( SlaveVP *procrToDissipate );
277 //Use this to create processor inside entry point & other places outside
278 // the VMS system boundary (IE, not run in slave nor Master)
279 SlaveVP *
280 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
282 void
283 VMS_ext__dissipate_procr( SlaveVP *procrToDissipate );
285 void
286 VMS_PI__throw_exception( char *msgStr, SlaveVP *reqstPr, VMSExcp *excpData );
288 void
289 VMS_int__shutdown();
291 void
292 VMS_int__cleanup_at_end_of_shutdown();
294 void *
295 VMS_WL__give_sem_env_for( SlaveVP *animPr );
298 //============== Request Related ===============
300 void
301 VMS_int__suspend_procr( SlaveVP *callingPr );
303 inline void
304 VMS_WL__add_sem_request_in_mallocd_VMSReqst( void *semReqData, SlaveVP *callingPr );
306 inline void
307 VMS_WL__send_sem_request( void *semReqData, SlaveVP *callingPr );
309 void
310 VMS_WL__send_create_procr_req( void *semReqData, SlaveVP *reqstingPr );
312 void inline
313 VMS_WL__send_dissipate_req( SlaveVP *prToDissipate );
315 inline void
316 VMS_WL__send_VMSSem_request( void *semReqData, SlaveVP *callingPr );
318 VMSReqst *
319 VMS_PI__take_next_request_out_of( SlaveVP *procrWithReq );
321 inline void *
322 VMS_PI__take_sem_reqst_from( VMSReqst *req );
324 void inline
325 VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingPr, void *semEnv,
326 ResumeVPFnPtr resumePrFnPtr );
328 //======================== MEASUREMENT ======================
329 uint64
330 VMS_WL__give_num_plugin_cycles();
331 uint32
332 VMS_WL__give_num_plugin_animations();
336 #include "ProcrContext.h"
337 #include "probes.h"
338 #include "vutilities.h"
340 #endif /* _VMS_H */
