Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
view VSs.h @ 14:b2bc97318262
bug fix -- always turn SlotTaskSlv into ExtraTaskSlv inside request handler
author | Sean Halle <seanhalle@yahoo.com> |
---|---|
date | Thu, 23 Aug 2012 01:27:26 -0700 |
parents | 2bf83f932705 |
children | 1ffd5df22df9 a60399b62614 |
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 _VSs_H
10 #define _VSs_H
12 #include "Queue_impl/PrivateQueue.h"
13 #include "Hash_impl/PrivateHash.h"
14 #include "VMS_impl/VMS.h"
15 #include "Measurement/dependency.h"
18 //===========================================================================
19 #define NUM_STRUCS_IN_SEM_ENV 1000
21 //This is hardware dependent -- it's the number of cycles of scheduling
22 // overhead -- if a work unit is fewer than this, it is better being
23 // combined sequentially with other work
24 //This value depends on both VMS overhead and VSs's plugin. At some point
25 // it will be derived by perf-counter measurements during init of VSs
26 #define MIN_WORK_UNIT_CYCLES 20000
28 //===========================================================================
29 /*This header defines everything specific to the VSs semantic plug-in
30 */
31 typedef struct _VSsSemReq VSsSemReq;
32 typedef void (*VSsTaskFnPtr ) ( void *, SlaveVP *);
33 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
34 //===========================================================================
36 #define NONCTLD 0
37 #define IN 1 /*Trick -- READER same as IN*/
38 #define OUT 2 /*Trick -- WRITER same as OUT and INOUT*/
39 #define INOUT 2 /*Trick -- WRITER same as OUT and INOUT*/
41 #define READER 1 /*Trick -- READER same as IN*/
42 #define WRITER 2 /*Trick -- WRITER same as OUT and INOUT*/
44 #define IS_A_THREAD NULL
45 #define IS_ENDED NULL
46 #define SEED_SLV NULL
48 typedef struct
49 {
50 VSsTaskFnPtr fn;
51 int32 numTotalArgs;//the number of inputs to function
52 int32 numCtldArgs;//how many of args have dependencies
53 int32 *argTypes; //says reader, writer, or non-ctld
54 int32 *argSizes; //for detecting overlap
55 int32 sizeOfArgs; //for memcpy of args struct
56 }
57 VSsTaskType;
60 typedef struct
61 {
62 bool32 hasEnabledNonFinishedWriter;
63 int32 numEnabledNonDoneReaders;
64 PrivQueueStruc *waitersQ;
65 }
66 VSsPointerEntry;
68 typedef struct
69 {
70 void **args; //ctld args must come first, as ptrs
71 VSsTaskType *taskType;
72 int32 *taskID;
73 int32 numBlockingProp;
74 SlaveVP *slaveAssignedTo; //only valid before end task (thread)
75 VSsPointerEntry **ptrEntries;
76 void* parentTaskStub;
77 int32 numLiveChildTasks;
78 int32 numLiveChildThreads;
79 bool32 isWaitingForChildTasksToEnd;
80 bool32 isWaitingForChildThreadsToEnd;
81 bool32 isEnded;
82 }
83 VSsTaskStub;
86 typedef struct
87 {
88 VSsTaskStub *taskStub;
89 int32 argNum;
90 int32 isReader;
91 }
92 VSsTaskStubCarrier;
95 /*Semantic layer-specific data sent inside a request from lib called in app
96 * to request handler called in AnimationMaster
97 */
99 typedef struct
100 {
101 SlaveVP *VPCurrentlyExecuting;
102 PrivQueueStruc *waitingVPQ;
103 }
104 VSsTrans;
106 /*WARNING: assembly hard-codes position of endInstrAddr as first field
107 */
108 typedef struct
109 {
110 void *endInstrAddr;
111 int32 hasBeenStarted;
112 int32 hasFinished;
113 PrivQueueStruc *waitQ;
114 }
115 VSsSingleton;
117 enum VSsReqType
118 {
119 submit_task = 1,
120 end_task,
121 create_slave,
122 create_slave_w_aff,
123 dissipate_slave,
124 //===============================
125 send_type_to,
126 receive_type_to,
127 send_from_to,
128 receive_from_to,
129 //===============================
130 taskwait,
131 malloc_req,
132 free_req,
133 singleton_fn_start,
134 singleton_fn_end,
135 singleton_data_start,
136 singleton_data_end,
137 atomic,
138 trans_start,
139 trans_end
140 };
142 struct _VSsSemReq
143 { enum VSsReqType reqType;
144 SlaveVP *callingSlv;
145 VSsTaskType *taskType;
146 void *args;
147 VSsTaskStub *taskStub;
149 SlaveVP *senderSlv;
150 SlaveVP *receiverSlv;
151 int32 *senderID;
152 int32 *receiverID;
153 int32 msgType;
154 void *msg;
155 VSsSemReq *nextReqInHashEntry;
156 int32 *taskID;
158 TopLevelFnPtr fnPtr;
159 void *initData;
160 int32 coreToAssignOnto;
162 int32 sizeToMalloc;
163 void *ptrToFree;
165 int32 singletonID;
166 VSsSingleton **singletonPtrAddr;
168 PtrToAtomicFn fnToExecInMaster;
169 void *dataForFn;
171 int32 transID;
172 }
173 /* VSsSemReq */;
176 typedef struct
177 {
178 PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned)
179 PrivQueueStruc *freeExtraTaskSlvQ; //Shared
180 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned)
181 SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
182 HashTable *argPtrHashTbl;
183 HashTable *commHashTbl;
184 int32 numLiveExtraTaskSlvs;
185 int32 numLiveThreadSlvs;
186 int32 nextCoreToGetNewSlv;
187 int32 primitiveStartTime;
189 //fix limit on num with dynArray
190 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
191 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
193 bool32 *coreIsDone;
194 int32 numCoresDone;
196 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
197 ListOfArrays* unitList;
198 ListOfArrays* ctlDependenciesList;
199 ListOfArrays* commDependenciesList;
200 NtoN** ntonGroups;
201 PrivDynArrayInfo* ntonGroupsInfo;
202 ListOfArrays* dynDependenciesList;
203 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
204 ListOfArrays* hwArcs;
205 #endif
207 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
208 ListOfArrays* counterList[NUM_CORES];
209 #endif
210 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
211 int shutdownInitiated;
212 }
213 VSsSemEnv;
216 typedef struct _TransListElem TransListElem;
217 struct _TransListElem
218 {
219 int32 transID;
220 TransListElem *nextTrans;
221 };
222 //TransListElem
224 enum VSsSlvType
225 { ExtraTaskSlv = 1,
226 SlotTaskSlv,
227 ThreadSlv
228 };
230 typedef struct
231 {
232 int32 highestTransEntered;
233 TransListElem *lastTransEntered;
234 bool32 needsTaskAssigned;
235 VSsTaskStub *taskStub;
236 enum VSsSlvType slaveType;
237 }
238 VSsSemData;
240 //===========================================================================
242 void
243 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
245 int32
246 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
248 void
249 VSs__start_primitive();
251 int32
252 VSs__end_primitive_and_give_cycles();
254 int32
255 VSs__giveIdealNumWorkUnits();
257 int32
258 VSs__give_number_of_cores_to_schedule_onto();
260 //=======================
262 void
263 VSs__init();
265 void
266 VSs__cleanup_after_shutdown();
268 //=======================
270 SlaveVP *
271 VSs__create_thread( TopLevelFnPtr fnPtr, void *initData,
272 SlaveVP *creatingThd );
274 void
275 VSs__end_thread( SlaveVP *thdToEnd );
277 //=======================
279 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
281 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
284 //=======================
285 void
286 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
288 inline int32 *
289 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
291 void
292 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID,
293 SlaveVP *animSlv);
295 void
296 VSs__end_task( SlaveVP *animSlv );
298 //=========================
299 void
300 VSs__taskwait(SlaveVP *animSlv);
303 inline int32 *
304 VSs__give_self_taskID( SlaveVP *animSlv );
306 void
307 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
308 SlaveVP *senderSlv );
310 void
311 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
313 void *
314 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
316 void *
317 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
319 //======================= Concurrency Stuff ======================
320 void
321 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
323 void
324 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
326 void
327 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
329 void
330 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
332 void
333 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
334 void *data, SlaveVP *animSlv );
336 void
337 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
339 void
340 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
343 //========================= Internal use only =============================
344 void
345 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
347 SlaveVP *
348 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
350 SlaveVP*
351 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
352 VSsSemEnv *semEnv, int32 coreToAssignOnto );
354 VSsTaskStub *
355 create_thread_task_stub( void *initData );
358 SlaveVP *
359 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
360 SlaveVP *creatingSlv );
362 SlaveVP *
363 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
364 SlaveVP *creatingSlv, int32 coreToAssignOnto);
366 void
367 idle_fn(void* data, SlaveVP *animatingSlv);
369 //===================== Measurement of Lang Overheads =====================
370 #include "Measurement/VSs_Measurement.h"
372 //===========================================================================
373 #endif /* _VSs_H */