Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
view VSs.h @ 23:3787df8b95f9
seedSlv gets taskID -1, assigner initiates shutdown if deadlock detected, more explicit debug messages
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Fri, 01 Feb 2013 17:18:57 +0100 |
| parents | feea343d202f |
| children | 227db52cbd93 |
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"
17 /* Switch for Nexus support
18 * Note: nexus incompatible with holistic recording (constraints not accessible)
19 * But counter recording still functional, can build constraintless display
20 * with wallclock time
21 */
22 //#define EXTERNAL_SCHEDULER
23 //#define SIMULATE_EXTERNAL_SCHEDULER
25 //===========================================================================
26 #define NUM_STRUCS_IN_SEM_ENV 1000
28 #define MAX_TASKS_NUM 256
30 //This is hardware dependent -- it's the number of cycles of scheduling
31 // overhead -- if a work unit is fewer than this, it is better being
32 // combined sequentially with other work
33 //This value depends on both VMS overhead and VSs's plugin. At some point
34 // it will be derived by perf-counter measurements during init of VSs
35 #define MIN_WORK_UNIT_CYCLES 20000
37 //===========================================================================
38 /*This header defines everything specific to the VSs semantic plug-in
39 */
40 typedef struct _VSsSemReq VSsSemReq;
41 typedef void (*VSsTaskFnPtr ) ( void *, SlaveVP *);
42 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
43 //===========================================================================
45 #define NONCTLD 0
46 #define IN 1 /*Trick -- READER same as IN*/
47 #define OUT 2 /*Trick -- WRITER same as OUT and INOUT*/
48 #define INOUT 2 /*Trick -- WRITER same as OUT and INOUT*/
50 #define READER 1 /*Trick -- READER same as IN*/
51 #define WRITER 2 /*Trick -- WRITER same as OUT and INOUT*/
53 #define IS_A_THREAD NULL
54 #define IS_ENDED NULL
55 #define SEED_SLV NULL
57 typedef struct
58 {
59 VSsTaskFnPtr fn;
60 int32 numTotalArgs;//the number of inputs to function
61 int32 numCtldArgs;//how many of args have dependencies
62 int32 *argTypes; //says reader, writer, or non-ctld
63 int32 *argSizes; //for detecting overlap
64 int32 sizeOfArgs; //for memcpy of args struct
65 }
66 VSsTaskType;
69 typedef struct
70 {
71 bool32 hasEnabledNonFinishedWriter;
72 int32 numEnabledNonDoneReaders;
73 PrivQueueStruc *waitersQ;
74 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
75 Unit lastWriter;
76 ListOfArrays* readersSinceLastWriter;
77 #endif
78 }
79 VSsPointerEntry;
81 typedef struct
82 {
83 void **args; //ctld args must come first, as ptrs
84 VSsTaskType *taskType;
85 int32 *taskID;
86 int32 numBlockingProp;
87 SlaveVP *slaveAssignedTo; //only valid before end task (thread)
88 VSsPointerEntry **ptrEntries;
89 void* parentTaskStub;
90 int32 numLiveChildTasks;
91 int32 numLiveChildThreads;
92 bool32 isWaitingForChildTasksToEnd;
93 bool32 isWaitingForChildThreadsToEnd;
94 bool32 isEnded;
95 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
96 Unit parentUnit;
97 Unit firstOfTask;
98 #endif
99 }
100 VSsTaskStub;
103 typedef struct
104 {
105 VSsTaskStub *taskStub;
106 int32 argNum;
107 int32 isReader;
108 bool32 isSuspended;
109 }
110 VSsTaskStubCarrier;
113 /*Semantic layer-specific data sent inside a request from lib called in app
114 * to request handler called in AnimationMaster
115 */
117 typedef struct
118 {
119 SlaveVP *VPCurrentlyExecuting;
120 PrivQueueStruc *waitingVPQ;
121 }
122 VSsTrans;
124 /*WARNING: assembly hard-codes position of endInstrAddr as first field
125 */
126 typedef struct
127 {
128 void *endInstrAddr;
129 int32 hasBeenStarted;
130 int32 hasFinished;
131 PrivQueueStruc *waitQ;
132 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
133 Unit executingUnit;
134 #endif
135 }
136 VSsSingleton;
138 typedef struct
139 {
140 int32 isOccupied;
141 PrivQueueStruc *waitQ;
142 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
143 Unit previous;
144 #endif
145 }
146 VSsCritical;
148 enum VSsReqType
149 {
150 submit_task = 1,
151 end_task,
152 create_slave,
153 create_slave_w_aff,
154 dissipate_slave,
155 //===============================
156 send_type_to,
157 receive_type_to,
158 send_from_to,
159 receive_from_to,
160 //===============================
161 taskwait,
162 taskwait_on,
163 critical_start,
164 critical_end,
165 malloc_req,
166 free_req,
167 singleton_fn_start,
168 singleton_fn_end,
169 singleton_data_start,
170 singleton_data_end,
171 atomic,
172 trans_start,
173 trans_end
174 };
176 struct _VSsSemReq
177 { enum VSsReqType reqType;
178 SlaveVP *callingSlv;
179 VSsTaskType *taskType;
180 void *args;
181 VSsTaskStub *taskStub;
183 SlaveVP *senderSlv;
184 SlaveVP *receiverSlv;
185 int32 *senderID;
186 int32 *receiverID;
187 int32 msgType;
188 void *msg;
189 VSsSemReq *nextReqInHashEntry;
190 int32 *taskID;
192 TopLevelFnPtr fnPtr;
193 void *initData;
194 int32 coreToAssignOnto;
196 int32 sizeToMalloc;
197 void *ptrToFree;
199 int32 singletonID;
200 VSsSingleton **singletonPtrAddr;
202 PtrToAtomicFn fnToExecInMaster;
203 void *dataForFn;
205 int32 transID;
206 int32 criticalID;
207 }
208 /* VSsSemReq */;
211 typedef struct
212 {
213 PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned)
214 PrivQueueStruc *freeExtraTaskSlvQ; //Shared
215 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned)
216 SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
217 HashTable *argPtrHashTbl;
218 HashTable *commHashTbl;
219 int32 numLiveExtraTaskSlvs;
220 int32 numLiveThreadSlvs;
221 int32 nextCoreToGetNewSlv;
222 int32 primitiveStartTime;
224 //fix limit on num with dynArray
225 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
226 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
227 VSsCritical criticalSection[NUM_STRUCS_IN_SEM_ENV];
229 bool32 *coreIsDone;
230 int32 numCoresDone;
232 int numInFlightTasks;
233 PrivQueueStruc *deferredSubmitsQ;
234 int numDeferred;
236 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
237 ListOfArrays* unitList;
238 ListOfArrays* ctlDependenciesList;
239 ListOfArrays* commDependenciesList;
240 ListOfArrays* dataDependenciesList;
241 ListOfArrays* warDependenciesList;
242 NtoN** ntonGroups;
243 PrivDynArrayInfo* ntonGroupsInfo;
244 ListOfArrays* dynDependenciesList;
245 ListOfArrays* singletonDependenciesList;
246 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
247 ListOfArrays* hwArcs;
248 #endif
250 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
251 ListOfArrays* counterList[NUM_CORES];
252 #endif
253 #ifdef IDLE_SLAVES
254 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
255 #endif
256 int shutdownInitiated;
257 }
258 VSsSemEnv;
261 typedef struct _TransListElem TransListElem;
262 struct _TransListElem
263 {
264 int32 transID;
265 TransListElem *nextTrans;
266 };
267 //TransListElem
269 enum VSsSlvType
270 { ExtraTaskSlv = 1,
271 SlotTaskSlv,
272 ThreadSlv
273 };
275 typedef struct
276 {
277 int32 highestTransEntered;
278 TransListElem *lastTransEntered;
279 bool32 needsTaskAssigned;
280 VSsTaskStub *taskStub;
281 enum VSsSlvType slaveType;
282 }
283 VSsSemData;
285 //===========================================================================
287 void
288 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
290 int32
291 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
293 void
294 VSs__start_primitive();
296 int32
297 VSs__end_primitive_and_give_cycles();
299 int32
300 VSs__giveIdealNumWorkUnits();
302 int32
303 VSs__give_number_of_cores_to_schedule_onto();
305 //=======================
307 void
308 VSs__init();
310 void
311 VSs__cleanup_after_shutdown();
313 //=======================
315 SlaveVP *
316 VSs__create_thread( TopLevelFnPtr fnPtr, void *initData,
317 SlaveVP *creatingThd );
319 void
320 VSs__end_thread( SlaveVP *thdToEnd );
322 //=======================
324 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
326 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
329 //=======================
330 void
331 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
333 int32 *
334 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
336 void
337 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID,
338 SlaveVP *animSlv);
340 void
341 VSs__end_task( SlaveVP *animSlv );
343 //=========================
344 void
345 VSs__taskwait(SlaveVP *animSlv);
347 void
348 VSs__taskwait_on(SlaveVP *animSlv,void* ptr);
350 void
351 VSs__start_critical(SlaveVP *animSlv,int32 name);
353 void
354 VSs__end_critical(SlaveVP *animSlv,int32 name);
356 int32 *
357 VSs__give_self_taskID( SlaveVP *animSlv );
359 void
360 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
361 SlaveVP *senderSlv );
363 void
364 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
366 void *
367 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
369 void *
370 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
372 //======================= Concurrency Stuff ======================
373 void
374 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
376 void
377 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
379 void
380 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
382 void
383 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
385 void
386 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
387 void *data, SlaveVP *animSlv );
389 void
390 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
392 void
393 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
396 //========================= Internal use only =============================
397 void
398 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
400 SlaveVP *
401 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
403 SlaveVP*
404 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
405 VSsSemEnv *semEnv, int32 coreToAssignOnto );
407 VSsTaskStub *
408 create_thread_task_stub( void *initData );
411 SlaveVP *
412 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
413 SlaveVP *creatingSlv );
415 SlaveVP *
416 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
417 SlaveVP *creatingSlv, int32 coreToAssignOnto);
419 void
420 idle_fn(void* data, SlaveVP *animatingSlv);
422 void
423 resume_slaveVP(SlaveVP *slave, VSsSemEnv *semEnv);
425 //===================== Measurement of Lang Overheads =====================
426 #include "Measurement/VSs_Measurement.h"
428 //===========================================================================
429 #endif /* _VSs_H */
