Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view VMS.h @ 171:5161414caa3e
VMS.h: defines for aligning
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Tue, 20 Dec 2011 15:04:06 +0100 |
| parents | d1dd9e6ee72c |
| children | bfaebdf60df3 |
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 "Queue_impl/PrivateQueue.h"
15 #include "Histogram/Histogram.h"
16 #include "DynArray/DynArray.h"
17 #include "Hash_impl/PrivateHash.h"
18 #include "vmalloc.h"
20 #include <pthread.h>
21 #include <sys/time.h>
23 //============= #defines ===========
24 //
25 #include "VMS_defs.h"
29 //===========================================================================
30 typedef unsigned long long TSCount;
31 typedef union
32 { uint32 lowHigh[2];
33 uint64 longVal;
34 }
35 TSCountLowHigh;
37 typedef struct _SchedSlot SchedSlot;
38 typedef struct _VMSReqst VMSReqst;
39 typedef struct _VirtProcr VirtProcr;
40 typedef struct _IntervalProbe IntervalProbe;
41 typedef struct _GateStruc GateStruc;
44 typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx
45 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv
46 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr
47 typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr
48 typedef void (*ResumePrFnPtr) ( VirtProcr *, void * );
51 //============= Requests ===========
52 //
54 enum VMSReqstType //avoid starting enums at 0, for debug reasons
55 {
56 semantic = 1,
57 createReq,
58 dissipate,
59 VMSSemantic //goes with VMSSemReqst below
60 };
62 struct _VMSReqst
63 {
64 enum VMSReqstType reqType;//used for dissipate and in future for IO requests
65 void *semReqData;
67 VMSReqst *nextReqst;
68 };
69 //VMSReqst
71 enum VMSSemReqstType //These are equivalent to semantic requests, but for
72 { // VMS's services available directly to app, like OS
73 createProbe = 1, // and probe services -- like a VMS-wide built-in lang
74 openFile,
75 otherIO
76 };
78 typedef struct
79 { enum VMSSemReqstType reqType;
80 VirtProcr *requestingPr;
81 char *nameStr; //for create probe
82 }
83 VMSSemReq;
86 //==================== Core data structures ===================
88 struct _SchedSlot
89 {
90 int workIsDone;
91 int needsProcrAssigned;
92 VirtProcr *procrAssignedToSlot;
93 };
94 //SchedSlot
96 /*WARNING: re-arranging this data structure could cause VP switching
97 * assembly code to fail -- hard-codes offsets of fields
98 */
99 struct _VirtProcr
100 { int procrID; //for debugging -- count up each time create
101 int coreAnimatedBy;
102 void *startOfStack;
103 void *stackPtr;
104 void *framePtr;
105 void *nextInstrPt;
107 void *coreLoopStartPt; //allows proto-runtime to be linked later
108 void *coreLoopFramePtr; //restore before jmp back to core loop
109 void *coreLoopStackPtr; //restore before jmp back to core loop
111 void *initialData;
113 SchedSlot *schedSlot;
114 VMSReqst *requests;
116 void *semanticData; //this livesUSE_GNU here for the life of VP
117 void *dataRetFromReq;//values returned from plugin to VP go here
119 //=========== MEASUREMENT STUFF ==========
120 #ifdef MEAS__TIME_STAMP_SUSP
121 uint32 preSuspTSCLow;
122 uint32 postSuspTSCLow;
123 #endif
124 #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/
125 uint32 startMasterTSCLow;USE_GNU
126 uint32 endMasterTSCLow;
127 #endif
128 #ifdef MEAS__TIME_2011_SYS
129 TSCountLowHigh startSusp;
130 uint64 totalSuspCycles;
131 uint32 numGoodSusp;
132 #endif
133 //========================================
135 float64 createPtInSecs; //have space but don't use on some configs
136 };
137 //VirtProcr
140 /*WARNING: re-arranging this data structure could cause VP-switching
141 * assembly code to fail -- hard-codes offsets of fields
142 * (because -O3 messes with things otherwise)
143 */
144 typedef struct
145 {
146 SlaveScheduler slaveScheduler;
147 RequestHandler requestHandler;
149 SchedSlot ***allSchedSlots;
150 VMSQueueStruc **readyToAnimateQs;
151 VirtProcr **masterVPs;
153 void *semanticEnv;
154 void *OSEventStruc; //for future, when add I/O to BLIS
155 MallocArrays *freeLists;
156 int32 amtOfOutstandingMem; //total currently allocated
158 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
160 int32 setupComplete;
161 volatile int32 masterLock;
163 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP
164 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal
165 int32 workStealingLock;
167 int32 numProcrsCreated; //gives ordering to processor creation
169 //=========== MEASUREMENT STUFF =============
170 IntervalProbe **intervalProbes;
171 PrivDynArrayInfo *dynIntervalProbesInfo;
172 HashTable *probeNameHashTbl;
173 int32 masterCreateProbeID;
174 float64 createPtInSecs;
175 Histogram **measHists;
176 PrivDynArrayInfo *measHistsInfo;
177 #ifdef MEAS__TIME_PLUGIN
178 Histogram *reqHdlrLowTimeHist;
179 Histogram *reqHdlrHighTimeHist;
180 #endif
181 #ifdef MEAS__TIME_MALLOC
182 Histogram *mallocTimeHist;
183 Histogram *freeTimeHist;
184 #endif
185 #ifdef MEAS__TIME_MASTER_LOCK
186 Histogram *masterLockLowTimeHist;
187 Histogram *masterLockHighTimeHist;
188 #endif
189 #ifdef MEAS__TIME_2011_SYS
190 TSCountLowHigh startMaster;
191 uint64 totalMasterCycles;
192 uint32 numMasterAnimations;
193 TSCountLowHigh startReqHdlr;
194 uint64 totalPluginCycles;
195 uint32 numPluginAnimations;
196 uint64 cyclesTillStartMasterLoop;
197 TSCountLowHigh endMasterLoop;
198 #endif
199 //==========================================
200 }
201 MasterEnv;
203 //========================= Extra Stuff Data Strucs =======================
204 typedef struct
205 {
207 }
208 VMSExcp;
210 struct _GateStruc
211 {
212 int32 gateClosed;
213 int32 preGateProgress;
214 int32 waitProgress;
215 int32 exitProgress;
216 };
217 //GateStruc
219 //======================= OS Thread related ===============================
221 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
222 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype
223 void masterLoop( void *initData, VirtProcr *masterVP );
226 typedef struct
227 {
228 void *endThdPt;
229 unsigned int coreNum;
230 }
231 ThdParams;
233 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state
234 ThdParams *coreLoopThdParams [ NUM_CORES ];
235 pthread_mutex_t suspendLock;
236 pthread_cond_t suspend_cond;
240 //===================== Global Vars ===================
242 volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__;
247 //=========================== Function Prototypes =========================
250 //========== Setup and shutdown ==========
251 void
252 VMS__init();
254 void
255 VMS__init_Seq();
257 void
258 VMS__start_the_work_then_wait_until_done();
260 void
261 VMS__start_the_work_then_wait_until_done_Seq();
263 inline VirtProcr *
264 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
266 void
267 VMS__dissipate_procr( VirtProcr *procrToDissipate );
269 //Use this to create processor inside entry point & other places outside
270 // the VMS system boundary (IE, not run in slave nor Master)
271 VirtProcr *
272 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
274 void
275 VMS_ext__dissipate_procr( VirtProcr *procrToDissipate );
277 void
278 VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData );
280 void
281 VMS__shutdown();
283 void
284 VMS__cleanup_at_end_of_shutdown();
286 void *
287 VMS__give_sem_env_for( VirtProcr *animPr );
290 //============== Request Related ===============
292 void
293 VMS__suspend_procr( VirtProcr *callingPr );
295 inline void
296 VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr );
298 inline void
299 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
301 void
302 VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr );
304 void inline
305 VMS__send_dissipate_req( VirtProcr *prToDissipate );
307 inline void
308 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr );
310 VMSReqst *
311 VMS__take_next_request_out_of( VirtProcr *procrWithReq );
313 inline void *
314 VMS__take_sem_reqst_from( VMSReqst *req );
316 void inline
317 VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv,
318 ResumePrFnPtr resumePrFnPtr );
320 //======================== MEASUREMENT ======================
321 uint64
322 VMS__give_num_plugin_cycles();
323 uint32
324 VMS__give_num_plugin_animations();
328 #include "ProcrContext.h"
329 #include "probes.h"
330 #include "vutilities.h"
331 #include "../VMS_lang_specific_defines.h"
332 #endif /* _VMS_H */
