view SSR.h @ 28:b37c38418637

changed memory allocation to distributed version
author Merten Sach <msach@mailbox.tu-berlin.de>
date Thu, 22 Sep 2011 12:01:22 +0200
parents a8e41e0bfa61
children 6a367b5d9a2d
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"
17 //===========================================================================
18 #define NUM_STRUCS_IN_SEM_ENV 1000
20 //===========================================================================
21 /*This header defines everything specific to the SSR semantic plug-in
22 */
23 typedef struct _SSRSemReq SSRSemReq;
24 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
25 //===========================================================================
27 /*Semantic layer-specific data sent inside a request from lib called in app
28 * to request handler called in MasterLoop
29 */
31 typedef struct
32 {
33 VirtProcr *VPCurrentlyExecuting;
34 PrivQueueStruc *waitingVPQ;
35 }
36 SSRTrans;
38 /*WARNING: assembly hard-codes position of endInstrAddr as first field
39 */
40 typedef struct
41 {
42 void *endInstrAddr;
43 int32 hasBeenStarted;
44 int32 hasFinished;
45 PrivQueueStruc *waitQ;
46 }
47 SSRSingleton;
49 enum SSRReqType
50 {
51 send_type = 1,
52 send_from_to,
53 receive_any, //order and grouping matter -- send before receive
54 receive_type, // and receive_any first of the receives -- Handlers
55 receive_from_to,// rely upon this ordering of enum
56 transfer_to,
57 transfer_out,
58 malloc_req,
59 free_req,
60 singleton_fn_start,
61 singleton_fn_end,
62 singleton_data_start,
63 singleton_data_end,
64 atomic,
65 trans_start,
66 trans_end
67 };
69 struct _SSRSemReq
70 { enum SSRReqType reqType;
71 VirtProcr *sendPr;
72 VirtProcr *receivePr;
73 int32 msgType;
74 void *msg;
75 SSRSemReq *nextReqInHashEntry;
77 void *initData;
78 VirtProcrFnPtr fnPtr;
79 int32 coreToScheduleOnto;
81 int32 sizeToMalloc;
82 void *ptrToFree;
84 int32 singletonID;
85 SSRSingleton **singletonPtrAddr;
87 PtrToAtomicFn fnToExecInMaster;
88 void *dataForFn;
90 int32 transID;
91 }
92 /* SSRSemReq */;
95 typedef struct
96 {
97 PrivQueueStruc **readyVPQs;
98 HashTable *commHashTbl;
99 int32 numVirtPr;
100 int32 nextCoreToGetNewPr;
101 int32 primitiveStartTime;
103 //fix limit on num with dynArray
104 SSRSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
105 SSRTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
106 }
107 SSRSemEnv;
110 typedef struct _TransListElem TransListElem;
111 struct _TransListElem
112 {
113 int32 transID;
114 TransListElem *nextTrans;
115 };
116 //TransListElem
118 typedef struct
119 {
120 int32 highestTransEntered;
121 TransListElem *lastTransEntered;
122 }
123 SSRSemData;
125 //===========================================================================
127 void
128 SSR__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
130 int32
131 SSR__giveMinWorkUnitCycles( float32 percentOverhead );
133 void
134 SSR__start_primitive();
136 int32
137 SSR__end_primitive_and_give_cycles();
139 int32
140 SSR__giveIdealNumWorkUnits();
142 int32
143 SSR__give_number_of_cores_to_schedule_onto();
145 //=======================
147 void
148 SSR__init();
150 void
151 SSR__cleanup_after_shutdown();
153 //=======================
155 VirtProcr *
156 SSR__create_procr_with( VirtProcrFnPtr fnPtr, void *initData,
157 VirtProcr *creatingPr );
159 VirtProcr *
160 SSR__create_procr_with_affinity( VirtProcrFnPtr fnPtr, void *initData,
161 VirtProcr *creatingPr, int32 coreToScheduleOnto);
163 void
164 SSR__dissipate_procr( VirtProcr *procrToDissipate );
166 //=======================
167 void *
168 SSR__malloc_to( int numBytes, VirtProcr *ownerPr );
170 void
171 SSR__free( void *ptrToFree, VirtProcr *owningPr );
173 void
174 SSR__transfer_ownership_of_from_to( void *data, VirtProcr *oldOwnerPr,
175 VirtProcr *newOwnerPr );
177 void
178 SSR__add_ownership_by_to( VirtProcr *newOwnerPr, void *data );
180 void
181 SSR__remove_ownership_by_from( VirtProcr *loserPr, void *dataLosing );
183 void
184 SSR__transfer_ownership_to_outside( void *dataToTransferOwnershipOf );
188 //=======================
189 void
190 SSR__send_of_type_to( VirtProcr *sendPr, void *msg, const int type,
191 VirtProcr *receivePr);
193 void
194 SSR__send_from_to( void *msg, VirtProcr *sendPr, VirtProcr *receivePr);
196 void *
197 SSR__receive_type_to( const int type, VirtProcr *receivePr );
199 void *
200 SSR__receive_from_to( VirtProcr *sendPr, VirtProcr *receivePr );
203 //======================= Concurrency Stuff ======================
204 void
205 SSR__start_fn_singleton( int32 singletonID, VirtProcr *animPr );
207 void
208 SSR__end_fn_singleton( int32 singletonID, VirtProcr *animPr );
210 void
211 SSR__start_data_singleton( SSRSingleton **singeltonAddr, VirtProcr *animPr );
213 void
214 SSR__end_data_singleton( SSRSingleton **singletonAddr, VirtProcr *animPr );
216 void
217 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
218 void *data, VirtProcr *animPr );
220 void
221 SSR__start_transaction( int32 transactionID, VirtProcr *animPr );
223 void
224 SSR__end_transaction( int32 transactionID, VirtProcr *animPr );
227 //========================= Internal use only =============================
228 void
229 SSR__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
231 VirtProcr *
232 SSR__schedule_virt_procr( void *_semEnv, int coreNum );
234 VirtProcr*
235 SSR__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData,
236 SSRSemEnv *semEnv, int32 coreToScheduleOnto );
238 #endif /* _SSR_H */