Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
view VSs.h @ 4:13af59ed7ea5
Works -- with send-receive plus normal dependencies
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Thu, 14 Jun 2012 18:44:47 -0700 |
| parents | 468b8638ff92 |
| children | 8188c5b4bfd7 |
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 }
73 VSsTaskStub;
75 typedef struct
76 {
77 VSsTaskStub *taskStub;
78 int32 argNum;
79 int32 isReader;
80 }
81 VSsTaskStubCarrier;
84 typedef struct
85 {
86 int32 type;
87 VSsTaskStub *taskStub;
88 }
89 VSsWaiterCarrier;
91 /*Semantic layer-specific data sent inside a request from lib called in app
92 * to request handler called in AnimationMaster
93 */
95 typedef struct
96 {
97 SlaveVP *VPCurrentlyExecuting;
98 PrivQueueStruc *waitingVPQ;
99 }
100 VSsTrans;
102 /*WARNING: assembly hard-codes position of endInstrAddr as first field
103 */
104 typedef struct
105 {
106 void *endInstrAddr;
107 int32 hasBeenStarted;
108 int32 hasFinished;
109 PrivQueueStruc *waitQ;
110 }
111 VSsSingleton;
113 enum VSsReqType
114 {
115 submit_task = 1,
116 end_task,
117 create_slave,
118 create_slave_w_aff,
119 dissipate_slave,
120 //===============================
121 send_type_to,
122 receive_type_to,
123 send_from_to,
124 receive_from_to,
125 //===============================
126 malloc_req,
127 free_req,
128 singleton_fn_start,
129 singleton_fn_end,
130 singleton_data_start,
131 singleton_data_end,
132 atomic,
133 trans_start,
134 trans_end
135 };
137 struct _VSsSemReq
138 { enum VSsReqType reqType;
139 SlaveVP *callingSlv;
140 VSsTaskType *taskType;
141 void *args;
142 VSsTaskStub *taskStub;
144 SlaveVP *senderSlv;
145 SlaveVP *receiverSlv;
146 int32 *senderID;
147 int32 *receiverID;
148 int32 msgType;
149 void *msg;
150 VSsSemReq *nextReqInHashEntry;
151 int32 *taskID;
153 TopLevelFnPtr fnPtr;
154 void *initData;
155 int32 coreToAssignOnto;
157 int32 sizeToMalloc;
158 void *ptrToFree;
160 int32 singletonID;
161 VSsSingleton **singletonPtrAddr;
163 PtrToAtomicFn fnToExecInMaster;
164 void *dataForFn;
166 int32 transID;
167 }
168 /* VSsSemReq */;
171 typedef struct
172 {
173 PrivQueueStruc **readyVPQs;
174 PrivQueueStruc *taskReadyQ; //Q: shared or local?
175 HashTable *argPtrHashTbl;
176 HashTable *commHashTbl;
177 int32 numSlaveVP;
178 int32 nextCoreToGetNewSlv;
179 int32 primitiveStartTime;
181 //fix limit on num with dynArray
182 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
183 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
185 bool32 *coreIsDone;
186 int32 numCoresDone;
188 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
189 ListOfArrays* unitList;
190 ListOfArrays* ctlDependenciesList;
191 ListOfArrays* commDependenciesList;
192 NtoN** ntonGroups;
193 PrivDynArrayInfo* ntonGroupsInfo;
194 ListOfArrays* dynDependenciesList;
195 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
196 ListOfArrays* hwArcs;
197 #endif
199 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
200 ListOfArrays* counterList[NUM_CORES];
201 #endif
202 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
203 int shutdownInitiated;
204 }
205 VSsSemEnv;
208 typedef struct _TransListElem TransListElem;
209 struct _TransListElem
210 {
211 int32 transID;
212 TransListElem *nextTrans;
213 };
214 //TransListElem
216 typedef struct
217 {
218 int32 highestTransEntered;
219 TransListElem *lastTransEntered;
220 bool32 needsTaskAssigned;
221 VSsTaskStub *taskStub;
222 }
223 VSsSemData;
225 //===========================================================================
227 void
228 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
230 int32
231 VSs__giveMinWorkUnitCycles( float32 percentOverhead );
233 void
234 VSs__start_primitive();
236 int32
237 VSs__end_primitive_and_give_cycles();
239 int32
240 VSs__giveIdealNumWorkUnits();
242 int32
243 VSs__give_number_of_cores_to_schedule_onto();
245 //=======================
247 void
248 VSs__init();
250 void
251 VSs__cleanup_after_shutdown();
253 //=======================
255 SlaveVP *
256 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
257 SlaveVP *creatingSlv );
259 SlaveVP *
260 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData,
261 SlaveVP *creatingSlv, int32 coreToAssignOnto);
263 void
264 VSs__dissipate_slave( SlaveVP *slaveToDissipate );
266 //=======================
268 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
270 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
273 //=======================
274 void
275 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
277 inline int32 *
278 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
280 void
281 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID,
282 SlaveVP *animSlv);
284 void
285 VSs__end_task( SlaveVP *animSlv );
287 //=========================
289 inline int32 *
290 VSs__give_self_taskID( SlaveVP *animSlv );
292 void
293 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
294 SlaveVP *senderSlv );
296 void
297 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
299 void *
300 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
302 void *
303 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
305 //======================= Concurrency Stuff ======================
306 void
307 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
309 void
310 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
312 void
313 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
315 void
316 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
318 void
319 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
320 void *data, SlaveVP *animSlv );
322 void
323 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
325 void
326 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
329 //========================= Internal use only =============================
330 void
331 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
333 SlaveVP *
334 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
336 SlaveVP*
337 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
338 VSsSemEnv *semEnv, int32 coreToAssignOnto );
340 //===================== Measurement of Lang Overheads =====================
341 #include "Measurement/VSs_Measurement.h"
343 //===========================================================================
344 #endif /* _VSs_H */
