Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
view VSs.h @ 10:b13fbd445e0a
Compiles and some bugs corrected.. still does double free of taskStub
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Fri, 17 Aug 2012 17:12:50 -0700 |
| parents | 832bc715fbf2 |
| children | f56e3beac86b |
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 }
66 VSsPointerEntry;
68 typedef struct
69 {
70 void **args; //ctld args must come first, as ptrs
71 VSsTaskType *taskType;
72 int32 *taskID;
73 int32 numBlockingProp;
74 SlaveVP *slaveAssignedTo; //only valid before end task (thread)
75 VSsPointerEntry **ptrEntries;
77 void* parentTasksStub;
78 int32 numLiveChildTasks;
79 int32 numLiveChildThreads;
80 bool32 isWaitingForChildTasksToEnd;
81 bool32 isWaitingForChildThreadsToEnd;
82 bool32 isEnded;
83 }
84 VSsTaskStub;
87 typedef struct
88 {
89 VSsTaskStub *taskStub;
90 int32 argNum;
91 int32 isReader;
92 }
93 VSsTaskStubCarrier;
96 typedef struct
97 {
98 int32 type;
99 VSsTaskStub *taskStub;
100 }
101 VSsWaiterCarrier;
103 /*Semantic layer-specific data sent inside a request from lib called in app
104 * to request handler called in AnimationMaster
105 */
107 typedef struct
108 {
109 SlaveVP *VPCurrentlyExecuting;
110 PrivQueueStruc *waitingVPQ;
111 }
112 VSsTrans;
114 /*WARNING: assembly hard-codes position of endInstrAddr as first field
115 */
116 typedef struct
117 {
118 void *endInstrAddr;
119 int32 hasBeenStarted;
120 int32 hasFinished;
121 PrivQueueStruc *waitQ;
122 }
123 VSsSingleton;
125 enum VSsReqType
126 {
127 submit_task = 1,
128 end_task,
129 create_slave,
130 create_slave_w_aff,
131 dissipate_slave,
132 //===============================
133 send_type_to,
134 receive_type_to,
135 send_from_to,
136 receive_from_to,
137 //===============================
138 taskwait,
139 malloc_req,
140 free_req,
141 singleton_fn_start,
142 singleton_fn_end,
143 singleton_data_start,
144 singleton_data_end,
145 atomic,
146 trans_start,
147 trans_end
148 };
150 struct _VSsSemReq
151 { enum VSsReqType reqType;
152 SlaveVP *callingSlv;
153 VSsTaskType *taskType;
154 void *args;
155 VSsTaskStub *taskStub;
157 SlaveVP *senderSlv;
158 SlaveVP *receiverSlv;
159 int32 *senderID;
160 int32 *receiverID;
161 int32 msgType;
162 void *msg;
163 VSsSemReq *nextReqInHashEntry;
164 int32 *taskID;
166 TopLevelFnPtr fnPtr;
167 void *initData;
168 int32 coreToAssignOnto;
170 int32 sizeToMalloc;
171 void *ptrToFree;
173 int32 singletonID;
174 VSsSingleton **singletonPtrAddr;
176 PtrToAtomicFn fnToExecInMaster;
177 void *dataForFn;
179 int32 transID;
180 }
181 /* VSsSemReq */;
184 typedef struct
185 {
186 PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned)
187 PrivQueueStruc *freeExtraTaskSlvQ; //Shared
188 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned)
189 SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
190 HashTable *argPtrHashTbl;
191 HashTable *commHashTbl;
192 int32 numLiveExtraTaskSlvs;
193 int32 numLiveThreadSlvs;
194 int32 nextCoreToGetNewSlv;
195 int32 primitiveStartTime;
197 //fix limit on num with dynArray
198 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
199 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
201 bool32 *coreIsDone;
202 int32 numCoresDone;
204 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
205 ListOfArrays* unitList;
206 ListOfArrays* ctlDependenciesList;
207 ListOfArrays* commDependenciesList;
208 NtoN** ntonGroups;
209 PrivDynArrayInfo* ntonGroupsInfo;
210 ListOfArrays* dynDependenciesList;
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 */
