view VSs.h @ 17:f83fff8bd4b2

finished instrumentation
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Fri, 31 Aug 2012 18:24:03 +0200
parents 1ffd5df22df9
children c9606ea7abc8
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 Unit lastWriter;
67 ListOfArrays* readersSinceLastWriter;
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 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
87 Unit parentUnit;
88 #endif
89 }
90 VSsTaskStub;
93 typedef struct
94 {
95 VSsTaskStub *taskStub;
96 int32 argNum;
97 int32 isReader;
98 }
99 VSsTaskStubCarrier;
102 /*Semantic layer-specific data sent inside a request from lib called in app
103 * to request handler called in AnimationMaster
104 */
106 typedef struct
107 {
108 SlaveVP *VPCurrentlyExecuting;
109 PrivQueueStruc *waitingVPQ;
110 }
111 VSsTrans;
113 /*WARNING: assembly hard-codes position of endInstrAddr as first field
114 */
115 typedef struct
116 {
117 void *endInstrAddr;
118 int32 hasBeenStarted;
119 int32 hasFinished;
120 PrivQueueStruc *waitQ;
121 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
122 Unit executingUnit;
123 #endif
124 }
125 VSsSingleton;
127 enum VSsReqType
128 {
129 submit_task = 1,
130 end_task,
131 create_slave,
132 create_slave_w_aff,
133 dissipate_slave,
134 //===============================
135 send_type_to,
136 receive_type_to,
137 send_from_to,
138 receive_from_to,
139 //===============================
140 taskwait,
141 malloc_req,
142 free_req,
143 singleton_fn_start,
144 singleton_fn_end,
145 singleton_data_start,
146 singleton_data_end,
147 atomic,
148 trans_start,
149 trans_end
150 };
152 struct _VSsSemReq
153 { enum VSsReqType reqType;
154 SlaveVP *callingSlv;
155 VSsTaskType *taskType;
156 void *args;
157 VSsTaskStub *taskStub;
159 SlaveVP *senderSlv;
160 SlaveVP *receiverSlv;
161 int32 *senderID;
162 int32 *receiverID;
163 int32 msgType;
164 void *msg;
165 VSsSemReq *nextReqInHashEntry;
166 int32 *taskID;
168 TopLevelFnPtr fnPtr;
169 void *initData;
170 int32 coreToAssignOnto;
172 int32 sizeToMalloc;
173 void *ptrToFree;
175 int32 singletonID;
176 VSsSingleton **singletonPtrAddr;
178 PtrToAtomicFn fnToExecInMaster;
179 void *dataForFn;
181 int32 transID;
182 }
183 /* VSsSemReq */;
186 typedef struct
187 {
188 PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned)
189 PrivQueueStruc *freeExtraTaskSlvQ; //Shared
190 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned)
191 SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
192 HashTable *argPtrHashTbl;
193 HashTable *commHashTbl;
194 int32 numLiveExtraTaskSlvs;
195 int32 numLiveThreadSlvs;
196 int32 nextCoreToGetNewSlv;
197 int32 primitiveStartTime;
199 //fix limit on num with dynArray
200 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
201 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
203 bool32 *coreIsDone;
204 int32 numCoresDone;
206 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
207 ListOfArrays* unitList;
208 ListOfArrays* ctlDependenciesList;
209 ListOfArrays* commDependenciesList;
210 ListOfArrays* dataDependenciesList;
211 ListOfArrays* warDependenciesList;
212 NtoN** ntonGroups;
213 PrivDynArrayInfo* ntonGroupsInfo;
214 ListOfArrays* dynDependenciesList;
215 ListOfArrays* singletonDependenciesList;
216 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
217 ListOfArrays* hwArcs;
218 #endif
220 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
221 ListOfArrays* counterList[NUM_CORES];
222 #endif
223 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
224 int shutdownInitiated;
225 }
226 VSsSemEnv;
229 typedef struct _TransListElem TransListElem;
230 struct _TransListElem
231 {
232 int32 transID;
233 TransListElem *nextTrans;
234 };
235 //TransListElem
237 enum VSsSlvType
238 { ExtraTaskSlv = 1,
239 SlotTaskSlv,
240 ThreadSlv
241 };
243 typedef struct
244 {
245 int32 highestTransEntered;
246 TransListElem *lastTransEntered;
247 bool32 needsTaskAssigned;
248 VSsTaskStub *taskStub;
249 enum VSsSlvType slaveType;
250 }
251 VSsSemData;
253 //===========================================================================
255 void
256 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
258 int32
259 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
261 void
262 VSs__start_primitive();
264 int32
265 VSs__end_primitive_and_give_cycles();
267 int32
268 VSs__giveIdealNumWorkUnits();
270 int32
271 VSs__give_number_of_cores_to_schedule_onto();
273 //=======================
275 void
276 VSs__init();
278 void
279 VSs__cleanup_after_shutdown();
281 //=======================
283 SlaveVP *
284 VSs__create_thread( TopLevelFnPtr fnPtr, void *initData,
285 SlaveVP *creatingThd );
287 void
288 VSs__end_thread( SlaveVP *thdToEnd );
290 //=======================
292 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
294 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
297 //=======================
298 void
299 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
301 inline int32 *
302 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
304 void
305 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID,
306 SlaveVP *animSlv);
308 void
309 VSs__end_task( SlaveVP *animSlv );
311 //=========================
312 void
313 VSs__taskwait(SlaveVP *animSlv);
316 inline int32 *
317 VSs__give_self_taskID( SlaveVP *animSlv );
319 void
320 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
321 SlaveVP *senderSlv );
323 void
324 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
326 void *
327 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
329 void *
330 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
332 //======================= Concurrency Stuff ======================
333 void
334 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
336 void
337 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
339 void
340 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
342 void
343 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
345 void
346 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
347 void *data, SlaveVP *animSlv );
349 void
350 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
352 void
353 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
356 //========================= Internal use only =============================
357 void
358 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
360 SlaveVP *
361 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
363 SlaveVP*
364 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
365 VSsSemEnv *semEnv, int32 coreToAssignOnto );
367 VSsTaskStub *
368 create_thread_task_stub( void *initData );
371 SlaveVP *
372 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
373 SlaveVP *creatingSlv );
375 SlaveVP *
376 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
377 SlaveVP *creatingSlv, int32 coreToAssignOnto);
379 void
380 idle_fn(void* data, SlaveVP *animatingSlv);
382 //===================== Measurement of Lang Overheads =====================
383 #include "Measurement/VSs_Measurement.h"
385 //===========================================================================
386 #endif /* _VSs_H */