view SSR.h @ 39:6a367b5d9a2d

Separate UCC recording from VMS core and put it into SSR plugin
author Nina Engelhardt
date Mon, 05 Dec 2011 19:00:51 +0100
parents 2c146b6b3890
children bde026832af7
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 Dependency** ctlDependencies;
112 PrivDynArrayInfo* ctlDependenciesInfo;
113 Dependency** commDependencies;
114 PrivDynArrayInfo* commDependenciesInfo;
115 //NtoN structure?
116 #endif
118 }
119 SSRSemEnv;
122 typedef struct _TransListElem TransListElem;
123 struct _TransListElem
124 {
125 int32 transID;
126 TransListElem *nextTrans;
127 };
128 //TransListElem
130 typedef struct
131 {
132 int32 highestTransEntered;
133 TransListElem *lastTransEntered;
134 }
135 SSRSemData;
137 //===========================================================================
139 void
140 SSR__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
142 int32
143 SSR__giveMinWorkUnitCycles( float32 percentOverhead );
145 void
146 SSR__start_primitive();
148 int32
149 SSR__end_primitive_and_give_cycles();
151 int32
152 SSR__giveIdealNumWorkUnits();
154 int32
155 SSR__give_number_of_cores_to_schedule_onto();
157 //=======================
159 void
160 SSR__init();
162 void
163 SSR__cleanup_after_shutdown();
165 //=======================
167 VirtProcr *
168 SSR__create_procr_with( VirtProcrFnPtr fnPtr, void *initData,
169 VirtProcr *creatingPr );
171 VirtProcr *
172 SSR__create_procr_with_affinity( VirtProcrFnPtr fnPtr, void *initData,
173 VirtProcr *creatingPr, int32 coreToScheduleOnto);
175 void
176 SSR__dissipate_procr( VirtProcr *procrToDissipate );
178 //=======================
179 void *
180 SSR__malloc_to( int numBytes, VirtProcr *ownerPr );
182 void
183 SSR__free( void *ptrToFree, VirtProcr *owningPr );
185 void
186 SSR__transfer_ownership_of_from_to( void *data, VirtProcr *oldOwnerPr,
187 VirtProcr *newOwnerPr );
189 void
190 SSR__add_ownership_by_to( VirtProcr *newOwnerPr, void *data );
192 void
193 SSR__remove_ownership_by_from( VirtProcr *loserPr, void *dataLosing );
195 void
196 SSR__transfer_ownership_to_outside( void *dataToTransferOwnershipOf );
200 //=======================
201 void
202 SSR__send_of_type_to( VirtProcr *sendPr, void *msg, const int type,
203 VirtProcr *receivePr);
205 void
206 SSR__send_from_to( void *msg, VirtProcr *sendPr, VirtProcr *receivePr);
208 void *
209 SSR__receive_type_to( const int type, VirtProcr *receivePr );
211 void *
212 SSR__receive_from_to( VirtProcr *sendPr, VirtProcr *receivePr );
215 //======================= Concurrency Stuff ======================
216 void
217 SSR__start_fn_singleton( int32 singletonID, VirtProcr *animPr );
219 void
220 SSR__end_fn_singleton( int32 singletonID, VirtProcr *animPr );
222 void
223 SSR__start_data_singleton( SSRSingleton **singeltonAddr, VirtProcr *animPr );
225 void
226 SSR__end_data_singleton( SSRSingleton **singletonAddr, VirtProcr *animPr );
228 void
229 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
230 void *data, VirtProcr *animPr );
232 void
233 SSR__start_transaction( int32 transactionID, VirtProcr *animPr );
235 void
236 SSR__end_transaction( int32 transactionID, VirtProcr *animPr );
239 //========================= Internal use only =============================
240 void
241 SSR__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
243 VirtProcr *
244 SSR__schedule_virt_procr( void *_semEnv, int coreNum );
246 VirtProcr*
247 SSR__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData,
248 SSRSemEnv *semEnv, int32 coreToScheduleOnto );
250 #endif /* _SSR_H */