Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
view VSs.h @ 2:f2ed1c379fe7
code nearly complete.. about to begin debugging
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Wed, 30 May 2012 15:02:38 -0700 |
| parents | 5ed4d833506e |
| children | 468b8638ff92 |
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 "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 * ); //executed atomically in master
33 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
34 //===========================================================================
36 #define IN 1
37 #define OUT 2
38 #define INOUT 3
40 #define READER 1
41 #define WRITER 2
43 typedef struct
44 {
45 VSsTaskFnPtr fn;
46 int32 numTotalArgs;//the number of inputs to function
47 int32 numCtldArgs;//how many of args have dependencies
48 int32 *argTypes; //says reader, writer, or non-ctld
49 int32 *argSizes; //for detecting overlap
50 int32 sizeOfArgs; //for memcpy of args struct
51 }
52 VSsTaskType;
55 typedef struct
56 {
57 void **args; //ctld args must come first, as ptrs
58 VSsTaskType *taskType;
59 int32 numBlockingProp;
60 SlaveVP *slaveAssignedTo;
61 }
62 VSsTaskStub;
64 typedef struct
65 {
66 VSsTaskStub *taskStub;
67 int32 argNum;
68 int32 isReader;
69 }
70 VSsTaskStubCarrier;
72 typedef struct
73 {
74 bool32 hasEnabledNonFinishedWriter;
75 int32 numEnabledNonDoneReaders;
76 PrivQStruct *waitersQ;
77 }
78 VSsPointerEntry;
81 typedef struct
82 {
83 int32 type;
84 VSsTaskStub *taskStub;
85 }
86 VSsWaiterCarrier;
88 /*Semantic layer-specific data sent inside a request from lib called in app
89 * to request handler called in AnimationMaster
90 */
92 typedef struct
93 {
94 SlaveVP *VPCurrentlyExecuting;
95 PrivQueueStruc *waitingVPQ;
96 }
97 VSsTrans;
99 /*WARNING: assembly hard-codes position of endInstrAddr as first field
100 */
101 typedef struct
102 {
103 void *endInstrAddr;
104 int32 hasBeenStarted;
105 int32 hasFinished;
106 PrivQueueStruc *waitQ;
107 }
108 VSsSingleton;
110 enum VSsReqType
111 {
112 submit_task = 1,
113 end_task,
114 create_slave,
115 create_slave_w_aff,
116 dissipate_slave,
117 //===============================
118 malloc_req,
119 free_req,
120 singleton_fn_start,
121 singleton_fn_end,
122 singleton_data_start,
123 singleton_data_end,
124 atomic,
125 trans_start,
126 trans_end
127 };
129 struct _VSsSemReq
130 { enum VSsReqType reqType;
131 SlaveVP *callingSlv;
132 VSsTaskType *taskType;
133 void *args;
134 VSsTaskStub *taskStub;
136 TopLevelFnPtr fnPtr;
137 void *initData;
138 int32 coreToAssignOnto;
140 int32 sizeToMalloc;
141 void *ptrToFree;
143 int32 singletonID;
144 VSsSingleton **singletonPtrAddr;
146 PtrToAtomicFn fnToExecInMaster;
147 void *dataForFn;
149 int32 transID;
150 }
151 /* VSsSemReq */;
154 typedef struct
155 {
156 PrivQueueStruc **readyVPQs;
157 PrivQueueStruc *taskReadyQ; //Q: shared or local?
158 HashTable *argPtrHashTbl;
159 int32 numSlaveVP;
160 int32 nextCoreToGetNewPr;
161 int32 primitiveStartTime;
163 //fix limit on num with dynArray
164 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
165 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
167 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
168 ListOfArrays* unitList;
169 ListOfArrays* ctlDependenciesList;
170 ListOfArrays* commDependenciesList;
171 NtoN** ntonGroups;
172 PrivDynArrayInfo* ntonGroupsInfo;
173 ListOfArrays* dynDependenciesList;
174 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
175 ListOfArrays* hwArcs;
176 #endif
178 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
179 ListOfArrays* counterList[NUM_CORES];
180 #endif
181 SlaveVP* idlePr[NUM_CORES][NUM_ANIM_SLOTS];
182 int shutdownInitiated;
183 }
184 VSsSemEnv;
187 typedef struct _TransListElem TransListElem;
188 struct _TransListElem
189 {
190 int32 transID;
191 TransListElem *nextTrans;
192 };
193 //TransListElem
195 typedef struct
196 {
197 int32 highestTransEntered;
198 TransListElem *lastTransEntered;
199 bool32 needsTaskAssigned;
200 VSsTaskStub *taskStub;
201 }
202 VSsSemData;
204 //===========================================================================
206 void
207 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
209 int32
210 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
212 void
213 VSs__start_primitive();
215 int32
216 VSs__end_primitive_and_give_cycles();
218 int32
219 VSs__giveIdealNumWorkUnits();
221 int32
222 VSs__give_number_of_cores_to_schedule_onto();
224 //=======================
226 void
227 VSs__init();
229 void
230 VSs__cleanup_after_shutdown();
232 //=======================
234 SlaveVP *
235 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
236 SlaveVP *creatingSlv );
238 SlaveVP *
239 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
240 SlaveVP *creatingPr, int32 coreToAssignOnto);
242 void
243 VSs__dissipate_slave( SlaveVP *slaveToDissipate );
245 //=======================
247 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
249 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
252 //=======================
253 int32
254 VSs__submit_task( VSsTaskType *taskType, void **args, SlaveVP *animSlv);
257 void
258 VSs__end_task( SlaveVP *animSlv );
261 //======================= Concurrency Stuff ======================
262 void
263 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
265 void
266 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
268 void
269 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
271 void
272 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
274 void
275 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
276 void *data, SlaveVP *animSlv );
278 void
279 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
281 void
282 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
285 //========================= Internal use only =============================
286 void
287 VSs__Request_Handler( SlaveVP *requestingPr, void *_semEnv );
289 SlaveVP *
290 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
292 SlaveVP*
293 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
294 VSsSemEnv *semEnv, int32 coreToAssignOnto );
296 //===================== Measurement of Lang Overheads =====================
297 #include "VSs_Measurement.h"
299 //===========================================================================
300 #endif /* _VSs_H */
