VMS/VMS_Implementations/SSR_impls/SSR__MC_shared_impl

view SSR.h @ 84:ce07f1a42ddf

Added skeleton for data tracking assigner + design notes
author Sean Halle <seanhalle@yahoo.com>
date Thu, 10 Jan 2013 11:16:42 -0800
parents 494703aecda2
children
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 _SSR_H
10 #define _SSR_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 //#define IDLE_SLAVES
23 //This is hardware dependent -- it's the number of cycles of scheduling
24 // overhead -- if a work unit is fewer than this, it is better being
25 // combined sequentially with other work
26 //This value depends on both VMS overhead and SSR's plugin. At some point
27 // it will be derived by perf-counter measurements during init of SSR
28 #define MIN_WORK_UNIT_CYCLES 20000
30 //===========================================================================
31 /*This header defines everything specific to the SSR semantic plug-in
32 */
33 typedef struct _SSRSemReq SSRSemReq;
34 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
35 //===========================================================================
37 /*Semantic layer-specific data sent inside a request from lib called in app
38 * to request handler called in AnimationMaster
39 */
41 typedef struct
42 {
43 SlaveVP *VPCurrentlyExecuting;
44 PrivQueueStruc *waitingVPQ;
45 }
46 SSRTrans;
48 /*WARNING: assembly hard-codes position of endInstrAddr as first field
49 */
50 typedef struct
51 {
52 void *endInstrAddr;
53 int32 hasBeenStarted;
54 int32 hasFinished;
55 PrivQueueStruc *waitQ;
56 int executingVp;
57 int executingTask;
58 }
59 SSRSingleton;
61 enum SSRReqType
62 {
63 send_type = 1,
64 send_from_to,
65 receive_any, //order and grouping matter -- send before receive
66 receive_type, // and receive_any first of the receives -- Handlers
67 receive_from_to,// rely upon this ordering of enum
68 transfer_to,
69 transfer_out,
70 malloc_req,
71 free_req,
72 singleton_fn_start,
73 singleton_fn_end,
74 singleton_data_start,
75 singleton_data_end,
76 atomic,
77 trans_start,
78 trans_end
79 };
81 struct _SSRSemReq
82 { enum SSRReqType reqType;
83 SlaveVP *sendPr;
84 SlaveVP *receivePr;
85 int32 msgType;
86 void *msg;
87 SSRSemReq *nextReqInHashEntry;
89 void *initData;
90 TopLevelFnPtr fnPtr;
91 int32 coreToAssignOnto;
93 int32 sizeToMalloc;
94 void *ptrToFree;
96 int32 singletonID;
97 SSRSingleton **singletonPtrAddr;
99 PtrToAtomicFn fnToExecInMaster;
100 void *dataForFn;
102 int32 transID;
103 }
104 /* SSRSemReq */;
107 typedef struct
108 {
109 PrivQueueStruc **readyVPQs;
110 HashTable *commHashTbl;
111 int32 numSlaveVP;
112 int32 nextCoreToGetNewPr;
113 int32 primitiveStartTime;
115 //fix limit on num with dynArray
116 SSRSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
117 SSRTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
119 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
120 ListOfArrays* unitList;
121 ListOfArrays* ctlDependenciesList;
122 ListOfArrays* commDependenciesList;
123 NtoN** ntonGroups;
124 PrivDynArrayInfo* ntonGroupsInfo;
125 ListOfArrays* dynDependenciesList;
126 ListOfArrays* singletonDependenciesList;
127 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
128 ListOfArrays* hwArcs;
129 int lastReqType;
130 #endif
132 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
133 ListOfArrays* counterList[NUM_CORES];
134 #endif
135 #ifdef IDLE_SLAVES
136 SlaveVP* idlePr[NUM_CORES][NUM_ANIM_SLOTS];
137 int shutdownInitiated;
138 #endif
139 }
140 SSRSemEnv;
143 typedef struct _DKUPiece DKUPiece;
145 typedef DKUPiece * (*DKUDividerFn ) ( DKUPiece * );
147 struct _DKUPiece
148 {
149 void *workData;
150 DKUPiece **subPieces;
151 void *infoForUndiv; //app creates own struct and casts
152 };
153 //DKUPiece
155 typedef struct _TransListElem TransListElem;
156 struct _TransListElem
157 {
158 int32 transID;
159 TransListElem *nextTrans;
160 };
161 //TransListElem
163 typedef struct
164 {
165 int32 highestTransEntered;
166 TransListElem *lastTransEntered;
167 }
168 SSRSemData;
170 //===========================================================================
172 void
173 SSR__create_seed_procr_and_do_work( TopLevelFnPtr fn, void *initData );
175 int32
176 SSR__giveMinWorkUnitCycles( float32 percentOverhead );
178 void
179 SSR__start_primitive();
181 int32
182 SSR__end_primitive_and_give_cycles();
184 int32
185 SSR__giveIdealNumWorkUnits();
187 int32
188 SSR__give_number_of_cores_to_schedule_onto();
190 //=======================
192 void
193 SSR__init();
195 void
196 SSR__cleanup_after_shutdown();
198 //=======================
200 SlaveVP *
201 SSR__create_procr_with( TopLevelFnPtr fnPtr, void *initData,
202 SlaveVP *creatingSlv );
204 SlaveVP *
205 SSR__create_procr_with_affinity( TopLevelFnPtr fnPtr, void *initData,
206 SlaveVP *creatingPr, int32 coreToAssignOnto);
208 void
209 SSR__dissipate_procr( SlaveVP *procrToDissipate );
211 //=======================
212 void *
213 SSR__malloc_to( int numBytes, SlaveVP *ownerSlv );
215 void
216 SSR__free( void *ptrToFree, SlaveVP *owningSlv );
218 void
219 SSR__transfer_ownership_of_from_to( void *data, SlaveVP *oldOwnerPr,
220 SlaveVP *newOwnerSlv );
222 void
223 SSR__add_ownership_by_to( SlaveVP *newOwnerPr, void *data );
225 void
226 SSR__remove_ownership_by_from( SlaveVP *loserPr, void *dataLosing );
228 void
229 SSR__transfer_ownership_to_outside( void *dataToTransferOwnershipOf );
233 //=======================
234 void
235 SSR__send_of_type_to( SlaveVP *sendPr, void *msg, const int type,
236 SlaveVP *receivePr);
238 void
239 SSR__send_from_to( void *msg, SlaveVP *sendPr, SlaveVP *receivePr);
241 void *
242 SSR__receive_type_to( const int type, SlaveVP *receiveSlv );
244 void *
245 SSR__receive_from_to( SlaveVP *sendPr, SlaveVP *receiveSlv );
249 //======================= Concurrency Stuff ======================
250 void
251 SSR__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
253 void
254 SSR__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
256 void
257 SSR__start_data_singleton( SSRSingleton **singeltonAddr, SlaveVP *animSlv );
259 void
260 SSR__end_data_singleton( SSRSingleton **singletonAddr, SlaveVP *animSlv );
262 void
263 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
264 void *data, SlaveVP *animSlv );
266 void
267 SSR__start_transaction( int32 transactionID, SlaveVP *animSlv );
269 void
270 SSR__end_transaction( int32 transactionID, SlaveVP *animSlv );
273 //========================= Internal use only =============================
274 void
275 SSR__Request_Handler( SlaveVP *requestingPr, void *_semEnv );
277 SlaveVP *
278 SSR__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
280 SlaveVP*
281 SSR__create_procr_helper( TopLevelFnPtr fnPtr, void *initData,
282 SSRSemEnv *semEnv, int32 coreToAssignOnto );
284 //===================== Measurement of Lang Overheads =====================
285 #include "SSR_Measurement.h"
287 //===========================================================================
288 #endif /* _SSR_H */