rev |
line source |
msach@6
|
1 /*
|
msach@6
|
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
|
msach@6
|
3 * Licensed under GNU General Public License version 2
|
msach@6
|
4 *
|
msach@6
|
5 * Author: seanhalle@yahoo.com
|
msach@6
|
6 *
|
msach@6
|
7 */
|
msach@6
|
8
|
msach@6
|
9 #ifndef _VCilk_H
|
msach@6
|
10 #define _VCilk_H
|
msach@6
|
11
|
msach@6
|
12 #include "VMS/Queue_impl/PrivateQueue.h"
|
msach@6
|
13 #include "VMS/Hash_impl/PrivateHash.h"
|
msach@6
|
14 #include "VMS/VMS.h"
|
msach@6
|
15
|
msach@6
|
16
|
msach@6
|
17
|
msach@6
|
18 /*This header defines everything specific to the VCilk semantic plug-in
|
msach@6
|
19 */
|
msach@6
|
20
|
msach@6
|
21 //===========================================================================
|
msach@6
|
22 #define NUM_STRUCS_IN_SEM_ENV 1000
|
msach@6
|
23
|
msach@6
|
24 //===========================================================================
|
msach@6
|
25 typedef struct _VCilkSemReq VCilkSemReq;
|
msach@6
|
26 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
|
msach@6
|
27
|
msach@6
|
28 //===========================================================================
|
msach@6
|
29
|
msach@6
|
30
|
msach@6
|
31 /*WARNING: assembly hard-codes position of endInstrAddr as first field
|
msach@6
|
32 */
|
msach@6
|
33 typedef struct
|
msach@6
|
34 {
|
msach@6
|
35 void *endInstrAddr;
|
msach@6
|
36 int32 hasBeenStarted;
|
msach@6
|
37 int32 hasFinished;
|
msach@6
|
38 PrivQueueStruc *waitQ;
|
msach@6
|
39 }
|
msach@6
|
40 VCilkSingleton;
|
msach@6
|
41
|
msach@6
|
42 /*Semantic layer-specific data sent inside a request from lib called in app
|
msach@6
|
43 * to request handler called in MasterLoop
|
msach@6
|
44 */
|
msach@6
|
45 enum VCilkReqType
|
msach@6
|
46 {
|
msach@6
|
47 syncReq = 1,
|
msach@6
|
48 mallocReq,
|
msach@6
|
49 freeReq,
|
msach@6
|
50 singleton_fn_start,
|
msach@6
|
51 singleton_fn_end,
|
msach@6
|
52 singleton_data_start,
|
msach@6
|
53 singleton_data_end,
|
msach@6
|
54 atomic,
|
msach@6
|
55 trans_start,
|
msach@6
|
56 trans_end
|
msach@6
|
57 };
|
msach@6
|
58
|
msach@6
|
59 struct _VCilkSemReq
|
msach@6
|
60 { enum VCilkReqType reqType;
|
msach@6
|
61 VirtProcr *requestingPr;
|
msach@6
|
62
|
msach@6
|
63 int32 sizeToMalloc;
|
msach@6
|
64 void *ptrToFree;
|
msach@6
|
65
|
msach@6
|
66 VirtProcrFnPtr fnPtr;
|
msach@6
|
67 void *initData;
|
msach@6
|
68 int32 coreToSpawnOnto;
|
msach@6
|
69
|
msach@6
|
70 int32 singletonID;
|
msach@6
|
71 VCilkSingleton **singletonPtrAddr;
|
msach@6
|
72
|
msach@6
|
73 PtrToAtomicFn fnToExecInMaster;
|
msach@6
|
74 void *dataForFn;
|
msach@6
|
75
|
msach@6
|
76 int32 transID;
|
msach@6
|
77 }
|
msach@6
|
78 /* VCilkSemReq */;
|
msach@6
|
79
|
msach@6
|
80 typedef struct
|
msach@6
|
81 {
|
msach@6
|
82 VirtProcr *VPCurrentlyExecuting;
|
msach@6
|
83 PrivQueueStruc *waitingVPQ;
|
msach@6
|
84 }
|
msach@6
|
85 VCilkTrans;
|
msach@6
|
86
|
msach@6
|
87 typedef struct
|
msach@6
|
88 {
|
msach@6
|
89 PrivQueueStruc **readyVPQs;
|
msach@6
|
90 HashTable *commHashTbl;
|
msach@6
|
91 int32 numVirtPr;
|
msach@6
|
92 int32 nextCoreToGetNewPr;
|
msach@6
|
93 int32 primitiveStartTime;
|
msach@6
|
94
|
msach@6
|
95 //fix limit on num with dynArray
|
msach@6
|
96 VCilkSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
|
msach@6
|
97 VCilkTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
|
msach@6
|
98 }
|
msach@6
|
99 VCilkSemEnv;
|
msach@6
|
100
|
msach@6
|
101 typedef struct _TransListElem TransListElem;
|
msach@6
|
102 struct _TransListElem
|
msach@6
|
103 {
|
msach@6
|
104 int32 transID;
|
msach@6
|
105 TransListElem *nextTrans;
|
msach@6
|
106 };
|
msach@6
|
107 //TransListElem
|
msach@6
|
108
|
msach@6
|
109 typedef struct
|
msach@6
|
110 {
|
msach@6
|
111 int32 syncPending;
|
msach@6
|
112 int32 numLiveChildren;
|
msach@6
|
113 VirtProcr *parentPr;
|
msach@6
|
114
|
msach@6
|
115 int32 highestTransEntered;
|
msach@6
|
116 TransListElem *lastTransEntered;
|
msach@6
|
117 }
|
msach@6
|
118 VCilkSemData;
|
msach@6
|
119
|
msach@6
|
120 //===========================================================================
|
msach@6
|
121
|
msach@6
|
122 void
|
msach@6
|
123 VCilk__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
|
msach@6
|
124
|
msach@6
|
125 int32
|
msach@6
|
126 VCilk__giveMinWorkUnitCycles( float32 percentOverhead );
|
msach@6
|
127
|
msach@6
|
128 void inline
|
msach@6
|
129 VCilk__start_primitive();
|
msach@6
|
130
|
msach@6
|
131 int32 inline
|
msach@6
|
132 VCilk__end_primitive_and_give_cycles();
|
msach@6
|
133
|
msach@6
|
134 int32
|
msach@6
|
135 VCilk__giveIdealNumWorkUnits();
|
msach@6
|
136
|
msach@6
|
137 //=======================
|
msach@6
|
138
|
msach@6
|
139 void
|
msach@6
|
140 VCilk__init();
|
msach@6
|
141
|
msach@6
|
142 void
|
msach@6
|
143 VCilk__cleanup_at_end_of_shutdown();
|
msach@6
|
144
|
msach@6
|
145 //=======================
|
msach@6
|
146
|
msach@6
|
147 void inline
|
msach@6
|
148 VCilk__spawn( int32 coreToSpawnOnto, VirtProcrFnPtr fnPtr,
|
msach@6
|
149 void *initData, VirtProcr *creatingPr );
|
msach@6
|
150
|
msach@6
|
151 int32
|
msach@6
|
152 VCilk__give_number_of_cores_to_spawn_onto();
|
msach@6
|
153
|
msach@6
|
154 void
|
msach@6
|
155 VCilk__sync( VirtProcr *animatingPr );
|
msach@6
|
156
|
msach@6
|
157 void *
|
msach@6
|
158 VCilk__malloc( int32 sizeToMalloc, VirtProcr *animPr );
|
msach@6
|
159
|
msach@6
|
160 void
|
msach@6
|
161 VCilk__free( void *ptrToFree, VirtProcr *animPr );
|
msach@6
|
162
|
msach@6
|
163 void
|
msach@6
|
164 VCilk__dissipate_procr( VirtProcr *procrToDissipate );
|
msach@6
|
165
|
msach@6
|
166
|
msach@6
|
167 //======================= Concurrency Stuff ======================
|
msach@6
|
168 void
|
msach@6
|
169 VCilk__start_fn_singleton( int32 singletonID, VirtProcr *animPr );
|
msach@6
|
170
|
msach@6
|
171 void
|
msach@6
|
172 VCilk__end_fn_singleton( int32 singletonID, VirtProcr *animPr );
|
msach@6
|
173
|
msach@6
|
174 void
|
msach@6
|
175 VCilk__start_data_singleton( VCilkSingleton **singeltonAddr, VirtProcr *animPr );
|
msach@6
|
176
|
msach@6
|
177 void
|
msach@6
|
178 VCilk__end_data_singleton( VCilkSingleton **singletonAddr, VirtProcr *animPr );
|
msach@6
|
179
|
msach@6
|
180 void
|
msach@6
|
181 VCilk__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
|
msach@6
|
182 void *data, VirtProcr *animPr );
|
msach@6
|
183
|
msach@6
|
184 void
|
msach@6
|
185 VCilk__start_transaction( int32 transactionID, VirtProcr *animPr );
|
msach@6
|
186
|
msach@6
|
187 void
|
msach@6
|
188 VCilk__end_transaction( int32 transactionID, VirtProcr *animPr );
|
msach@6
|
189
|
msach@6
|
190
|
msach@6
|
191 //========================= Internal use only =============================
|
msach@6
|
192 void
|
msach@6
|
193 VCilk__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
|
msach@6
|
194
|
msach@6
|
195 VirtProcr *
|
msach@6
|
196 VCilk__schedule_virt_procr( void *_semEnv, int coreNum );
|
msach@6
|
197
|
msach@6
|
198
|
msach@6
|
199 #endif /* _VCilk_H */
|
msach@6
|
200
|