Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
view VSs.h @ 28:91caa8a9d591
Back to compile process, fixing compile errors
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Tue, 05 Feb 2013 20:24:25 -0800 |
| parents | 3b30da4643d1 |
| children | dd1efbf29ff9 |
line source
1 /*
2 * Copyright 2009 OpenSourceResearchInstitute.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 "PR_impl/PR.h"
15 #include "Measurement/dependency.h"
18 //===========================================================================
19 //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32
20 #define VSs_MAGIC_NUMBER 0000000001
22 #define NUM_STRUCS_IN_LANG_ENV 1000
24 //This is hardware dependent -- it's the number of cycles of scheduling
25 // overhead -- if a work unit is fewer than this, it is better being
26 // combined sequentially with other work
27 //This value depends on both PR overhead and VSs's plugin. At some point
28 // it will be derived by perf-counter measurements during init of VSs
29 #define MIN_WORK_UNIT_CYCLES 20000
31 //===========================================================================
32 /*This header defines everything specific to the VSs semantic plug-in
33 */
34 typedef struct _VSsLangReq VSsLangReq;
35 typedef struct _VSsTaskStub VSsTaskStub;
36 typedef void (*VSsTaskFnPtr ) ( void *, SlaveVP *);
37 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
38 //===========================================================================
40 #define NONCTLD 0
41 #define IN 1 /*Trick -- READER same as IN*/
42 #define OUT 2 /*Trick -- WRITER same as OUT and INOUT*/
43 #define INOUT 2 /*Trick -- WRITER same as OUT and INOUT*/
45 #define READER 1 /*Trick -- READER same as IN*/
46 #define WRITER 2 /*Trick -- WRITER same as OUT and INOUT*/
48 #define IS_A_THREAD NULL
49 #define IS_ENDED NULL
50 #define SEED_SLV NULL
52 #define NO_ID NULL
53 #define ANY_CORE -1
55 //===========================================================================
56 typedef struct
57 {
58 VSsTaskFnPtr fn;
59 int32 numTotalArgs;//the number of inputs to function
60 int32 numCtldArgs;//how many of args have dependencies
61 int32 *argTypes; //says reader, writer, or non-ctld
62 int32 *argSizes; //for detecting overlap
63 int32 sizeOfArgs; //for memcpy of args struct
64 }
65 VSsTaskType;
68 typedef struct
69 {
70 bool32 hasEnabledNonFinishedWriter;
71 int32 numEnabledNonDoneReaders;
72 PrivQueueStruc *waitersQ;
73 }
74 VSsPointerEntry;
76 /*This is placed into langData, used for dependencies and wait construct*/
77 struct _VSsTaskStub
78 {
79 //====== The first fields must match PRLangMetaTask fields ======
80 int32 langMagicNumber; //magic num must be 1st field of langMetaTask
81 PRMetaTask *protoMetaTask; //back-link must always be 2nd field
82 //====== end PRLangMetaTask fields =========
83 void **args; //ctld args must be the first ones (as ptrs)
84 VSsPointerEntry **ptrEntries;
85 int32 numBlockingProp;
87 VSsTaskType *taskType; //has VSs lang related info
89 VSsTaskStub *parentTaskStub; //for liveness, for the wait construct
90 int32 numLiveChildTasks;
91 int32 numLiveChildThreads;
92 bool32 isWaitingForChildTasksToEnd;
93 bool32 isWaitingForChildThreadsToEnd;
94 bool32 isEnded;
95 };
98 typedef struct
99 {
100 VSsTaskStub *taskStub;
101 int32 argNum;
102 int32 isReader;
103 }
104 VSsTaskStubCarrier;
107 /*Semantic layer-specific data sent inside a request from lib called in app
108 * to request handler called in AnimationMaster
109 */
111 typedef struct
112 {
113 SlaveVP *VPCurrentlyExecuting;
114 PrivQueueStruc *waitingVPQ;
115 }
116 VSsTrans;
118 /*WARNING: assembly hard-codes position of endInstrAddr as first field
119 */
120 typedef struct
121 {
122 void *endInstrAddr;
123 int32 hasBeenStarted;
124 int32 hasFinished;
125 PrivQueueStruc *waitQ;
126 }
127 VSsSingleton;
129 enum VSsReqType
130 {
131 submit_task = 1,
132 end_task,
133 create_slave,
134 create_slave_w_aff,
135 dissipate_slave,
136 //===============================
137 send_type_to,
138 receive_type_to,
139 send_from_to,
140 receive_from_to,
141 //===============================
142 taskwait,
143 malloc_req,
144 free_req,
145 singleton_fn_start,
146 singleton_fn_end,
147 singleton_data_start,
148 singleton_data_end,
149 atomic,
150 trans_start,
151 trans_end
152 };
154 struct _VSsLangReq
155 { enum VSsReqType reqType;
156 SlaveVP *callingSlv;
157 VSsTaskType *taskType;
158 void *args;
159 // VSsTaskStub *taskStub; //not needed -- get via PR accessor from slv
161 SlaveVP *senderSlv;
162 SlaveVP *receiverSlv;
163 int32 *senderID;
164 int32 *receiverID;
165 int32 msgType;
166 void *msg;
167 VSsLangReq *nextReqInHashEntry;
168 //In PRReq: int32 *taskID;
170 TopLevelFnPtr fnPtr;
171 void *initData;
172 int32 coreToAssignOnto;
174 //These, below, should move to util language..
175 int32 sizeToMalloc;
176 void *ptrToFree;
178 int32 singletonID;
179 VSsSingleton **singletonPtrAddr;
181 PtrToAtomicFn fnToExecInMaster;
182 void *dataForFn;
184 int32 transID;
185 }
186 /* VSsLangReq */;
189 typedef struct
190 {
191 PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned)
192 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned)
194 HashTable *argPtrHashTbl;
195 HashTable *commHashTbl;
196 int32 nextCoreToGetNewSlv;
197 int32 primitiveStartTime;
199 //fix limit on num with dynArray
200 VSsSingleton fnSingletons[NUM_STRUCS_IN_LANG_ENV];
201 VSsTrans transactionStrucs[NUM_STRUCS_IN_LANG_ENV];
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 }
218 VSsLangEnv;
221 typedef struct _TransListElem TransListElem;
222 struct _TransListElem
223 {
224 int32 transID;
225 TransListElem *nextTrans;
226 };
227 //TransListElem
229 /* PR now handles what this used to be used for
230 enum VSsSlvType
231 { FreeTaskSlv = 1,
232 SlotTaskSlv,
233 ThreadSlv
234 };
235 */
237 typedef struct
238 {
239 int32 highestTransEntered;
240 TransListElem *lastTransEntered;
241 int32 primitiveStartTime;
242 // VSsTaskStub *taskStub; //get from slave via PR accessor
243 }
244 VSsLangData;
246 //===========================================================================
248 void
249 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
251 int32
252 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
254 void
255 VSs__begin_primitive();
257 int32
258 VSs__end_primitive_and_give_cycles();
260 int32
261 VSs__giveIdealNumWorkUnits();
263 int32
264 VSs__give_number_of_cores_to_schedule_onto();
266 //=======================
268 void
269 VSs__start( SlaveVP *seedSlv );
271 void
272 VSs__cleanup_after_shutdown();
274 //=======================
276 SlaveVP *
277 VSs__create_thread( TopLevelFnPtr fnPtr, void *initData,
278 SlaveVP *creatingThd );
280 void
281 VSs__end_thread( SlaveVP *thdToEnd );
283 //=======================
285 #define VSs__malloc( numBytes, callingSlave ) PR_App__malloc( numBytes, callingSlave)
287 #define VSs__free(ptrToFree, callingSlave ) PR_App__free( ptrToFree, callingSlave )
290 //=======================
291 void
292 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
294 inline int32 *
295 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
297 void
298 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID,
299 SlaveVP *animSlv);
301 void
302 VSs__end_task( SlaveVP *animSlv );
304 //=========================
305 void
306 VSs__taskwait(SlaveVP *animSlv);
309 inline int32 *
310 VSs__give_self_taskID( SlaveVP *animSlv );
312 void
313 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
314 SlaveVP *senderSlv );
316 void
317 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
319 void *
320 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
322 void *
323 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
325 //======================= Concurrency Stuff ======================
326 void
327 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
329 void
330 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
332 void
333 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
335 void
336 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
338 void
339 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
340 void *data, SlaveVP *animSlv );
342 void
343 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
345 void
346 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
349 //========================= Internal use only =============================
350 void
351 VSs__Request_Handler( SlaveVP *requestingSlv, void *_langEnv );
353 SlaveVP *
354 VSs__assign_work_to_slot( void *_langEnv, AnimSlot *slot );
356 SlaveVP*
357 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
358 VSsLangEnv *langEnv, int32 coreToAssignOnto );
360 SlaveVP *
361 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
362 SlaveVP *creatingSlv );
364 SlaveVP *
365 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
366 SlaveVP *creatingSlv, int32 coreToAssignOnto);
368 //===================== =====================
370 #include "VSs_Request_Handlers.h"
372 //===================== Measurement of Lang Overheads =====================
373 #include "Measurement/VSs_Measurement.h"
375 //===========================================================================
376 #endif /* _VSs_H */
