view SSR.h @ 46:bde026832af7

switch dependencies to ListOfArrays
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Mon, 19 Dec 2011 17:15:10 +0100
parents 6a367b5d9a2d
children 23bcca1c3687
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 _SSR_H
10 #define _SSR_H
12 #include "VMS/Queue_impl/PrivateQueue.h"
13 #include "VMS/Hash_impl/PrivateHash.h"
14 #include "VMS/VMS.h"
15 #include "dependency.h"
18 //===========================================================================
19 #define NUM_STRUCS_IN_SEM_ENV 1000
21 //===========================================================================
22 /*This header defines everything specific to the SSR semantic plug-in
23 */
24 typedef struct _SSRSemReq SSRSemReq;
25 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
26 //===========================================================================
28 /*Semantic layer-specific data sent inside a request from lib called in app
29 * to request handler called in MasterLoop
30 */
32 typedef struct
33 {
34 VirtProcr *VPCurrentlyExecuting;
35 PrivQueueStruc *waitingVPQ;
36 }
37 SSRTrans;
39 /*WARNING: assembly hard-codes position of endInstrAddr as first field
40 */
41 typedef struct
42 {
43 void *endInstrAddr;
44 int32 hasBeenStarted;
45 int32 hasFinished;
46 PrivQueueStruc *waitQ;
47 }
48 SSRSingleton;
50 enum SSRReqType
51 {
52 send_type = 1,
53 send_from_to,
54 receive_any, //order and grouping matter -- send before receive
55 receive_type, // and receive_any first of the receives -- Handlers
56 receive_from_to,// rely upon this ordering of enum
57 transfer_to,
58 transfer_out,
59 malloc_req,
60 free_req,
61 singleton_fn_start,
62 singleton_fn_end,
63 singleton_data_start,
64 singleton_data_end,
65 atomic,
66 trans_start,
67 trans_end
68 };
70 struct _SSRSemReq
71 { enum SSRReqType reqType;
72 VirtProcr *sendPr;
73 VirtProcr *receivePr;
74 int32 msgType;
75 void *msg;
76 SSRSemReq *nextReqInHashEntry;
78 void *initData;
79 VirtProcrFnPtr fnPtr;
80 int32 coreToScheduleOnto;
82 int32 sizeToMalloc;
83 void *ptrToFree;
85 int32 singletonID;
86 SSRSingleton **singletonPtrAddr;
88 PtrToAtomicFn fnToExecInMaster;
89 void *dataForFn;
91 int32 transID;
92 }
93 /* SSRSemReq */;
96 typedef struct
97 {
98 PrivQueueStruc **readyVPQs;
99 HashTable *commHashTbl;
100 int32 numVirtPr;
101 int32 nextCoreToGetNewPr;
102 int32 primitiveStartTime;
104 //fix limit on num with dynArray
105 SSRSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
106 SSRTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
108 #ifdef OBSERVE_UCC
109 Unit*** unitcollection;
110 PrivDynArrayInfo* unitcollectionInfo;
111 ListOfArrays* ctlDependenciesList;
112 ListOfArrays* commDependenciesList;
113 //NtoN structure?
114 #endif
116 }
117 SSRSemEnv;
120 typedef struct _TransListElem TransListElem;
121 struct _TransListElem
122 {
123 int32 transID;
124 TransListElem *nextTrans;
125 };
126 //TransListElem
128 typedef struct
129 {
130 int32 highestTransEntered;
131 TransListElem *lastTransEntered;
132 }
133 SSRSemData;
135 //===========================================================================
137 void
138 SSR__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
140 int32
141 SSR__giveMinWorkUnitCycles( float32 percentOverhead );
143 void
144 SSR__start_primitive();
146 int32
147 SSR__end_primitive_and_give_cycles();
149 int32
150 SSR__giveIdealNumWorkUnits();
152 int32
153 SSR__give_number_of_cores_to_schedule_onto();
155 //=======================
157 void
158 SSR__init();
160 void
161 SSR__cleanup_after_shutdown();
163 //=======================
165 VirtProcr *
166 SSR__create_procr_with( VirtProcrFnPtr fnPtr, void *initData,
167 VirtProcr *creatingPr );
169 VirtProcr *
170 SSR__create_procr_with_affinity( VirtProcrFnPtr fnPtr, void *initData,
171 VirtProcr *creatingPr, int32 coreToScheduleOnto);
173 void
174 SSR__dissipate_procr( VirtProcr *procrToDissipate );
176 //=======================
177 void *
178 SSR__malloc_to( int numBytes, VirtProcr *ownerPr );
180 void
181 SSR__free( void *ptrToFree, VirtProcr *owningPr );
183 void
184 SSR__transfer_ownership_of_from_to( void *data, VirtProcr *oldOwnerPr,
185 VirtProcr *newOwnerPr );
187 void
188 SSR__add_ownership_by_to( VirtProcr *newOwnerPr, void *data );
190 void
191 SSR__remove_ownership_by_from( VirtProcr *loserPr, void *dataLosing );
193 void
194 SSR__transfer_ownership_to_outside( void *dataToTransferOwnershipOf );
198 //=======================
199 void
200 SSR__send_of_type_to( VirtProcr *sendPr, void *msg, const int type,
201 VirtProcr *receivePr);
203 void
204 SSR__send_from_to( void *msg, VirtProcr *sendPr, VirtProcr *receivePr);
206 void *
207 SSR__receive_type_to( const int type, VirtProcr *receivePr );
209 void *
210 SSR__receive_from_to( VirtProcr *sendPr, VirtProcr *receivePr );
213 //======================= Concurrency Stuff ======================
214 void
215 SSR__start_fn_singleton( int32 singletonID, VirtProcr *animPr );
217 void
218 SSR__end_fn_singleton( int32 singletonID, VirtProcr *animPr );
220 void
221 SSR__start_data_singleton( SSRSingleton **singeltonAddr, VirtProcr *animPr );
223 void
224 SSR__end_data_singleton( SSRSingleton **singletonAddr, VirtProcr *animPr );
226 void
227 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
228 void *data, VirtProcr *animPr );
230 void
231 SSR__start_transaction( int32 transactionID, VirtProcr *animPr );
233 void
234 SSR__end_transaction( int32 transactionID, VirtProcr *animPr );
237 //========================= Internal use only =============================
238 void
239 SSR__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
241 VirtProcr *
242 SSR__schedule_virt_procr( void *_semEnv, int coreNum );
244 VirtProcr*
245 SSR__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData,
246 SSRSemEnv *semEnv, int32 coreToScheduleOnto );
248 #endif /* _SSR_H */