Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
view VSs.h @ 41:37bb39da5ff1
static3d working, still trouble with child tasks
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Wed, 05 Jun 2013 14:40:40 +0200 |
| parents | 0715109abb08 |
| children | 8733d1299c3a |
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 extern void free_pointer_entry(void* ptrEntry);
18 /* Switch for Nexus support
19 * Note: nexus incompatible with holistic recording (constraints not accessible)
20 * But counter recording still functional, can build constraintless display
21 * with wallclock time
22 */
23 //#define EXTERNAL_SCHEDULER
24 //#define SIMULATE_EXTERNAL_SCHEDULER
26 //===========================================================================
27 #define NUM_STRUCS_IN_SEM_ENV 1000
29 #define MAX_TASKS_NUM 5
31 //This is hardware dependent -- it's the number of cycles of scheduling
32 // overhead -- if a work unit is fewer than this, it is better being
33 // combined sequentially with other work
34 //This value depends on both VMS overhead and VSs's plugin. At some point
35 // it will be derived by perf-counter measurements during init of VSs
36 #define MIN_WORK_UNIT_CYCLES 20000
38 //===========================================================================
39 /*This header defines everything specific to the VSs semantic plug-in
40 */
41 typedef struct _VSsSemReq VSsSemReq;
42 typedef void (*VSsTaskFnPtr ) ( void * );
43 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
44 //===========================================================================
46 #define NONCTLD 0
47 #define IN 1 /*Trick -- READER same as IN*/
48 #define OUT 2 /*Trick -- WRITER same as OUT and INOUT*/
49 #define INOUT 2 /*Trick -- WRITER same as OUT and INOUT*/
51 #define READER 1 /*Trick -- READER same as IN*/
52 #define WRITER 2 /*Trick -- WRITER same as OUT and INOUT*/
54 #define IS_A_THREAD NULL
55 #define IS_ENDED NULL
56 #define SEED_SLV NULL
58 typedef struct
59 {
60 VSsTaskFnPtr fn;
61 int32 numDeps;//how many of args have dependencies
62 int32 *depsTypes; //says reader, writer, or non-ctld
63 size_t *depsSizes; //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 void **args; //for calling only, can contain values
83 void** depsAddrs; //pointers only
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 int *depsMask;
96 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
97 Unit parentUnit;
98 Unit firstOfTask;
99 #endif
100 }
101 VSsTaskStub;
104 typedef struct
105 {
106 VSsTaskStub *taskStub;
107 int32 argNum;
108 int32 isReader;
109 bool32 isSuspended;
110 }
111 VSsTaskStubCarrier;
114 /*Semantic layer-specific data sent inside a request from lib called in app
115 * to request handler called in AnimationMaster
116 */
118 typedef struct
119 {
120 SlaveVP *VPCurrentlyExecuting;
121 PrivQueueStruc *waitingVPQ;
122 }
123 VSsTrans;
125 /*WARNING: assembly hard-codes position of endInstrAddr as first field
126 */
127 typedef struct
128 {
129 void *endInstrAddr;
130 int32 hasBeenStarted;
131 int32 hasFinished;
132 PrivQueueStruc *waitQ;
133 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
134 Unit executingUnit;
135 #endif
136 }
137 VSsSingleton;
139 typedef struct
140 {
141 int32 isOccupied;
142 PrivQueueStruc *waitQ;
143 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
144 Unit previous;
145 #endif
146 }
147 VSsCritical;
149 enum VSsReqType
150 {
151 submit_task = 1,
152 end_task,
153 create_slave,
154 create_slave_w_aff,
155 dissipate_slave,
156 //===============================
157 send_type_to,
158 receive_type_to,
159 send_from_to,
160 receive_from_to,
161 //===============================
162 taskwait,
163 taskwait_on,
164 critical_start,
165 critical_end,
166 malloc_req,
167 free_req,
168 singleton_fn_start,
169 singleton_fn_end,
170 singleton_data_start,
171 singleton_data_end,
172 atomic,
173 trans_start,
174 trans_end
175 };
177 struct _VSsSemReq
178 { enum VSsReqType reqType;
179 SlaveVP *callingSlv;
180 VSsTaskType *taskType;
181 void *args;
182 void *deps;
183 VSsTaskStub *taskStub;
185 SlaveVP *senderSlv;
186 SlaveVP *receiverSlv;
187 int32 *senderID;
188 int32 *receiverID;
189 int32 msgType;
190 void *msg;
191 VSsSemReq *nextReqInHashEntry;
192 int32 *taskID;
194 TopLevelFnPtr fnPtr;
195 void *initData;
196 int32 coreToAssignOnto;
198 int32 sizeToMalloc;
199 void *ptrToFree;
201 int32 singletonID;
202 VSsSingleton **singletonPtrAddr;
204 PtrToAtomicFn fnToExecInMaster;
205 void *dataForFn;
207 int32 transID;
208 void* criticalID;
209 }
210 /* VSsSemReq */;
213 typedef struct
214 {
215 PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned)
216 PrivQueueStruc *freeExtraTaskSlvQ; //Shared
217 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned)
218 SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
219 HashTable *argPtrHashTbl;
220 HashTable *commHashTbl;
221 HashTable *criticalHashTbl;
222 int32 numLiveExtraTaskSlvs;
223 int32 numLiveThreadSlvs;
224 int32 nextCoreToGetNewSlv;
225 int32 primitiveStartTime;
227 //fix limit on num with dynArray
228 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
229 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
232 bool32 *coreIsDone;
233 int32 numCoresDone;
235 int numInFlightTasks;
236 PrivQueueStruc *deferredSubmitsQ;
237 int numDeferred;
239 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
240 ListOfArrays* unitList;
241 ListOfArrays* ctlDependenciesList;
242 ListOfArrays* commDependenciesList;
243 ListOfArrays* dataDependenciesList;
244 ListOfArrays* warDependenciesList;
245 NtoN** ntonGroups;
246 PrivDynArrayInfo* ntonGroupsInfo;
247 ListOfArrays* dynDependenciesList;
248 ListOfArrays* singletonDependenciesList;
249 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
250 ListOfArrays* hwArcs;
251 #endif
253 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
254 ListOfArrays* counterList[NUM_CORES];
255 #endif
256 #ifdef IDLE_SLAVES
257 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
258 #endif
259 //int shutdownInitiated;
260 }
261 VSsSemEnv;
264 typedef struct _TransListElem TransListElem;
265 struct _TransListElem
266 {
267 int32 transID;
268 TransListElem *nextTrans;
269 };
270 //TransListElem
272 enum VSsSlvType
273 { ExtraTaskSlv = 1,
274 SlotTaskSlv,
275 ThreadSlv
276 };
278 typedef struct
279 {
280 int32 highestTransEntered;
281 TransListElem *lastTransEntered;
282 bool32 needsTaskAssigned;
283 VSsTaskStub *taskStub;
284 enum VSsSlvType slaveType;
285 }
286 VSsSemData;
288 //===========================================================================
290 void
291 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
293 int32
294 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
296 void
297 VSs__start_primitive();
299 int32
300 VSs__end_primitive_and_give_cycles();
302 int32
303 VSs__giveIdealNumWorkUnits();
305 int32
306 VSs__give_number_of_cores_to_schedule_onto();
308 //=======================
310 void
311 VSs__init();
313 void
314 VSs__cleanup_after_shutdown();
316 //=======================
318 SlaveVP *
319 VSs__create_thread( TopLevelFnPtr fnPtr, void *initData,
320 SlaveVP *creatingThd );
322 void VSs__run_thread(TopLevelFnPtr fnPtr, void *initData);
324 void
325 VSs__end_thread();
327 //=======================
329 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
331 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
334 //=======================
335 void
336 VSs__submit_task( VSsTaskType *taskType, void *args, void* deps);
338 int32 *
339 VSs__create_taskID_of_size( int32 numInts);
341 void
342 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, void* deps, int32 *taskID);
344 void VSs__run_task(TopLevelFnPtr fnPtr, void *initData);
346 void
347 VSs__end_task();
349 //=========================
350 void
351 VSs__taskwait();
353 void
354 VSs__taskwait_on(void* ptr);
356 void
357 VSs__start_critical(void* name);
359 void
360 VSs__end_critical(void* name);
362 int32 *
363 VSs__give_self_taskID();
365 void
366 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID);
368 void
369 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID);
371 void *
372 VSs__receive_type_to( const int32 type, int32* receiverID );
374 void *
375 VSs__receive_from_to( int32 *senderID, int32 *receiverID );
377 //======================= Concurrency Stuff ======================
378 void
379 VSs__start_fn_singleton( int32 singletonID );
381 void
382 VSs__end_fn_singleton( int32 singletonID );
384 void
385 VSs__start_data_singleton( VSsSingleton **singeltonAddr );
387 void
388 VSs__end_data_singleton( VSsSingleton **singletonAddr );
390 void
391 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
392 void *data );
394 void
395 VSs__start_transaction( int32 transactionID );
397 void
398 VSs__end_transaction( int32 transactionID );
401 //========================= Internal use only =============================
402 void
403 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
405 SlaveVP *
406 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
408 SlaveVP*
409 VSs__create_slave_helper(TopLevelFnWrapper fnWrapper, TopLevelFnPtr fnPtr, void *initData,
410 VSsSemEnv *semEnv, int32 coreToAssignOnto );
412 VSsTaskStub *
413 create_thread_task_stub( void *initData );
416 SlaveVP *
417 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
418 SlaveVP *creatingSlv );
420 SlaveVP *
421 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
422 SlaveVP *creatingSlv, int32 coreToAssignOnto);
424 void
425 idle_fn(void* data);
427 void
428 resume_slaveVP(SlaveVP *slave, VSsSemEnv *semEnv);
430 //===================== Measurement of Lang Overheads =====================
431 #include "Measurement/VSs_Measurement.h"
433 //===========================================================================
435 /* Hide entry point trick */
437 typedef struct {
438 int argc;
439 char** argv;
440 } __main_args;
442 extern int __main_ret;
444 int __program_main(int argc, char** argv);
446 void __entry_point(void* _args);
448 int main(int argc, char** argv);
451 #define main __program_main
453 #endif /* _VSs_H */
