Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
view VSs.h @ 18:c9606ea7abc8
add interface for Tamer's nexus board
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Tue, 11 Sep 2012 17:51:05 +0200 |
| parents | f83fff8bd4b2 |
| children | 58a71af04cd1 |
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 //This is hardware dependent -- it's the number of cycles of scheduling
29 // overhead -- if a work unit is fewer than this, it is better being
30 // combined sequentially with other work
31 //This value depends on both VMS overhead and VSs's plugin. At some point
32 // it will be derived by perf-counter measurements during init of VSs
33 #define MIN_WORK_UNIT_CYCLES 20000
35 //===========================================================================
36 /*This header defines everything specific to the VSs semantic plug-in
37 */
38 typedef struct _VSsSemReq VSsSemReq;
39 typedef void (*VSsTaskFnPtr ) ( void *, SlaveVP *);
40 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
41 //===========================================================================
43 #define NONCTLD 0
44 #define IN 1 /*Trick -- READER same as IN*/
45 #define OUT 2 /*Trick -- WRITER same as OUT and INOUT*/
46 #define INOUT 2 /*Trick -- WRITER same as OUT and INOUT*/
48 #define READER 1 /*Trick -- READER same as IN*/
49 #define WRITER 2 /*Trick -- WRITER same as OUT and INOUT*/
51 #define IS_A_THREAD NULL
52 #define IS_ENDED NULL
53 #define SEED_SLV NULL
55 typedef struct
56 {
57 VSsTaskFnPtr fn;
58 int32 numTotalArgs;//the number of inputs to function
59 int32 numCtldArgs;//how many of args have dependencies
60 int32 *argTypes; //says reader, writer, or non-ctld
61 int32 *argSizes; //for detecting overlap
62 int32 sizeOfArgs; //for memcpy of args struct
63 }
64 VSsTaskType;
67 typedef struct
68 {
69 bool32 hasEnabledNonFinishedWriter;
70 int32 numEnabledNonDoneReaders;
71 PrivQueueStruc *waitersQ;
72 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
73 Unit lastWriter;
74 ListOfArrays* readersSinceLastWriter;
75 #endif
76 }
77 VSsPointerEntry;
79 typedef struct
80 {
81 void **args; //ctld args must come first, as ptrs
82 VSsTaskType *taskType;
83 int32 *taskID;
84 int32 numBlockingProp;
85 SlaveVP *slaveAssignedTo; //only valid before end task (thread)
86 VSsPointerEntry **ptrEntries;
87 void* parentTaskStub;
88 int32 numLiveChildTasks;
89 int32 numLiveChildThreads;
90 bool32 isWaitingForChildTasksToEnd;
91 bool32 isWaitingForChildThreadsToEnd;
92 bool32 isEnded;
93 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
94 Unit parentUnit;
95 #endif
96 }
97 VSsTaskStub;
100 typedef struct
101 {
102 VSsTaskStub *taskStub;
103 int32 argNum;
104 int32 isReader;
105 }
106 VSsTaskStubCarrier;
109 /*Semantic layer-specific data sent inside a request from lib called in app
110 * to request handler called in AnimationMaster
111 */
113 typedef struct
114 {
115 SlaveVP *VPCurrentlyExecuting;
116 PrivQueueStruc *waitingVPQ;
117 }
118 VSsTrans;
120 /*WARNING: assembly hard-codes position of endInstrAddr as first field
121 */
122 typedef struct
123 {
124 void *endInstrAddr;
125 int32 hasBeenStarted;
126 int32 hasFinished;
127 PrivQueueStruc *waitQ;
128 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
129 Unit executingUnit;
130 #endif
131 }
132 VSsSingleton;
134 enum VSsReqType
135 {
136 submit_task = 1,
137 end_task,
138 create_slave,
139 create_slave_w_aff,
140 dissipate_slave,
141 //===============================
142 send_type_to,
143 receive_type_to,
144 send_from_to,
145 receive_from_to,
146 //===============================
147 taskwait,
148 malloc_req,
149 free_req,
150 singleton_fn_start,
151 singleton_fn_end,
152 singleton_data_start,
153 singleton_data_end,
154 atomic,
155 trans_start,
156 trans_end
157 };
159 struct _VSsSemReq
160 { enum VSsReqType reqType;
161 SlaveVP *callingSlv;
162 VSsTaskType *taskType;
163 void *args;
164 VSsTaskStub *taskStub;
166 SlaveVP *senderSlv;
167 SlaveVP *receiverSlv;
168 int32 *senderID;
169 int32 *receiverID;
170 int32 msgType;
171 void *msg;
172 VSsSemReq *nextReqInHashEntry;
173 int32 *taskID;
175 TopLevelFnPtr fnPtr;
176 void *initData;
177 int32 coreToAssignOnto;
179 int32 sizeToMalloc;
180 void *ptrToFree;
182 int32 singletonID;
183 VSsSingleton **singletonPtrAddr;
185 PtrToAtomicFn fnToExecInMaster;
186 void *dataForFn;
188 int32 transID;
189 }
190 /* VSsSemReq */;
193 typedef struct
194 {
195 PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned)
196 PrivQueueStruc *freeExtraTaskSlvQ; //Shared
197 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned)
198 SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
199 HashTable *argPtrHashTbl;
200 HashTable *commHashTbl;
201 int32 numLiveExtraTaskSlvs;
202 int32 numLiveThreadSlvs;
203 int32 nextCoreToGetNewSlv;
204 int32 primitiveStartTime;
206 //fix limit on num with dynArray
207 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
208 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
210 bool32 *coreIsDone;
211 int32 numCoresDone;
213 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
214 ListOfArrays* unitList;
215 ListOfArrays* ctlDependenciesList;
216 ListOfArrays* commDependenciesList;
217 ListOfArrays* dataDependenciesList;
218 ListOfArrays* warDependenciesList;
219 NtoN** ntonGroups;
220 PrivDynArrayInfo* ntonGroupsInfo;
221 ListOfArrays* dynDependenciesList;
222 ListOfArrays* singletonDependenciesList;
223 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
224 ListOfArrays* hwArcs;
225 #endif
227 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
228 ListOfArrays* counterList[NUM_CORES];
229 #endif
230 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
231 int shutdownInitiated;
232 }
233 VSsSemEnv;
236 typedef struct _TransListElem TransListElem;
237 struct _TransListElem
238 {
239 int32 transID;
240 TransListElem *nextTrans;
241 };
242 //TransListElem
244 enum VSsSlvType
245 { ExtraTaskSlv = 1,
246 SlotTaskSlv,
247 ThreadSlv
248 };
250 typedef struct
251 {
252 int32 highestTransEntered;
253 TransListElem *lastTransEntered;
254 bool32 needsTaskAssigned;
255 VSsTaskStub *taskStub;
256 enum VSsSlvType slaveType;
257 }
258 VSsSemData;
260 //===========================================================================
262 void
263 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
265 int32
266 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
268 void
269 VSs__start_primitive();
271 int32
272 VSs__end_primitive_and_give_cycles();
274 int32
275 VSs__giveIdealNumWorkUnits();
277 int32
278 VSs__give_number_of_cores_to_schedule_onto();
280 //=======================
282 void
283 VSs__init();
285 void
286 VSs__cleanup_after_shutdown();
288 //=======================
290 SlaveVP *
291 VSs__create_thread( TopLevelFnPtr fnPtr, void *initData,
292 SlaveVP *creatingThd );
294 void
295 VSs__end_thread( SlaveVP *thdToEnd );
297 //=======================
299 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
301 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
304 //=======================
305 void
306 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
308 inline int32 *
309 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
311 void
312 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID,
313 SlaveVP *animSlv);
315 void
316 VSs__end_task( SlaveVP *animSlv );
318 //=========================
319 void
320 VSs__taskwait(SlaveVP *animSlv);
323 inline int32 *
324 VSs__give_self_taskID( SlaveVP *animSlv );
326 void
327 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
328 SlaveVP *senderSlv );
330 void
331 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
333 void *
334 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
336 void *
337 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
339 //======================= Concurrency Stuff ======================
340 void
341 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
343 void
344 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
346 void
347 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
349 void
350 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
352 void
353 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
354 void *data, SlaveVP *animSlv );
356 void
357 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
359 void
360 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
363 //========================= Internal use only =============================
364 void
365 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
367 SlaveVP *
368 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
370 SlaveVP*
371 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
372 VSsSemEnv *semEnv, int32 coreToAssignOnto );
374 VSsTaskStub *
375 create_thread_task_stub( void *initData );
378 SlaveVP *
379 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
380 SlaveVP *creatingSlv );
382 SlaveVP *
383 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
384 SlaveVP *creatingSlv, int32 coreToAssignOnto);
386 void
387 idle_fn(void* data, SlaveVP *animatingSlv);
389 //===================== Measurement of Lang Overheads =====================
390 #include "Measurement/VSs_Measurement.h"
392 //===========================================================================
393 #endif /* _VSs_H */
