view VSs.h @ 16:1ffd5df22df9

add CG instrumentation; still missing WaR hazard constraints
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Tue, 28 Aug 2012 15:33:16 +0200
parents b2bc97318262
children f83fff8bd4b2
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 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
66 int lastWriterVP;
67 int lastWriterTask;
68 #endif
69 }
70 VSsPointerEntry;
72 typedef struct
73 {
74 void **args; //ctld args must come first, as ptrs
75 VSsTaskType *taskType;
76 int32 *taskID;
77 int32 numBlockingProp;
78 SlaveVP *slaveAssignedTo; //only valid before end task (thread)
79 VSsPointerEntry **ptrEntries;
80 void* parentTaskStub;
81 int32 numLiveChildTasks;
82 int32 numLiveChildThreads;
83 bool32 isWaitingForChildTasksToEnd;
84 bool32 isWaitingForChildThreadsToEnd;
85 bool32 isEnded;
86 }
87 VSsTaskStub;
90 typedef struct
91 {
92 VSsTaskStub *taskStub;
93 int32 argNum;
94 int32 isReader;
95 }
96 VSsTaskStubCarrier;
99 /*Semantic layer-specific data sent inside a request from lib called in app
100 * to request handler called in AnimationMaster
101 */
103 typedef struct
104 {
105 SlaveVP *VPCurrentlyExecuting;
106 PrivQueueStruc *waitingVPQ;
107 }
108 VSsTrans;
110 /*WARNING: assembly hard-codes position of endInstrAddr as first field
111 */
112 typedef struct
113 {
114 void *endInstrAddr;
115 int32 hasBeenStarted;
116 int32 hasFinished;
117 PrivQueueStruc *waitQ;
118 int executingVp;
119 int executingTask;
120 }
121 VSsSingleton;
123 enum VSsReqType
124 {
125 submit_task = 1,
126 end_task,
127 create_slave,
128 create_slave_w_aff,
129 dissipate_slave,
130 //===============================
131 send_type_to,
132 receive_type_to,
133 send_from_to,
134 receive_from_to,
135 //===============================
136 taskwait,
137 malloc_req,
138 free_req,
139 singleton_fn_start,
140 singleton_fn_end,
141 singleton_data_start,
142 singleton_data_end,
143 atomic,
144 trans_start,
145 trans_end
146 };
148 struct _VSsSemReq
149 { enum VSsReqType reqType;
150 SlaveVP *callingSlv;
151 VSsTaskType *taskType;
152 void *args;
153 VSsTaskStub *taskStub;
155 SlaveVP *senderSlv;
156 SlaveVP *receiverSlv;
157 int32 *senderID;
158 int32 *receiverID;
159 int32 msgType;
160 void *msg;
161 VSsSemReq *nextReqInHashEntry;
162 int32 *taskID;
164 TopLevelFnPtr fnPtr;
165 void *initData;
166 int32 coreToAssignOnto;
168 int32 sizeToMalloc;
169 void *ptrToFree;
171 int32 singletonID;
172 VSsSingleton **singletonPtrAddr;
174 PtrToAtomicFn fnToExecInMaster;
175 void *dataForFn;
177 int32 transID;
178 }
179 /* VSsSemReq */;
182 typedef struct
183 {
184 PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned)
185 PrivQueueStruc *freeExtraTaskSlvQ; //Shared
186 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned)
187 SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
188 HashTable *argPtrHashTbl;
189 HashTable *commHashTbl;
190 int32 numLiveExtraTaskSlvs;
191 int32 numLiveThreadSlvs;
192 int32 nextCoreToGetNewSlv;
193 int32 primitiveStartTime;
195 //fix limit on num with dynArray
196 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
197 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
199 bool32 *coreIsDone;
200 int32 numCoresDone;
202 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
203 ListOfArrays* unitList;
204 ListOfArrays* ctlDependenciesList;
205 ListOfArrays* commDependenciesList;
206 ListOfArrays* dataDependenciesList;
207 NtoN** ntonGroups;
208 PrivDynArrayInfo* ntonGroupsInfo;
209 ListOfArrays* dynDependenciesList;
210 ListOfArrays* singletonDependenciesList;
211 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
212 ListOfArrays* hwArcs;
213 #endif
215 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
216 ListOfArrays* counterList[NUM_CORES];
217 #endif
218 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
219 int shutdownInitiated;
220 }
221 VSsSemEnv;
224 typedef struct _TransListElem TransListElem;
225 struct _TransListElem
226 {
227 int32 transID;
228 TransListElem *nextTrans;
229 };
230 //TransListElem
232 enum VSsSlvType
233 { ExtraTaskSlv = 1,
234 SlotTaskSlv,
235 ThreadSlv
236 };
238 typedef struct
239 {
240 int32 highestTransEntered;
241 TransListElem *lastTransEntered;
242 bool32 needsTaskAssigned;
243 VSsTaskStub *taskStub;
244 enum VSsSlvType slaveType;
245 }
246 VSsSemData;
248 //===========================================================================
250 void
251 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
253 int32
254 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
256 void
257 VSs__start_primitive();
259 int32
260 VSs__end_primitive_and_give_cycles();
262 int32
263 VSs__giveIdealNumWorkUnits();
265 int32
266 VSs__give_number_of_cores_to_schedule_onto();
268 //=======================
270 void
271 VSs__init();
273 void
274 VSs__cleanup_after_shutdown();
276 //=======================
278 SlaveVP *
279 VSs__create_thread( TopLevelFnPtr fnPtr, void *initData,
280 SlaveVP *creatingThd );
282 void
283 VSs__end_thread( SlaveVP *thdToEnd );
285 //=======================
287 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
289 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
292 //=======================
293 void
294 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
296 inline int32 *
297 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
299 void
300 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID,
301 SlaveVP *animSlv);
303 void
304 VSs__end_task( SlaveVP *animSlv );
306 //=========================
307 void
308 VSs__taskwait(SlaveVP *animSlv);
311 inline int32 *
312 VSs__give_self_taskID( SlaveVP *animSlv );
314 void
315 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
316 SlaveVP *senderSlv );
318 void
319 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
321 void *
322 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
324 void *
325 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
327 //======================= Concurrency Stuff ======================
328 void
329 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
331 void
332 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
334 void
335 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
337 void
338 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
340 void
341 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
342 void *data, SlaveVP *animSlv );
344 void
345 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
347 void
348 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
351 //========================= Internal use only =============================
352 void
353 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
355 SlaveVP *
356 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
358 SlaveVP*
359 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
360 VSsSemEnv *semEnv, int32 coreToAssignOnto );
362 VSsTaskStub *
363 create_thread_task_stub( void *initData );
366 SlaveVP *
367 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
368 SlaveVP *creatingSlv );
370 SlaveVP *
371 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
372 SlaveVP *creatingSlv, int32 coreToAssignOnto);
374 void
375 idle_fn(void* data, SlaveVP *animatingSlv);
377 //===================== Measurement of Lang Overheads =====================
378 #include "Measurement/VSs_Measurement.h"
380 //===========================================================================
381 #endif /* _VSs_H */