Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view VMS.h @ 200:6db9e4898978
VMS name chgs -- added "WL" "PI" and "int" and split vms.h up
| author | Me@portablequad |
|---|---|
| date | Sun, 12 Feb 2012 01:49:33 -0800 |
| parents | 1738f190b7bb |
| children | cb888346c3e0 |
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"
31 //================================ Typedefs =================================
32 //
33 typedef unsigned long long TSCount;
34 typedef union
35 { uint32 lowHigh[2];
36 uint64 longVal;
37 }
38 TSCountLowHigh;
40 typedef struct _SchedSlot SchedSlot;
41 typedef struct _VMSReqst VMSReqst;
42 typedef struct _SlaveVP SlaveVP;
43 typedef struct _IntervalProbe IntervalProbe;
44 typedef struct _GateStruc GateStruc;
47 typedef SlaveVP * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx
48 typedef void (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv
49 typedef void (*VirtProcrFnPtr) ( void *, SlaveVP * ); //initData, animPr
50 typedef void VirtProcrFn ( void *, SlaveVP * ); //initData, animPr
51 typedef void (*ResumeVPFnPtr) ( SlaveVP *, void * );
54 //============= Request Related ===========
55 //
57 enum VMSReqstType //avoid starting enums at 0, for debug reasons
58 {
59 semantic = 1,
60 createReq,
61 dissipate,
62 VMSSemantic //goes with VMSSemReqst below
63 };
65 struct _VMSReqst
66 {
67 enum VMSReqstType reqType;//used for dissipate and in future for IO requests
68 void *semReqData;
70 VMSReqst *nextReqst;
71 };
72 //VMSReqst
74 enum VMSSemReqstType //These are equivalent to semantic requests, but for
75 { // VMS's services available directly to app, like OS
76 createProbe = 1, // and probe services -- like a VMS-wide built-in lang
77 openFile,
78 otherIO
79 };
81 typedef struct
82 { enum VMSSemReqstType reqType;
83 SlaveVP *requestingPr;
84 char *nameStr; //for create probe
85 }
86 VMSSemReq;
89 //==================== Core data structures ===================
91 struct _SchedSlot
92 {
93 int workIsDone;
94 int needsProcrAssigned;
95 SlaveVP *procrAssignedToSlot;
96 };
97 //SchedSlot
99 /*WARNING: re-arranging this data structure could cause VP switching
100 * assembly code to fail -- hard-codes offsets of fields
101 */
102 struct _SlaveVP
103 { int procrID; //for debugging -- count up each time create
104 int coreAnimatedBy;
105 void *startOfStack;
106 void *stackPtr;
107 void *framePtr;
108 void *nextInstrPt;
110 void *coreLoopStartPt; //allows proto-runtime to be linked later
111 void *coreLoopFramePtr; //restore before jmp back to core loop
112 void *coreLoopStackPtr; //restore before jmp back to core loop
114 void *initialData;
116 SchedSlot *schedSlot;
117 VMSReqst *requests;
119 void *semanticData; //this livesUSE_GNU here for the life of VP
120 void *dataRetFromReq;//values returned from plugin to VP go here
122 //=========== MEASUREMENT STUFF ==========
123 #ifdef MEAS__TIME_STAMP_SUSP
124 uint32 preSuspTSCLow;
125 uint32 postSuspTSCLow;
126 #endif
127 #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/
128 uint32 startMasterTSCLow;USE_GNU
129 uint32 endMasterTSCLow;
130 #endif
131 #ifdef MEAS__TIME_2011_SYS
132 TSCountLowHigh startSusp;
133 uint64 totalSuspCycles;
134 uint32 numGoodSusp;
135 #endif
136 //========================================
138 float64 createPtInSecs; //have space but don't use on some configs
139 };
140 //VirtProcr
143 /*WARNING: re-arranging this data structure could cause VP-switching
144 * assembly code to fail -- hard-codes offsets of fields
145 * (because -O3 messes with things otherwise)
146 */
147 typedef struct
148 {
149 union{ //adds padding to put masterLock on its own cache-line to elim
150 // false sharing (masterLock is most-accessed var in VMS)
151 volatile int32 masterLock;
152 char padding[CACHELINE_SIZE];
153 } masterLockUnion;
154 SlaveScheduler slaveScheduler;
155 RequestHandler requestHandler;
157 SchedSlot ***allSchedSlots;
158 VMSQueueStruc **readyToAnimateQs;
159 SlaveVP **masterVPs;
161 void *semanticEnv;
162 void *OSEventStruc; //for future, when add I/O to BLIS
163 MallocArrays *freeLists;
164 int32 amtOfOutstandingMem; //total currently allocated
166 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
168 int32 setupComplete;
169 //int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP
170 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal
171 int32 workStealingLock;
173 int32 numVPsCreated; //gives ordering to processor creation
175 //=========== MEASUREMENT STUFF =============
176 IntervalProbe **intervalProbes;
177 PrivDynArrayInfo *dynIntervalProbesInfo;
178 HashTable *probeNameHashTbl;
179 int32 masterCreateProbeID;
180 float64 createPtInSecs;
181 Histogram **measHists;
182 PrivDynArrayInfo *measHistsInfo;
183 #ifdef MEAS__TIME_PLUGIN
184 Histogram *reqHdlrLowTimeHist;
185 Histogram *reqHdlrHighTimeHist;
186 #endif
187 #ifdef MEAS__TIME_MALLOC
188 Histogram *mallocTimeHist;
189 Histogram *freeTimeHist;
190 #endif
191 #ifdef MEAS__TIME_MASTER_LOCK
192 Histogram *masterLockLowTimeHist;
193 Histogram *masterLockHighTimeHist;
194 #endif
195 #ifdef MEAS__TIME_2011_SYS
196 TSCountLowHigh startMaster;
197 uint64 totalMasterCycles;
198 uint32 numMasterAnimations;
199 TSCountLowHigh startReqHdlr;
200 uint64 totalPluginCycles;
201 uint32 numPluginAnimations;
202 uint64 cyclesTillStartMasterLoop;
203 TSCountLowHigh endMasterLoop;
204 #endif
205 //==========================================
206 }
207 MasterEnv;
209 //========================= Extra Stuff Data Strucs =======================
210 typedef struct
211 {
213 }
214 VMSExcp;
216 struct _GateStruc
217 {
218 int32 gateClosed;
219 int32 preGateProgress;
220 int32 waitProgress;
221 int32 exitProgress;
222 };
223 //GateStruc
225 //======================= OS Thread related ===============================
227 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
228 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype
229 void masterLoop( void *initData, SlaveVP *masterVP );
232 typedef struct
233 {
234 void *endThdPt;
235 unsigned int coreNum;
236 }
237 ThdParams;
239 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state
240 ThdParams *coreLoopThdParams [ NUM_CORES ];
241 pthread_mutex_t suspendLock;
242 pthread_cond_t suspend_cond;
246 //============================= Global Vars ================================
248 volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__;
253 //========================= Function Prototypes ===========================
256 //========== Setup and shutdown ==========
257 void
258 VMS_int__init();
260 void
261 VMS_int__init_Seq();
263 void
264 VMS_WL__start_the_work_then_wait_until_done();
266 void
267 VMS_WL__start_the_work_then_wait_until_done_Seq();
269 inline SlaveVP *
270 VMS_int__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
272 void
273 VMS_int__dissipate_procr( SlaveVP *procrToDissipate );
275 //Use this to create processor inside entry point & other places outside
276 // the VMS system boundary (IE, not run in slave nor Master)
277 SlaveVP *
278 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
280 void
281 VMS_ext__dissipate_procr( SlaveVP *procrToDissipate );
283 void
284 VMS_PI__throw_exception( char *msgStr, SlaveVP *reqstPr, VMSExcp *excpData );
286 void
287 VMS_int__shutdown();
289 void
290 VMS_int__cleanup_at_end_of_shutdown();
292 void *
293 VMS_WL__give_sem_env_for( SlaveVP *animPr );
296 //============== Request Related ===============
298 void
299 VMS_int__suspend_procr( SlaveVP *callingPr );
301 inline void
302 VMS_WL__add_sem_request_in_mallocd_VMSReqst( void *semReqData, SlaveVP *callingPr );
304 inline void
305 VMS_WL__send_sem_request( void *semReqData, SlaveVP *callingPr );
307 void
308 VMS_WL__send_create_procr_req( void *semReqData, SlaveVP *reqstingPr );
310 void inline
311 VMS_WL__send_dissipate_req( SlaveVP *prToDissipate );
313 inline void
314 VMS_WL__send_VMSSem_request( void *semReqData, SlaveVP *callingPr );
316 VMSReqst *
317 VMS_PI__take_next_request_out_of( SlaveVP *procrWithReq );
319 inline void *
320 VMS_PI__take_sem_reqst_from( VMSReqst *req );
322 void inline
323 VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingPr, void *semEnv,
324 ResumeVPFnPtr resumePrFnPtr );
326 //======================== MEASUREMENT ======================
327 uint64
328 VMS_WL__give_num_plugin_cycles();
329 uint32
330 VMS_WL__give_num_plugin_animations();
334 #include "ProcrContext.h"
335 #include "probes.h"
336 #include "vutilities.h"
338 #endif /* _VMS_H */
