VMS/VMS_Implementations/VSs_impls/VSs__MC_shared_impl

view VSs.h @ 5:8188c5b4bfd7

implemented taskwait
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Fri, 13 Jul 2012 17:35:49 +0200
parents 13af59ed7ea5
children 1780f6b00e3d
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 typedef struct
45 {
46 VSsTaskFnPtr fn;
47 int32 numTotalArgs;//the number of inputs to function
48 int32 numCtldArgs;//how many of args have dependencies
49 int32 *argTypes; //says reader, writer, or non-ctld
50 int32 *argSizes; //for detecting overlap
51 int32 sizeOfArgs; //for memcpy of args struct
52 }
53 VSsTaskType;
56 typedef struct
57 {
58 bool32 hasEnabledNonFinishedWriter;
59 int32 numEnabledNonDoneReaders;
60 PrivQueueStruc *waitersQ;
61 }
62 VSsPointerEntry;
64 typedef struct _VSsTaskStub VSsTaskStub;
66 struct _VSsTaskStub
67 {
68 void **args; //ctld args must come first, as ptrs
69 VSsTaskType *taskType;
70 int32 *taskID;
71 int32 numBlockingProp;
72 SlaveVP *slaveAssignedTo;
73 VSsPointerEntry **ptrEntries;
74 void* parent;
75 bool32 parentIsTask;
76 int32 numChildTasks;
77 bool32 isWaiting;
78 }
79 ;
81 typedef struct {
82 void* parent;
83 bool32 parentIsTask;
84 int32 numChildTasks;
85 bool32 isWaiting;
86 SlaveVP *slaveAssignedTo;
87 } VSsThreadInfo;
89 typedef struct
90 {
91 VSsTaskStub *taskStub;
92 int32 argNum;
93 int32 isReader;
94 }
95 VSsTaskStubCarrier;
98 typedef struct
99 {
100 int32 type;
101 VSsTaskStub *taskStub;
102 }
103 VSsWaiterCarrier;
105 /*Semantic layer-specific data sent inside a request from lib called in app
106 * to request handler called in AnimationMaster
107 */
109 typedef struct
110 {
111 SlaveVP *VPCurrentlyExecuting;
112 PrivQueueStruc *waitingVPQ;
113 }
114 VSsTrans;
116 /*WARNING: assembly hard-codes position of endInstrAddr as first field
117 */
118 typedef struct
119 {
120 void *endInstrAddr;
121 int32 hasBeenStarted;
122 int32 hasFinished;
123 PrivQueueStruc *waitQ;
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 **readyVPQs;
189 PrivQueueStruc *taskReadyQ; //Q: shared or local?
190 HashTable *argPtrHashTbl;
191 HashTable *commHashTbl;
192 int32 numSlaveVP;
193 int32 nextCoreToGetNewSlv;
194 int32 primitiveStartTime;
196 //fix limit on num with dynArray
197 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
198 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
200 bool32 *coreIsDone;
201 int32 numCoresDone;
203 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
204 ListOfArrays* unitList;
205 ListOfArrays* ctlDependenciesList;
206 ListOfArrays* commDependenciesList;
207 NtoN** ntonGroups;
208 PrivDynArrayInfo* ntonGroupsInfo;
209 ListOfArrays* dynDependenciesList;
210 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
211 ListOfArrays* hwArcs;
212 #endif
214 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
215 ListOfArrays* counterList[NUM_CORES];
216 #endif
217 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
218 int shutdownInitiated;
219 }
220 VSsSemEnv;
223 typedef struct _TransListElem TransListElem;
224 struct _TransListElem
225 {
226 int32 transID;
227 TransListElem *nextTrans;
228 };
229 //TransListElem
233 typedef struct
234 {
235 int32 highestTransEntered;
236 TransListElem *lastTransEntered;
237 bool32 needsTaskAssigned;
238 VSsTaskStub *taskStub;
239 VSsThreadInfo *threadInfo;
240 }
241 VSsSemData;
243 //===========================================================================
245 void
246 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
248 int32
249 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
251 void
252 VSs__start_primitive();
254 int32
255 VSs__end_primitive_and_give_cycles();
257 int32
258 VSs__giveIdealNumWorkUnits();
260 int32
261 VSs__give_number_of_cores_to_schedule_onto();
263 //=======================
265 void
266 VSs__init();
268 void
269 VSs__cleanup_after_shutdown();
271 //=======================
273 SlaveVP *
274 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
275 SlaveVP *creatingSlv );
277 SlaveVP *
278 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
279 SlaveVP *creatingSlv, int32 coreToAssignOnto);
281 void
282 VSs__dissipate_slave( SlaveVP *slaveToDissipate );
284 //=======================
286 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
288 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
291 //=======================
292 void
293 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
295 inline int32 *
296 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
298 void
299 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID,
300 SlaveVP *animSlv);
302 void
303 VSs__end_task( SlaveVP *animSlv );
305 //=========================
306 void
307 VSs__taskwait(SlaveVP *animSlv);
310 inline int32 *
311 VSs__give_self_taskID( SlaveVP *animSlv );
313 void
314 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
315 SlaveVP *senderSlv );
317 void
318 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
320 void *
321 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
323 void *
324 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
326 //======================= Concurrency Stuff ======================
327 void
328 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
330 void
331 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
333 void
334 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
336 void
337 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
339 void
340 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
341 void *data, SlaveVP *animSlv );
343 void
344 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
346 void
347 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
350 //========================= Internal use only =============================
351 void
352 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
354 SlaveVP *
355 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
357 SlaveVP*
358 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
359 VSsSemEnv *semEnv, int32 coreToAssignOnto );
361 //===================== Measurement of Lang Overheads =====================
362 #include "Measurement/VSs_Measurement.h"
364 //===========================================================================
365 #endif /* _VSs_H */