Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
view VSs.h @ 7:3999b8429ddd
Not working -- check point to share changes with Nina
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Wed, 01 Aug 2012 03:16:27 -0700 |
| parents | 1780f6b00e3d |
| children | eb3d77ca9f59 |
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
65 {
66 void **args; //ctld args must come first, as ptrs
67 VSsTaskType *taskType;
68 int32 *taskID;
69 int32 numBlockingProp;
70 SlaveVP *slaveAssignedTo;
71 VSsPointerEntry **ptrEntries;
72 void* parent;
73 bool32 parentIsTask;
74 int32 numChildTasks;
75 bool32 isWaiting;
76 }
77 VSsTaskStub;
79 typedef struct
80 {
81 void* parent;
82 bool32 parentIsTask;
83 int32 numChildTasks;
84 bool32 isWaiting;
85 SlaveVP *slaveAssignedTo;
86 }
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 **slavesReadyToResumeQ; //Shared (slaves not pinned)
189 PrivQueueStruc **extraTaskSlvQ; //Shared
190 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned)
191 SlaveVP *currTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
192 HashTable *argPtrHashTbl;
193 HashTable *commHashTbl;
194 int32 numAdditionalSlvs;
195 int32 nextCoreToGetNewSlv;
196 int32 primitiveStartTime;
198 //fix limit on num with dynArray
199 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
200 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
202 bool32 *coreIsDone;
203 int32 numCoresDone;
205 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
206 ListOfArrays* unitList;
207 ListOfArrays* ctlDependenciesList;
208 ListOfArrays* commDependenciesList;
209 NtoN** ntonGroups;
210 PrivDynArrayInfo* ntonGroupsInfo;
211 ListOfArrays* dynDependenciesList;
212 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
213 ListOfArrays* hwArcs;
214 #endif
216 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
217 ListOfArrays* counterList[NUM_CORES];
218 #endif
219 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
220 int shutdownInitiated;
221 }
222 VSsSemEnv;
225 typedef struct _TransListElem TransListElem;
226 struct _TransListElem
227 {
228 int32 transID;
229 TransListElem *nextTrans;
230 };
231 //TransListElem
235 typedef struct
236 {
237 int32 highestTransEntered;
238 TransListElem *lastTransEntered;
239 bool32 needsTaskAssigned;
240 VSsTaskStub *taskStub;
241 VSsThreadInfo *threadInfo;
242 }
243 VSsSemData;
245 //===========================================================================
247 void
248 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
250 int32
251 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
253 void
254 VSs__start_primitive();
256 int32
257 VSs__end_primitive_and_give_cycles();
259 int32
260 VSs__giveIdealNumWorkUnits();
262 int32
263 VSs__give_number_of_cores_to_schedule_onto();
265 //=======================
267 void
268 VSs__init();
270 void
271 VSs__cleanup_after_shutdown();
273 //=======================
275 SlaveVP *
276 VSs__create_thread( TopLevelFnPtr fnPtr, void *initData,
277 SlaveVP *creatingThd );
279 void
280 VSs__end_thread( SlaveVP *thdToEnd );
282 //=======================
284 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
286 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
289 //=======================
290 void
291 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
293 inline int32 *
294 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
296 void
297 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID,
298 SlaveVP *animSlv);
300 void
301 VSs__end_task( SlaveVP *animSlv );
303 //=========================
304 void
305 VSs__taskwait(SlaveVP *animSlv);
308 inline int32 *
309 VSs__give_self_taskID( SlaveVP *animSlv );
311 void
312 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
313 SlaveVP *senderSlv );
315 void
316 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
318 void *
319 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
321 void *
322 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
324 //======================= Concurrency Stuff ======================
325 void
326 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
328 void
329 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
331 void
332 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
334 void
335 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
337 void
338 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
339 void *data, SlaveVP *animSlv );
341 void
342 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
344 void
345 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
348 //========================= Internal use only =============================
349 void
350 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
352 SlaveVP *
353 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
355 SlaveVP*
356 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
357 VSsSemEnv *semEnv, int32 coreToAssignOnto );
359 VSsTaskStub *
360 create_expl_proc_task_stub( void *initData );
363 SlaveVP *
364 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
365 SlaveVP *creatingSlv );
367 SlaveVP *
368 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
369 SlaveVP *creatingSlv, int32 coreToAssignOnto);
372 //===================== Measurement of Lang Overheads =====================
373 #include "Measurement/VSs_Measurement.h"
375 //===========================================================================
376 #endif /* _VSs_H */
