Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view VMS.h @ 230:f2a7831352dc
changed SchedulingMaster.c to AnimationMaster.c and cleaned up all comments
| author | Some Random Person <seanhalle@yahoo.com> |
|---|---|
| date | Thu, 15 Mar 2012 20:31:41 -0700 |
| parents | 5c475c4b7b49 |
| children | 88fd85921d7f |
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 "DynArray/DynArray.h"
15 #include "Hash_impl/PrivateHash.h"
16 #include "Histogram/Histogram.h"
17 #include "Queue_impl/PrivateQueue.h"
18 #include "Services_Offered_by_VMS/Memory_Handling/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 "Defines/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 _MasterVP MasterVP;
43 typedef struct _IntervalProbe IntervalProbe;
44 typedef struct _GateStruc GateStruc;
47 typedef SlaveVP *(*SlaveAssigner) ( void *, SchedSlot*); //semEnv, slot for HW info
48 typedef void (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv
49 typedef void (*TopLevelFnPtr) ( void *, SlaveVP * ); //initData, animSlv
50 typedef void TopLevelFn ( void *, SlaveVP * ); //initData, animSlv
51 typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * );
53 //============================ HW Dependent Fns ================================
55 #include "Hardware_Dependent/VMS__HW_measurement.h"
56 #include "Hardware_Dependent/VMS__primitives.h"
58 //============================= Statistics ==================================
60 inline TSCount getTSCount();
62 //============= Request Related ===========
63 //
65 enum VMSReqstType //avoid starting enums at 0, for debug reasons
66 {
67 semantic = 1,
68 createReq,
69 dissipate,
70 VMSSemantic //goes with VMSSemReqst below
71 };
73 struct _VMSReqst
74 {
75 enum VMSReqstType reqType;//used for dissipate and in future for IO requests
76 void *semReqData;
78 VMSReqst *nextReqst;
79 };
80 //VMSReqst
82 enum VMSSemReqstType //These are equivalent to semantic requests, but for
83 { // VMS's services available directly to app, like OS
84 createProbe = 1, // and probe services -- like a VMS-wide built-in lang
85 openFile,
86 otherIO
87 };
89 typedef struct
90 { enum VMSSemReqstType reqType;
91 SlaveVP *requestingSlv;
92 char *nameStr; //for create probe
93 }
94 VMSSemReq;
97 //==================== Core data structures ===================
99 struct _SchedSlot
100 {
101 int workIsDone;
102 int needsSlaveAssigned;
103 SlaveVP *slaveAssignedToSlot;
105 int slotIdx; //needed by Holistic Model's data gathering
106 int coreOfSlot;
107 SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core
108 };
109 //SchedSlot
111 /*WARNING: re-arranging this data structure could cause Slv switching
112 * assembly code to fail -- hard-codes offsets of fields
113 */
114 struct _SlaveVP
115 { int slaveID; //each slave given a unique ID
116 int coreAnimatedBy;
117 void *startOfStack;
118 void *stackPtr;
119 void *framePtr;
120 void *resumeInstrPtr;
122 void *coreCtlrStartPt; //allows proto-runtime to be linked later
123 void *coreCtlrFramePtr; //restore before jmp back to core controller
124 void *coreCtlrStackPtr; //restore before jmp back to core controller
126 SchedSlot *schedSlot;
127 VMSReqst *requests;
129 void *semanticData; //this is live for the life of Slv
130 void *dataRetFromReq;//Used to return vals from plugin to Wrapper Lib
132 //=========== MEASUREMENT STUFF ==========
133 MEAS__Insert_Meas_Fields_into_Slave;
134 //========================================
136 float64 createPtInSecs; //have space but don't use on some configs
137 };
138 //SlaveVP
140 /*The one and only global variable, holds many odds and ends
141 */
142 typedef struct
143 { //The offsets of these fields are hard-coded into assembly
144 void *coreCtlrReturnPt; //offset of field used in asm
145 int32 masterLock __align_to_cacheline__; //used in asm
147 //============ below this, no asm uses the field offsets =============
149 //Basic VMS infrastructure
150 SlaveVP **masterVPs;
151 SchedSlot ***allSchedSlots;
153 //plugin related
154 SlaveAssigner slaveAssigner;
155 RequestHandler requestHandler;
156 void *semanticEnv;
158 //Slave creation
159 int32 numSlavesCreated; //gives ordering to processor creation
160 int32 numSlavesAlive; //used to detect fail-safe shutdown
162 //Initialization related
163 int32 setupComplete; //use while starting up coreCtlr
165 //Memory management related
166 MallocArrays *freeLists;
167 int32 amtOfOutstandingMem;//total currently allocated
169 //Work-stealing related
170 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal
171 int32 workStealingLock;
174 //=========== MEASUREMENT STUFF =============
175 IntervalProbe **intervalProbes;
176 PrivDynArrayInfo *dynIntervalProbesInfo;
177 HashTable *probeNameHashTbl;
178 int32 masterCreateProbeID;
179 float64 createPtInSecs; //real-clock time VMS initialized
180 Histogram **measHists;
181 PrivDynArrayInfo *measHistsInfo;
182 MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
183 MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
184 MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
185 MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
186 MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
187 MEAS__Insert_System_Meas_Fields_into_MasterEnv;
188 //==========================================
189 }
190 MasterEnv;
192 //========================= Extra Stuff Data Strucs =======================
193 typedef struct
194 {
196 }
197 VMSExcp;
199 struct _GateStruc
200 {
201 int32 gateClosed;
202 int32 preGateProgress;
203 int32 waitProgress;
204 int32 exitProgress;
205 };
206 //GateStruc
208 //======================= OS Thread related ===============================
210 void * coreController( void *paramsIn ); //standard PThreads fn prototype
211 void * coreCtlr_Seq( void *paramsIn ); //standard PThreads fn prototype
212 void animationMaster( void *initData, SlaveVP *masterVP );
215 typedef struct
216 {
217 void *endThdPt;
218 unsigned int coreNum;
219 }
220 ThdParams;
222 //============================= Global Vars ================================
224 volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__;
226 pthread_t coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state
227 ThdParams *coreCtlrThdParams [ NUM_CORES ];
229 pthread_mutex_t suspendLock;
230 pthread_cond_t suspendCond;
232 //========================= Function Prototypes ===========================
234 /* MEANING OF WL PI SS int
235 * These indicate which places the function is safe to use. They stand for:
236 * WL: Wrapper Library
237 * PI: Plugin
238 * SS: Startup and Shutdown
239 * int: internal to the VMS implementation
240 */
242 //========== Setup and shutdown ==========
243 void
244 VMS_SS__init();
246 void
247 VMS_SS__start_the_work_then_wait_until_done();
249 void
250 VMS_SS__shutdown();
252 void
253 VMS_SS__cleanup_at_end_of_shutdown();
256 //============== ===============
258 inline SlaveVP *
259 VMS_int__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam );
260 #define VMS_PI__create_slaveVP VMS_int__create_slaveVP
261 #define VMS_WL__create_slaveVP VMS_int__create_slaveVP
263 //Use this to create processor inside entry point & other places outside
264 // the VMS system boundary (IE, don't animate with a SlaveVP or MasterVP)
265 SlaveVP *
266 VMS_ext__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam );
268 inline SlaveVP *
269 VMS_int__create_slaveVP_helper( SlaveVP *newSlv, TopLevelFnPtr fnPtr,
270 void *dataParam, void *stackLocs );
272 inline void
273 VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr,
274 void *dataParam);
276 void
277 VMS_int__dissipate_slaveVP( SlaveVP *slaveToDissipate );
278 #define VMS_PI__dissipate_slaveVP VMS_int__dissipate_slaveVP
279 //WL: dissipate a SlaveVP by sending a request
281 void
282 VMS_ext__dissipate_slaveVP( SlaveVP *slaveToDissipate );
284 void
285 VMS_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, VMSExcp *excpData );
286 #define VMS_PI__throw_exception VMS_int__throw_exception
287 #define VMS_WL__throw_exception VMS_int__throw_exception
289 void *
290 VMS_int__give_sem_env_for( SlaveVP *animSlv );
291 #define VMS_PI__give_sem_env_for VMS_int__give_sem_env_for
292 #define VMS_SS__give_sem_env_for VMS_int__give_sem_env_for
293 //No WL version -- not safe! if use in WL, be sure data rd & wr is stable
295 //============== Request Related ===============
297 void
298 VMS_int__suspend_slaveVP_and_send_req( SlaveVP *callingSlv );
300 inline void
301 VMS_WL__add_sem_request_in_mallocd_VMSReqst( void *semReqData, SlaveVP *callingSlv );
303 inline void
304 VMS_WL__send_sem_request( void *semReqData, SlaveVP *callingSlv );
306 void
307 VMS_WL__send_create_slaveVP_req( void *semReqData, SlaveVP *reqstingSlv );
309 void inline
310 VMS_WL__send_dissipate_req( SlaveVP *prToDissipate );
312 inline void
313 VMS_WL__send_VMSSem_request( void *semReqData, SlaveVP *callingSlv );
315 VMSReqst *
316 VMS_PI__take_next_request_out_of( SlaveVP *slaveWithReq );
318 inline void *
319 VMS_PI__take_sem_reqst_from( VMSReqst *req );
321 void inline
322 VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingSlv, void *semEnv,
323 ResumeSlvFnPtr resumeSlvFnPtr );
325 //======================== MEASUREMENT ======================
326 uint64
327 VMS_WL__give_num_plugin_cycles();
328 uint32
329 VMS_WL__give_num_plugin_animations();
332 //========================= Utilities =======================
333 inline char *
334 VMS_int__strDup( char *str );
337 //========================= Probes =======================
338 #include "Services_Offered_by_VMS/Measurement_and_Stats/probes.h"
340 //================================================
341 #endif /* _VMS_H */
