view VSs.h @ 21:feea343d202f

add support for more OmpSs features
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Mon, 29 Oct 2012 16:57:56 +0100
parents a7ca8f45c1c4
children b787a5234406
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 Unit firstOfTask;
96 #endif
97 }
98 VSsTaskStub;
101 typedef struct
102 {
103 VSsTaskStub *taskStub;
104 int32 argNum;
105 int32 isReader;
106 bool32 isSuspended;
107 }
108 VSsTaskStubCarrier;
111 /*Semantic layer-specific data sent inside a request from lib called in app
112 * to request handler called in AnimationMaster
113 */
115 typedef struct
116 {
117 SlaveVP *VPCurrentlyExecuting;
118 PrivQueueStruc *waitingVPQ;
119 }
120 VSsTrans;
122 /*WARNING: assembly hard-codes position of endInstrAddr as first field
123 */
124 typedef struct
125 {
126 void *endInstrAddr;
127 int32 hasBeenStarted;
128 int32 hasFinished;
129 PrivQueueStruc *waitQ;
130 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
131 Unit executingUnit;
132 #endif
133 }
134 VSsSingleton;
136 typedef struct
137 {
138 int32 isOccupied;
139 PrivQueueStruc *waitQ;
140 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
141 Unit previous;
142 #endif
143 }
144 VSsCritical;
146 enum VSsReqType
147 {
148 submit_task = 1,
149 end_task,
150 create_slave,
151 create_slave_w_aff,
152 dissipate_slave,
153 //===============================
154 send_type_to,
155 receive_type_to,
156 send_from_to,
157 receive_from_to,
158 //===============================
159 taskwait,
160 taskwait_on,
161 critical_start,
162 critical_end,
163 malloc_req,
164 free_req,
165 singleton_fn_start,
166 singleton_fn_end,
167 singleton_data_start,
168 singleton_data_end,
169 atomic,
170 trans_start,
171 trans_end
172 };
174 struct _VSsSemReq
175 { enum VSsReqType reqType;
176 SlaveVP *callingSlv;
177 VSsTaskType *taskType;
178 void *args;
179 VSsTaskStub *taskStub;
181 SlaveVP *senderSlv;
182 SlaveVP *receiverSlv;
183 int32 *senderID;
184 int32 *receiverID;
185 int32 msgType;
186 void *msg;
187 VSsSemReq *nextReqInHashEntry;
188 int32 *taskID;
190 TopLevelFnPtr fnPtr;
191 void *initData;
192 int32 coreToAssignOnto;
194 int32 sizeToMalloc;
195 void *ptrToFree;
197 int32 singletonID;
198 VSsSingleton **singletonPtrAddr;
200 PtrToAtomicFn fnToExecInMaster;
201 void *dataForFn;
203 int32 transID;
204 int32 criticalID;
205 }
206 /* VSsSemReq */;
209 typedef struct
210 {
211 PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned)
212 PrivQueueStruc *freeExtraTaskSlvQ; //Shared
213 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned)
214 SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
215 HashTable *argPtrHashTbl;
216 HashTable *commHashTbl;
217 int32 numLiveExtraTaskSlvs;
218 int32 numLiveThreadSlvs;
219 int32 nextCoreToGetNewSlv;
220 int32 primitiveStartTime;
222 //fix limit on num with dynArray
223 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
224 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
225 VSsCritical criticalSection[NUM_STRUCS_IN_SEM_ENV];
227 bool32 *coreIsDone;
228 int32 numCoresDone;
230 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
231 ListOfArrays* unitList;
232 ListOfArrays* ctlDependenciesList;
233 ListOfArrays* commDependenciesList;
234 ListOfArrays* dataDependenciesList;
235 ListOfArrays* warDependenciesList;
236 NtoN** ntonGroups;
237 PrivDynArrayInfo* ntonGroupsInfo;
238 ListOfArrays* dynDependenciesList;
239 ListOfArrays* singletonDependenciesList;
240 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
241 ListOfArrays* hwArcs;
242 #endif
244 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
245 ListOfArrays* counterList[NUM_CORES];
246 #endif
247 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
248 int shutdownInitiated;
249 }
250 VSsSemEnv;
253 typedef struct _TransListElem TransListElem;
254 struct _TransListElem
255 {
256 int32 transID;
257 TransListElem *nextTrans;
258 };
259 //TransListElem
261 enum VSsSlvType
262 { ExtraTaskSlv = 1,
263 SlotTaskSlv,
264 ThreadSlv
265 };
267 typedef struct
268 {
269 int32 highestTransEntered;
270 TransListElem *lastTransEntered;
271 bool32 needsTaskAssigned;
272 VSsTaskStub *taskStub;
273 enum VSsSlvType slaveType;
274 }
275 VSsSemData;
277 //===========================================================================
279 void
280 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
282 int32
283 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
285 void
286 VSs__start_primitive();
288 int32
289 VSs__end_primitive_and_give_cycles();
291 int32
292 VSs__giveIdealNumWorkUnits();
294 int32
295 VSs__give_number_of_cores_to_schedule_onto();
297 //=======================
299 void
300 VSs__init();
302 void
303 VSs__cleanup_after_shutdown();
305 //=======================
307 SlaveVP *
308 VSs__create_thread( TopLevelFnPtr fnPtr, void *initData,
309 SlaveVP *creatingThd );
311 void
312 VSs__end_thread( SlaveVP *thdToEnd );
314 //=======================
316 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
318 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
321 //=======================
322 void
323 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
325 int32 *
326 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
328 void
329 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID,
330 SlaveVP *animSlv);
332 void
333 VSs__end_task( SlaveVP *animSlv );
335 //=========================
336 void
337 VSs__taskwait(SlaveVP *animSlv);
339 void
340 VSs__taskwait_on(SlaveVP *animSlv,void* ptr);
342 void
343 VSs__start_critical(SlaveVP *animSlv,int32 name);
345 void
346 VSs__end_critical(SlaveVP *animSlv,int32 name);
348 int32 *
349 VSs__give_self_taskID( SlaveVP *animSlv );
351 void
352 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
353 SlaveVP *senderSlv );
355 void
356 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
358 void *
359 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
361 void *
362 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
364 //======================= Concurrency Stuff ======================
365 void
366 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
368 void
369 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
371 void
372 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
374 void
375 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
377 void
378 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
379 void *data, SlaveVP *animSlv );
381 void
382 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
384 void
385 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
388 //========================= Internal use only =============================
389 void
390 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
392 SlaveVP *
393 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
395 SlaveVP*
396 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
397 VSsSemEnv *semEnv, int32 coreToAssignOnto );
399 VSsTaskStub *
400 create_thread_task_stub( void *initData );
403 SlaveVP *
404 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
405 SlaveVP *creatingSlv );
407 SlaveVP *
408 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
409 SlaveVP *creatingSlv, int32 coreToAssignOnto);
411 void
412 idle_fn(void* data, SlaveVP *animatingSlv);
414 void
415 resume_slaveVP(SlaveVP *slave, VSsSemEnv *semEnv);
417 //===================== Measurement of Lang Overheads =====================
418 #include "Measurement/VSs_Measurement.h"
420 //===========================================================================
421 #endif /* _VSs_H */