comparison VMS.h @ 209:0c83ea8adefc

Close to compilable version of common_ancestor -- still includes HW dep stuff
author Some Random Person <seanhalle@yahoo.com>
date Sun, 04 Mar 2012 14:26:35 -0800
parents eaf7e4c58c9e
children a18539c0bc37
comparison
equal deleted inserted replaced
95:626e560d81f7 96:16bb3aa7337c
18 #include "vmalloc.h" 18 #include "vmalloc.h"
19 19
20 #include <pthread.h> 20 #include <pthread.h>
21 #include <sys/time.h> 21 #include <sys/time.h>
22 22
23 #ifndef _LANG_NAME_
24 #define _LANG_NAME_ ""
25 #endif
26
23 //================= Defines: included from separate files ================= 27 //================= Defines: included from separate files =================
24 // 28 //
25 // Note: ALL defines are in other files, none are in here 29 // Note: ALL defines are in other files, none are in here
26 // 30 //
27 #include "VMS_defs__main.h" 31 #include "VMS_defs__main.h"
42 typedef struct _MasterVP MasterVP; 46 typedef struct _MasterVP MasterVP;
43 typedef struct _IntervalProbe IntervalProbe; 47 typedef struct _IntervalProbe IntervalProbe;
44 typedef struct _GateStruc GateStruc; 48 typedef struct _GateStruc GateStruc;
45 49
46 50
47 typedef SlaveVP * (*Sched_Assigner) ( void *, int ); //semEnv, coreIdx 51 typedef SlaveVP * (*Sched_Assigner) ( void *, int ); //semEnv, coreIdx
48 typedef void (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv 52 typedef void (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv
49 typedef void (*TopLevelFnPtr) ( void *, SlaveVP * ); //initData, animPr 53 typedef void (*TopLevelFnPtr) ( void *, SlaveVP * ); //initData, animSlv
50 typedef void TopLevelFn ( void *, SlaveVP * ); //initData, animPr 54 typedef void TopLevelFn ( void *, SlaveVP * ); //initData, animSlv
51 typedef void (*ResumeVPFnPtr) ( SlaveVP *, void * ); 55 typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * );
56
57 //============================ HW Dependent Fns ================================
58
59 #include "VMS__HW_dependent.h"
52 60
53 //============================= Statistics ================================== 61 //============================= Statistics ==================================
54 62
55 inline TSCount getTSCount(); 63 inline TSCount getTSCount();
56 64
81 otherIO 89 otherIO
82 }; 90 };
83 91
84 typedef struct 92 typedef struct
85 { enum VMSSemReqstType reqType; 93 { enum VMSSemReqstType reqType;
86 SlaveVP *requestingPr; 94 SlaveVP *requestingSlv;
87 char *nameStr; //for create probe 95 char *nameStr; //for create probe
88 } 96 }
89 VMSSemReq; 97 VMSSemReq;
90 98
91 99
92 //==================== Core data structures =================== 100 //==================== Core data structures ===================
93 101
94 struct _SchedSlot 102 struct _SchedSlot
95 { 103 {
96 int workIsDone; 104 int workIsDone;
97 int needsProcrAssigned; 105 int needsSlaveAssigned;
98 SlaveVP *procrAssignedToSlot; 106 SlaveVP *slaveAssignedToSlot;
99 }; 107 };
100 //SchedSlot 108 //SchedSlot
101 109
102 /*WARNING: re-arranging this data structure could cause VP switching 110 /*WARNING: re-arranging this data structure could cause Slv switching
103 * assembly code to fail -- hard-codes offsets of fields 111 * assembly code to fail -- hard-codes offsets of fields
104 */ 112 */
105 struct _SlaveVP 113 struct _SlaveVP
106 { int procrID; //for debugging -- count up each time create 114 { int procrID; //for debugging -- count up each time create
107 int coreAnimatedBy; 115 int coreAnimatedBy;
115 void *coreLoopStackPtr; //restore before jmp back to core loop 123 void *coreLoopStackPtr; //restore before jmp back to core loop
116 124
117 SchedSlot *schedSlot; 125 SchedSlot *schedSlot;
118 VMSReqst *requests; 126 VMSReqst *requests;
119 127
120 void *semanticData; //this livesUSE_GNU here for the life of VP 128 void *semanticData; //this livesUSE_GNU here for the life of Slv
121 void *dataRetFromReq;//values returned from plugin to VP go here 129 void *dataRetFromReq;//values returned from plugin to Slv go here
122 130
123 //=========== MEASUREMENT STUFF ========== 131 //=========== MEASUREMENT STUFF ==========
124 #ifdef MEAS__TIME_STAMP_SUSP 132 MEAS__Insert_Meas_Fields_into_Slave;
125 uint32 preSuspTSCLow;
126 uint32 postSuspTSCLow;
127 #endif
128 #ifdef MEAS__TIME_MASTER /* in SlaveVP because multiple masterVPs*/
129 uint32 startMasterTSCLow;USE_GNU
130 uint32 endMasterTSCLow;
131 #endif
132 #ifdef MEAS__TIME_2011_SYS
133 TSCountLowHigh startSusp;
134 uint64 totalSuspCycles;
135 uint32 numGoodSusp;
136 #endif
137 //======================================== 133 //========================================
138 134
139 float64 createPtInSecs; //have space but don't use on some configs 135 float64 createPtInSecs; //have space but don't use on some configs
140 }; 136 };
141 //SlaveVP 137 //SlaveVP
142 138
143 139
144 /*WARNING: re-arranging this data structure could cause VP-switching 140 /*WARNING: re-arranging this data structure could cause Slv-switching
145 * assembly code to fail -- hard-codes offsets of fields 141 * assembly code to fail -- hard-codes offsets of fields
146 * (because -O3 messes with things otherwise) 142 * (because -O3 messes with things otherwise)
147 */ 143 */
148 typedef struct 144 typedef struct
149 { 145 {
150 union{ //adds padding to put masterLock on its own cache-line to elim 146 Sched_Assigner slaveAssigner;
151 // false sharing (masterLock is most-accessed var in VMS)
152 volatile int32 masterLock;
153 char padding[CACHE_LINE_SZ];
154 } masterLockUnion;
155 Sched_Assigner slaveSchedAssigner;
156 RequestHandler requestHandler; 147 RequestHandler requestHandler;
157 148
158 SchedSlot ***allSchedSlots; 149 SchedSlot ***allSchedSlots;
159 VMSQueueStruc **readyToAnimateQs; 150 VMSQueueStruc **readyToAnimateQs;
160 SlaveVP **masterVPs; 151 SlaveVP **masterVPs;
161 152
162 void *semanticEnv; 153 void *semanticEnv;
163 void *OSEventStruc; //for future, when add I/O to BLIS 154 void *OSEventStruc; //for future, when add I/O to BLIS
164 MallocArrays *freeLists; 155 MallocArrays *freeLists;
165 int32 amtOfOutstandingMem; //total currently allocated 156 int32 amtOfOutstandingMem; //total currently allocated
166 157
167 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop 158 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
168 159
169 int32 setupComplete; 160 int32 setupComplete;
170 //int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP 161 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP
162 int32 masterLock __align_to_cacheline__;
171 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal 163 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal
172 int32 workStealingLock; 164 int32 workStealingLock;
173 165
174 int32 numVPsCreated; //gives ordering to processor creation 166 int32 numSlavesCreated; //gives ordering to processor creation
167 int32 numSlavesAlive; //used to detect when to shutdown
175 168
176 //=========== MEASUREMENT STUFF ============= 169 //=========== MEASUREMENT STUFF =============
177 IntervalProbe **intervalProbes; 170 IntervalProbe **intervalProbes;
178 PrivDynArrayInfo *dynIntervalProbesInfo; 171 PrivDynArrayInfo *dynIntervalProbesInfo;
179 HashTable *probeNameHashTbl; 172 HashTable *probeNameHashTbl;
180 int32 masterCreateProbeID; 173 int32 masterCreateProbeID;
181 float64 createPtInSecs; 174 float64 createPtInSecs;
182 Histogram **measHists; 175 Histogram **measHists;
183 PrivDynArrayInfo *measHistsInfo; 176 PrivDynArrayInfo *measHistsInfo;
184 #ifdef MEAS__TIME_PLUGIN 177 MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
185 Histogram *reqHdlrLowTimeHist; 178 MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
186 Histogram *reqHdlrHighTimeHist; 179 MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
187 #endif 180 MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
188 #ifdef MEAS__TIME_MALLOC 181 MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
189 Histogram *mallocTimeHist; 182 MEAS__Insert_System_Meas_Fields_into_MasterEnv;
190 Histogram *freeTimeHist;
191 #endif
192 #ifdef MEAS__TIME_MASTER_LOCK
193 Histogram *masterLockLowTimeHist;
194 Histogram *masterLockHighTimeHist;
195 #endif
196 #ifdef MEAS__TIME_2011_SYS
197 TSCountLowHigh startMaster;
198 uint64 totalMasterCycles;
199 uint32 numMasterAnimations;
200 TSCountLowHigh startReqHdlr;
201 uint64 totalPluginCycles;
202 uint32 numPluginAnimations;
203 uint64 cyclesTillStartMasterLoop;
204 TSCountLowHigh endMasterLoop;
205 #endif
206 //========================================== 183 //==========================================
207 } 184 }
208 MasterEnv; 185 MasterEnv;
209 186
210 //========================= Extra Stuff Data Strucs ======================= 187 //========================= Extra Stuff Data Strucs =======================
235 void *endThdPt; 212 void *endThdPt;
236 unsigned int coreNum; 213 unsigned int coreNum;
237 } 214 }
238 ThdParams; 215 ThdParams;
239 216
217 //============================= Global Vars ================================
218
240 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state 219 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state
241 ThdParams *coreLoopThdParams [ NUM_CORES ]; 220 ThdParams *coreLoopThdParams [ NUM_CORES ];
242 pthread_mutex_t suspendLock; 221 pthread_mutex_t suspendLock;
243 pthread_cond_t suspend_cond; 222 pthread_cond_t suspend_cond;
244 223
245
246
247 //============================= Global Vars ================================
248
249 volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__; 224 volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__;
250 225
251 226
252
253
254 //========================= Function Prototypes =========================== 227 //========================= Function Prototypes ===========================
255 228
229 /* MEANING OF WL PI SS int
230 * These indicate which places the function is safe to use. They stand for:
231 * WL: Wrapper Library
232 * PI: Plugin
233 * SS: Startup and Shutdown
234 * int: internal to the VMS implementation
235 */
256 236
257 //========== Setup and shutdown ========== 237 //========== Setup and shutdown ==========
258 void 238 void
259 VMS_int__init(); 239 VMS_SS__init();
260 240
261 Fix seed-procr creation -- put box around language, have lang register stuff 241 //Fix;
242 /*seed-procr creation -- put box around language, have lang register stuff
262 with VMS. 243 with VMS.
263 have main program explicitly INIT Lang! -- makes more sense to 244 have main program explicitly INIT Lang! -- makes more sense to
264 C programmers -- makes it clear that there's a transition. 245 C programmers -- makes it clear that there's a transition.
265 (might need to have the pthreads remain waiting for 246 (might need to have the pthreads remain waiting for
266 cond until work is scheduled) 247 cond until work is scheduled)
287 "VMS__link_programs(processIDs, 2);" 268 "VMS__link_programs(processIDs, 2);"
288 Then, the programs just know they sync with other prog, but use own 269 Then, the programs just know they sync with other prog, but use own
289 lang's sync constructs -- VMS uses message system to establish tie-pt, 270 lang's sync constructs -- VMS uses message system to establish tie-pt,
290 each lang defines what a tie-point means to it.. (work with the 271 each lang defines what a tie-point means to it.. (work with the
291 diff semantics?) 272 diff semantics?)
292 void 273 */
293 VMS_WL__start_the_work_then_wait_until_done(); 274 void
294 275 VMS_SS__start_the_work_then_wait_until_done();
295 void 276
296 VMS_int__shutdown(); 277 void
297 278 VMS_SS__shutdown();
298 void 279
299 VMS_int__cleanup_at_end_of_shutdown(); 280 void
281 VMS_SS__cleanup_at_end_of_shutdown();
300 282
301 283
302 //============== =============== 284 //============== ===============
303 285
304 inline SlaveVP * 286 inline SlaveVP *
305 VMS_int__create_procr( TopLevelFnPtr fnPtr, void *dataParam ); 287 VMS_int__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam );
288 #define VMS_PI__create_slaveVP VMS_int__create_slaveVP
289 #define VMS_WL__create_slaveVP VMS_int__create_slaveVP
306 290
307 inline void 291 inline void
308 VMS_int__point_slave_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr, 292 VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr,
309 void *dataParam); 293 void *dataParam);
310 294 #define VMS_PI__point_slaveVP_to_Fn VMS_int__point_slaveVP_to_Fn
311 void 295 #define VMS_WL__point_slaveVP_to_Fn VMS_int__point_slaveVP_to_Fn
312 VMS_int__save_return_addr_into_ptd_to_loc(void *ptrToReturnAddrHoldingLoc); 296
313 297 void
314 void 298 VMS_int__dissipate_SlaveVP( SlaveVP *slaveToDissipate );
315 VMS_int__write_return_addr_from_ptd_to_loc(void *ptrToReturnAddrHoldingLoc); 299 #define VMS_PI__dissipate_SlaveVP VMS_int__dissipateSlaveVP
316 300 //From WL, dissipate a SlaveVP by sending a request
317 void
318 VMS_int__dissipate_procr( SlaveVP *procrToDissipate );
319 301
320 //Use this to create processor inside entry point & other places outside 302 //Use this to create processor inside entry point & other places outside
321 // the VMS system boundary (IE, not run in slave nor Master) 303 // the VMS system boundary (IE, not run in slave nor Master)
322 SlaveVP * 304 SlaveVP *
323 VMS_ext__create_procr( TopLevelFnPtr fnPtr, void *dataParam ); 305 VMS_ext__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam );
324 306
325 void 307 void
326 VMS_ext__dissipate_procr( SlaveVP *procrToDissipate ); 308 VMS_ext__dissipate_slaveVP( SlaveVP *slaveToDissipate );
327 309
328 void 310 void
329 VMS_PI__throw_exception( char *msgStr, SlaveVP *reqstPr, VMSExcp *excpData ); 311 VMS_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, VMSExcp *excpData );
312 #define VMS_PI__throw_exception VMS_int__throw_exception
313 #define VMS_WL__throw_exception VMS_int__throw_exception
330 314
331 void * 315 void *
332 VMS_WL__give_sem_env_for( SlaveVP *animPr ); 316 VMS_int__give_sem_env_for( SlaveVP *animSlv );
317 #define VMS_PI__give_sem_env_for VMS_int__give_sem_env_for
318 #define VMS_SS__give_sem_env_for VMS_int__give_sem_env_for
319 //No WL version -- not safe! if use in WL, be sure data rd & wr is stable
333 320
334 //============== Request Related =============== 321 //============== Request Related ===============
335 322
336 void 323 void
337 VMS_int__suspend_procr( SlaveVP *callingPr ); 324 VMS_int__suspend_slaveVP_and_send_req( SlaveVP *callingSlv );
338 325
339 inline void 326 inline void
340 VMS_WL__add_sem_request_in_mallocd_VMSReqst( void *semReqData, SlaveVP *callingPr ); 327 VMS_WL__add_sem_request_in_mallocd_VMSReqst( void *semReqData, SlaveVP *callingSlv );
341 328
342 inline void 329 inline void
343 VMS_WL__send_sem_request( void *semReqData, SlaveVP *callingPr ); 330 VMS_WL__send_sem_request( void *semReqData, SlaveVP *callingSlv );
344 331
345 void 332 void
346 VMS_WL__send_create_procr_req( void *semReqData, SlaveVP *reqstingPr ); 333 VMS_WL__send_create_slaveVP_req( void *semReqData, SlaveVP *reqstingSlv );
347 334
348 void inline 335 void inline
349 VMS_WL__send_dissipate_req( SlaveVP *prToDissipate ); 336 VMS_WL__send_dissipate_req( SlaveVP *prToDissipate );
350 337
351 inline void 338 inline void
352 VMS_WL__send_VMSSem_request( void *semReqData, SlaveVP *callingPr ); 339 VMS_WL__send_VMSSem_request( void *semReqData, SlaveVP *callingSlv );
353 340
354 VMSReqst * 341 VMSReqst *
355 VMS_PI__take_next_request_out_of( SlaveVP *procrWithReq ); 342 VMS_PI__take_next_request_out_of( SlaveVP *slaveWithReq );
356 343
357 inline void * 344 inline void *
358 VMS_PI__take_sem_reqst_from( VMSReqst *req ); 345 VMS_PI__take_sem_reqst_from( VMSReqst *req );
359 346
360 void inline 347 void inline
361 VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingPr, void *semEnv, 348 VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingSlv, void *semEnv,
362 ResumeVPFnPtr resumePrFnPtr ); 349 ResumeSlvFnPtr resumeSlvFnPtr );
363 350
364 //======================== MEASUREMENT ====================== 351 //======================== MEASUREMENT ======================
365 uint64 352 uint64
366 VMS_WL__give_num_plugin_cycles(); 353 VMS_WL__give_num_plugin_cycles();
367 uint32 354 uint32
368 VMS_WL__give_num_plugin_animations(); 355 VMS_WL__give_num_plugin_animations();
369 356
370 357
371
372 #include "VMS__HW_dependent.h"
373 #include "probes.h" 358 #include "probes.h"
374 #include "vutilities.h" 359 #include "vutilities.h"
375 360
376 #endif /* _VMS_H */ 361 #endif /* _VMS_H */
377 362