| rev |
line source |
|
seanhalle@64
|
1 /*
|
|
seanhalle@64
|
2 * Copyright 2010 OpenSourceCodeStewardshipFoundation
|
|
seanhalle@64
|
3 *
|
|
seanhalle@64
|
4 * Licensed under BSD
|
|
seanhalle@64
|
5 */
|
|
seanhalle@64
|
6
|
|
seanhalle@64
|
7 #include <stdio.h>
|
|
seanhalle@64
|
8 #include <stdlib.h>
|
|
seanhalle@64
|
9 #include <malloc.h>
|
|
seanhalle@64
|
10
|
|
seanhalle@64
|
11 #include "Queue_impl/PrivateQueue.h"
|
|
seanhalle@64
|
12 #include "Hash_impl/PrivateHash.h"
|
|
seanhalle@64
|
13
|
|
seanhalle@64
|
14 #include "SSR.h"
|
|
seanhalle@64
|
15 #include "SSR_Counter_Recording.h"
|
|
seanhalle@64
|
16
|
|
seanhalle@64
|
17 //==========================================================================
|
|
seanhalle@64
|
18
|
|
seanhalle@64
|
19 void
|
|
seanhalle@64
|
20 SSR__init();
|
|
seanhalle@64
|
21
|
|
seanhalle@64
|
22 void
|
|
seanhalle@64
|
23 SSR__init_Helper();
|
|
seanhalle@64
|
24 //==========================================================================
|
|
seanhalle@64
|
25
|
|
seanhalle@64
|
26
|
|
seanhalle@64
|
27 /*TODO: Q: dealing with library f()s and DKU vs WT vs FoR
|
|
seanhalle@64
|
28 * (still want to do FoR, with time-lines as syntax, could be super cool)
|
|
seanhalle@64
|
29 * A: thinking pin the coreCtlrs for all of BLIS -- let Master arbitrate
|
|
seanhalle@64
|
30 * among library, DKU, WT, FoR -- all the patterns in terms of virtual
|
|
seanhalle@64
|
31 * processors (or equivalently work-units), so Master picks which virt procr
|
|
seanhalle@67
|
32 * from which portions of app (DKU, WT, FoR) onto which anim slots
|
|
seanhalle@67
|
33 *Might even do hierarchy of masters -- group of anim slots for each core
|
|
seanhalle@64
|
34 * has its own master, that keeps generated work local
|
|
seanhalle@64
|
35 * single-reader-single-writer sync everywhere -- no atomic primitives
|
|
seanhalle@64
|
36 * Might have the different assigners talk to each other, to negotiate
|
|
seanhalle@64
|
37 * larger-grain sharing of resources, according to predicted critical
|
|
seanhalle@64
|
38 * path, and expansion of work
|
|
seanhalle@64
|
39 */
|
|
seanhalle@64
|
40
|
|
seanhalle@64
|
41
|
|
seanhalle@64
|
42
|
|
seanhalle@64
|
43 //===========================================================================
|
|
seanhalle@64
|
44
|
|
seanhalle@64
|
45
|
|
seanhalle@64
|
46 /*These are the library functions *called in the application*
|
|
seanhalle@64
|
47 *
|
|
seanhalle@64
|
48 *There's a pattern for the outside sequential code to interact with the
|
|
seanhalle@64
|
49 * VMS_HW code.
|
|
seanhalle@64
|
50 *The VMS_HW system is inside a boundary.. every SSR system is in its
|
|
seanhalle@64
|
51 * own directory that contains the functions for each of the processor types.
|
|
seanhalle@64
|
52 * One of the processor types is the "seed" processor that starts the
|
|
seanhalle@64
|
53 * cascade of creating all the processors that do the work.
|
|
seanhalle@64
|
54 *So, in the directory is a file called "EntryPoint.c" that contains the
|
|
seanhalle@64
|
55 * function, named appropriately to the work performed, that the outside
|
|
seanhalle@64
|
56 * sequential code calls. This function follows a pattern:
|
|
seanhalle@64
|
57 *1) it calls SSR__init()
|
|
seanhalle@64
|
58 *2) it creates the initial data for the seed processor, which is passed
|
|
seanhalle@64
|
59 * in to the function
|
|
seanhalle@64
|
60 *3) it creates the seed SSR processor, with the data to start it with.
|
|
seanhalle@64
|
61 *4) it calls startSSRThenWaitUntilWorkDone
|
|
seanhalle@64
|
62 *5) it gets the returnValue from the transfer struc and returns that
|
|
seanhalle@64
|
63 * from the function
|
|
seanhalle@64
|
64 *
|
|
seanhalle@64
|
65 *For now, a new SSR system has to be created via SSR__init every
|
|
seanhalle@64
|
66 * time an entry point function is called -- later, might add letting the
|
|
seanhalle@64
|
67 * SSR system be created once, and let all the entry points just reuse
|
|
seanhalle@64
|
68 * it -- want to be as simple as possible now, and see by using what makes
|
|
seanhalle@64
|
69 * sense for later..
|
|
seanhalle@64
|
70 */
|
|
seanhalle@64
|
71
|
|
seanhalle@64
|
72
|
|
seanhalle@64
|
73
|
|
seanhalle@64
|
74 //===========================================================================
|
|
seanhalle@64
|
75
|
|
seanhalle@64
|
76 /*This is the "border crossing" function -- the thing that crosses from the
|
|
seanhalle@64
|
77 * outside world, into the VMS_HW world. It initializes and starts up the
|
|
seanhalle@64
|
78 * VMS system, then creates one processor from the specified function and
|
|
seanhalle@64
|
79 * puts it into the readyQ. From that point, that one function is resp.
|
|
seanhalle@64
|
80 * for creating all the other processors, that then create others, and so
|
|
seanhalle@64
|
81 * forth.
|
|
seanhalle@64
|
82 *When all the processors, including the seed, have dissipated, then this
|
|
seanhalle@64
|
83 * function returns. The results will have been written by side-effect via
|
|
seanhalle@64
|
84 * pointers read from, or written into initData.
|
|
seanhalle@64
|
85 *
|
|
seanhalle@64
|
86 *NOTE: no Threads should exist in the outside program that might touch
|
|
seanhalle@64
|
87 * any of the data reachable from initData passed in to here
|
|
seanhalle@64
|
88 */
|
|
seanhalle@64
|
89 void
|
|
seanhalle@64
|
90 SSR__create_seed_procr_and_do_work( TopLevelFnPtr fnPtr, void *initData )
|
|
seanhalle@64
|
91 { SSRSemEnv *semEnv;
|
|
seanhalle@64
|
92 SlaveVP *seedPr;
|
|
seanhalle@64
|
93
|
|
seanhalle@64
|
94 SSR__init(); //normal multi-thd
|
|
seanhalle@64
|
95
|
|
seanhalle@64
|
96 semEnv = _VMSMasterEnv->semanticEnv;
|
|
seanhalle@64
|
97
|
|
seanhalle@64
|
98 //SSR starts with one processor, which is put into initial environ,
|
|
seanhalle@64
|
99 // and which then calls create() to create more, thereby expanding work
|
|
seanhalle@64
|
100 seedPr = SSR__create_procr_helper( fnPtr, initData,
|
|
seanhalle@64
|
101 semEnv, semEnv->nextCoreToGetNewPr++ );
|
|
seanhalle@64
|
102
|
|
seanhalle@64
|
103 resume_slaveVP( seedPr, semEnv );
|
|
seanhalle@64
|
104
|
|
seanhalle@64
|
105 VMS_SS__start_the_work_then_wait_until_done(); //normal multi-thd
|
|
seanhalle@64
|
106
|
|
seanhalle@64
|
107 SSR__cleanup_after_shutdown();
|
|
seanhalle@64
|
108 }
|
|
seanhalle@64
|
109
|
|
seanhalle@64
|
110
|
|
seanhalle@64
|
111 int32
|
|
seanhalle@64
|
112 SSR__giveMinWorkUnitCycles( float32 percentOverhead )
|
|
seanhalle@64
|
113 {
|
|
seanhalle@64
|
114 return MIN_WORK_UNIT_CYCLES;
|
|
seanhalle@64
|
115 }
|
|
seanhalle@64
|
116
|
|
seanhalle@64
|
117 int32
|
|
seanhalle@64
|
118 SSR__giveIdealNumWorkUnits()
|
|
seanhalle@64
|
119 {
|
|
seanhalle@69
|
120 return NUM_ANIM_SLOTS * NUM_CORES;
|
|
seanhalle@64
|
121 }
|
|
seanhalle@64
|
122
|
|
seanhalle@64
|
123 int32
|
|
seanhalle@64
|
124 SSR__give_number_of_cores_to_schedule_onto()
|
|
seanhalle@64
|
125 {
|
|
seanhalle@64
|
126 return NUM_CORES;
|
|
seanhalle@64
|
127 }
|
|
seanhalle@64
|
128
|
|
seanhalle@64
|
129 /*For now, use TSC -- later, make these two macros with assembly that first
|
|
seanhalle@64
|
130 * saves jump point, and second jumps back several times to get reliable time
|
|
seanhalle@64
|
131 */
|
|
seanhalle@64
|
132 void
|
|
seanhalle@64
|
133 SSR__start_primitive()
|
|
seanhalle@64
|
134 { saveLowTimeStampCountInto( ((SSRSemEnv *)(_VMSMasterEnv->semanticEnv))->
|
|
seanhalle@64
|
135 primitiveStartTime );
|
|
seanhalle@64
|
136 }
|
|
seanhalle@64
|
137
|
|
seanhalle@64
|
138 /*Just quick and dirty for now -- make reliable later
|
|
seanhalle@64
|
139 * will want this to jump back several times -- to be sure cache is warm
|
|
seanhalle@64
|
140 * because don't want comm time included in calc-time measurement -- and
|
|
seanhalle@64
|
141 * also to throw out any "weird" values due to OS interrupt or TSC rollover
|
|
seanhalle@64
|
142 */
|
|
seanhalle@64
|
143 int32
|
|
seanhalle@64
|
144 SSR__end_primitive_and_give_cycles()
|
|
seanhalle@64
|
145 { int32 endTime, startTime;
|
|
seanhalle@64
|
146 //TODO: fix by repeating time-measurement
|
|
seanhalle@64
|
147 saveLowTimeStampCountInto( endTime );
|
|
seanhalle@64
|
148 startTime =((SSRSemEnv*)(_VMSMasterEnv->semanticEnv))->primitiveStartTime;
|
|
seanhalle@64
|
149 return (endTime - startTime);
|
|
seanhalle@64
|
150 }
|
|
seanhalle@64
|
151
|
|
seanhalle@64
|
152 //===========================================================================
|
|
seanhalle@64
|
153
|
|
seanhalle@64
|
154 /*Initializes all the data-structures for a SSR system -- but doesn't
|
|
seanhalle@64
|
155 * start it running yet!
|
|
seanhalle@64
|
156 *
|
|
seanhalle@64
|
157 *This runs in the main thread -- before VMS starts up
|
|
seanhalle@64
|
158 *
|
|
seanhalle@64
|
159 *This sets up the semantic layer over the VMS system
|
|
seanhalle@64
|
160 *
|
|
seanhalle@64
|
161 *First, calls VMS_Setup, then creates own environment, making it ready
|
|
seanhalle@64
|
162 * for creating the seed processor and then starting the work.
|
|
seanhalle@64
|
163 */
|
|
seanhalle@64
|
164 void
|
|
seanhalle@64
|
165 SSR__init()
|
|
seanhalle@64
|
166 {
|
|
seanhalle@64
|
167 VMS_SS__init();
|
|
seanhalle@64
|
168 //masterEnv, a global var, now is partially set up by init_VMS
|
|
seanhalle@64
|
169 // after this, have VMS_int__malloc and VMS_int__free available
|
|
seanhalle@64
|
170
|
|
seanhalle@64
|
171 SSR__init_Helper();
|
|
seanhalle@64
|
172 }
|
|
seanhalle@64
|
173
|
|
seanhalle@64
|
174
|
|
seanhalle@64
|
175 void idle_fn(void* data, SlaveVP *animatingSlv){
|
|
seanhalle@64
|
176 while(1){
|
|
seanhalle@64
|
177 VMS_int__suspend_slaveVP_and_send_req(animatingSlv);
|
|
seanhalle@64
|
178 }
|
|
seanhalle@64
|
179 }
|
|
seanhalle@64
|
180
|
|
seanhalle@64
|
181 void
|
|
seanhalle@64
|
182 SSR__init_Helper()
|
|
seanhalle@64
|
183 { SSRSemEnv *semanticEnv;
|
|
seanhalle@64
|
184 PrivQueueStruc **readyVPQs;
|
|
seanhalle@64
|
185 int coreIdx, i, j;
|
|
seanhalle@64
|
186
|
|
seanhalle@64
|
187 //Hook up the semantic layer's plug-ins to the Master virt procr
|
|
seanhalle@64
|
188 _VMSMasterEnv->requestHandler = &SSR__Request_Handler;
|
|
seanhalle@67
|
189 _VMSMasterEnv->slaveAssigner = &SSR__assign_slaveVP_to_slot;
|
|
seanhalle@64
|
190 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
|
|
seanhalle@64
|
191 _VMSMasterEnv->counterHandler = &SSR__counter_handler;
|
|
seanhalle@64
|
192 #endif
|
|
seanhalle@64
|
193
|
|
seanhalle@64
|
194 //create the semantic layer's environment (all its data) and add to
|
|
seanhalle@64
|
195 // the master environment
|
|
seanhalle@64
|
196 semanticEnv = VMS_int__malloc( sizeof( SSRSemEnv ) );
|
|
seanhalle@64
|
197 _VMSMasterEnv->semanticEnv = semanticEnv;
|
|
seanhalle@64
|
198
|
|
seanhalle@64
|
199 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
|
|
seanhalle@64
|
200 SSR__init_counter_data_structs();
|
|
seanhalle@64
|
201 #endif
|
|
nengel@72
|
202 #ifdef IDLE_SLAVES
|
|
nengel@66
|
203 semanticEnv->shutdownInitiated = FALSE;
|
|
seanhalle@64
|
204 for(i=0;i<NUM_CORES;++i){
|
|
seanhalle@69
|
205 for(j=0;j<NUM_ANIM_SLOTS;++j){
|
|
seanhalle@64
|
206 semanticEnv->idlePr[i][j] = VMS_int__create_slaveVP(&idle_fn,NULL);
|
|
seanhalle@64
|
207 semanticEnv->idlePr[i][j]->coreAnimatedBy = i;
|
|
nengel@72
|
208 semanticEnv->idlePr[i][j]->typeOfVP = Idle;
|
|
seanhalle@64
|
209 }
|
|
seanhalle@64
|
210 }
|
|
nengel@72
|
211 #endif
|
|
seanhalle@64
|
212 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
|
|
seanhalle@64
|
213 semanticEnv->unitList = makeListOfArrays(sizeof(Unit),128);
|
|
seanhalle@64
|
214 semanticEnv->ctlDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
|
seanhalle@64
|
215 semanticEnv->commDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
|
seanhalle@64
|
216 semanticEnv->dynDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
|
nengel@74
|
217 semanticEnv->singletonDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
|
seanhalle@64
|
218 semanticEnv->ntonGroupsInfo = makePrivDynArrayOfSize((void***)&(semanticEnv->ntonGroups),8);
|
|
seanhalle@64
|
219
|
|
seanhalle@64
|
220 semanticEnv->hwArcs = makeListOfArrays(sizeof(Dependency),128);
|
|
seanhalle@69
|
221 memset(semanticEnv->last_in_slot,0,sizeof(NUM_CORES * NUM_ANIM_SLOTS * sizeof(Unit)));
|
|
seanhalle@64
|
222 #endif
|
|
seanhalle@64
|
223
|
|
seanhalle@64
|
224 //create the ready queue, hash tables used for pairing send to receive
|
|
seanhalle@64
|
225 // and so forth
|
|
seanhalle@64
|
226 //TODO: add hash tables for pairing sends with receives, and
|
|
seanhalle@64
|
227 // initialize the data ownership system
|
|
seanhalle@64
|
228 readyVPQs = VMS_int__malloc( NUM_CORES * sizeof(PrivQueueStruc *) );
|
|
seanhalle@64
|
229
|
|
seanhalle@64
|
230 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
|
|
seanhalle@64
|
231 {
|
|
seanhalle@64
|
232 readyVPQs[ coreIdx ] = makeVMSQ();
|
|
seanhalle@64
|
233 }
|
|
seanhalle@64
|
234
|
|
seanhalle@64
|
235 semanticEnv->readyVPQs = readyVPQs;
|
|
seanhalle@64
|
236
|
|
seanhalle@64
|
237 semanticEnv->nextCoreToGetNewPr = 0;
|
|
seanhalle@64
|
238 semanticEnv->numSlaveVP = 0;
|
|
seanhalle@64
|
239
|
|
seanhalle@64
|
240 semanticEnv->commHashTbl = makeHashTable( 1<<16, &VMS_int__free );//start big
|
|
seanhalle@64
|
241
|
|
seanhalle@64
|
242 //TODO: bug -- turn these arrays into dyn arrays to eliminate limit
|
|
seanhalle@64
|
243 //semanticEnv->singletonHasBeenExecutedFlags = makeDynArrayInfo( );
|
|
seanhalle@64
|
244 //semanticEnv->transactionStrucs = makeDynArrayInfo( );
|
|
seanhalle@64
|
245 for( i = 0; i < NUM_STRUCS_IN_SEM_ENV; i++ )
|
|
seanhalle@64
|
246 {
|
|
seanhalle@64
|
247 semanticEnv->fnSingletons[i].endInstrAddr = NULL;
|
|
seanhalle@64
|
248 semanticEnv->fnSingletons[i].hasBeenStarted = FALSE;
|
|
seanhalle@64
|
249 semanticEnv->fnSingletons[i].hasFinished = FALSE;
|
|
seanhalle@64
|
250 semanticEnv->fnSingletons[i].waitQ = makeVMSQ();
|
|
seanhalle@64
|
251 semanticEnv->transactionStrucs[i].waitingVPQ = makeVMSQ();
|
|
seanhalle@64
|
252 }
|
|
seanhalle@84
|
253
|
|
seanhalle@84
|
254 initAssigner( semanticEnv );
|
|
seanhalle@64
|
255 }
|
|
seanhalle@64
|
256
|
|
seanhalle@64
|
257
|
|
seanhalle@64
|
258 /*Frees any memory allocated by SSR__init() then calls VMS_int__shutdown
|
|
seanhalle@64
|
259 */
|
|
seanhalle@64
|
260 void
|
|
seanhalle@64
|
261 SSR__cleanup_after_shutdown()
|
|
seanhalle@64
|
262 { SSRSemEnv *semanticEnv;
|
|
seanhalle@64
|
263
|
|
seanhalle@64
|
264 semanticEnv = _VMSMasterEnv->semanticEnv;
|
|
seanhalle@64
|
265
|
|
seanhalle@64
|
266 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
|
|
seanhalle@64
|
267 //UCC
|
|
seanhalle@64
|
268 FILE* output;
|
|
seanhalle@64
|
269 int n;
|
|
seanhalle@64
|
270 char filename[255];
|
|
seanhalle@64
|
271 for(n=0;n<255;n++)
|
|
seanhalle@64
|
272 {
|
|
seanhalle@64
|
273 sprintf(filename, "./counters/UCC.%d",n);
|
|
seanhalle@64
|
274 output = fopen(filename,"r");
|
|
seanhalle@64
|
275 if(output)
|
|
seanhalle@64
|
276 {
|
|
seanhalle@64
|
277 fclose(output);
|
|
seanhalle@64
|
278 }else{
|
|
seanhalle@64
|
279 break;
|
|
seanhalle@64
|
280 }
|
|
seanhalle@64
|
281 }
|
|
seanhalle@64
|
282 if(n<255){
|
|
seanhalle@64
|
283 printf("Saving UCC to File: %s ...\n", filename);
|
|
seanhalle@64
|
284 output = fopen(filename,"w+");
|
|
seanhalle@64
|
285 if(output!=NULL){
|
|
seanhalle@64
|
286 set_dependency_file(output);
|
|
seanhalle@64
|
287 //fprintf(output,"digraph Dependencies {\n");
|
|
seanhalle@64
|
288 //set_dot_file(output);
|
|
seanhalle@64
|
289 //FIXME: first line still depends on counters being enabled, replace w/ unit struct!
|
|
seanhalle@64
|
290 //forAllInDynArrayDo(_VMSMasterEnv->counter_history_array_info, &print_dot_node_info );
|
|
seanhalle@64
|
291 forAllInListOfArraysDo(semanticEnv->unitList, &print_unit_to_file);
|
|
seanhalle@64
|
292 forAllInListOfArraysDo( semanticEnv->commDependenciesList, &print_comm_dependency_to_file );
|
|
seanhalle@64
|
293 forAllInListOfArraysDo( semanticEnv->ctlDependenciesList, &print_ctl_dependency_to_file );
|
|
seanhalle@64
|
294 forAllInDynArrayDo(semanticEnv->ntonGroupsInfo,&print_nton_to_file);
|
|
seanhalle@64
|
295 //fprintf(output,"}\n");
|
|
seanhalle@64
|
296 fflush(output);
|
|
seanhalle@64
|
297
|
|
seanhalle@64
|
298 } else
|
|
seanhalle@64
|
299 printf("Opening UCC file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");
|
|
seanhalle@64
|
300 } else {
|
|
seanhalle@64
|
301 printf("Could not open UCC file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
|
|
seanhalle@64
|
302 }
|
|
seanhalle@64
|
303 //Loop Graph
|
|
seanhalle@64
|
304 for(n=0;n<255;n++)
|
|
seanhalle@64
|
305 {
|
|
seanhalle@64
|
306 sprintf(filename, "./counters/LoopGraph.%d",n);
|
|
seanhalle@64
|
307 output = fopen(filename,"r");
|
|
seanhalle@64
|
308 if(output)
|
|
seanhalle@64
|
309 {
|
|
seanhalle@64
|
310 fclose(output);
|
|
seanhalle@64
|
311 }else{
|
|
seanhalle@64
|
312 break;
|
|
seanhalle@64
|
313 }
|
|
seanhalle@64
|
314 }
|
|
seanhalle@64
|
315 if(n<255){
|
|
seanhalle@64
|
316 printf("Saving LoopGraph to File: %s ...\n", filename);
|
|
seanhalle@64
|
317 output = fopen(filename,"w+");
|
|
seanhalle@64
|
318 if(output!=NULL){
|
|
seanhalle@64
|
319 set_dependency_file(output);
|
|
seanhalle@64
|
320 //fprintf(output,"digraph Dependencies {\n");
|
|
seanhalle@64
|
321 //set_dot_file(output);
|
|
seanhalle@64
|
322 //FIXME: first line still depends on counters being enabled, replace w/ unit struct!
|
|
seanhalle@64
|
323 //forAllInDynArrayDo(_VMSMasterEnv->counter_history_array_info, &print_dot_node_info );
|
|
seanhalle@64
|
324 forAllInListOfArraysDo( semanticEnv->unitList, &print_unit_to_file );
|
|
seanhalle@64
|
325 forAllInListOfArraysDo( semanticEnv->commDependenciesList, &print_comm_dependency_to_file );
|
|
seanhalle@64
|
326 forAllInListOfArraysDo( semanticEnv->ctlDependenciesList, &print_ctl_dependency_to_file );
|
|
seanhalle@64
|
327 forAllInListOfArraysDo( semanticEnv->dynDependenciesList, &print_dyn_dependency_to_file );
|
|
nengel@74
|
328 forAllInListOfArraysDo( semanticEnv->singletonDependenciesList, &print_singleton_dependency_to_file );
|
|
seanhalle@64
|
329 forAllInListOfArraysDo( semanticEnv->hwArcs, &print_hw_dependency_to_file );
|
|
seanhalle@64
|
330 //fprintf(output,"}\n");
|
|
seanhalle@64
|
331 fflush(output);
|
|
seanhalle@64
|
332
|
|
seanhalle@64
|
333 } else
|
|
seanhalle@64
|
334 printf("Opening LoopGraph file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");
|
|
seanhalle@64
|
335 } else {
|
|
seanhalle@64
|
336 printf("Could not open LoopGraph file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
|
|
seanhalle@64
|
337 }
|
|
seanhalle@64
|
338
|
|
seanhalle@64
|
339
|
|
seanhalle@64
|
340 freeListOfArrays(semanticEnv->unitList);
|
|
seanhalle@64
|
341 freeListOfArrays(semanticEnv->commDependenciesList);
|
|
seanhalle@64
|
342 freeListOfArrays(semanticEnv->ctlDependenciesList);
|
|
seanhalle@64
|
343 freeListOfArrays(semanticEnv->dynDependenciesList);
|
|
nengel@74
|
344 freeListOfArrays(semanticEnv->singletonDependenciesList);
|
|
seanhalle@64
|
345 #endif
|
|
seanhalle@64
|
346 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
|
|
seanhalle@64
|
347 for(n=0;n<255;n++)
|
|
seanhalle@64
|
348 {
|
|
seanhalle@64
|
349 sprintf(filename, "./counters/Counters.%d.csv",n);
|
|
seanhalle@64
|
350 output = fopen(filename,"r");
|
|
seanhalle@64
|
351 if(output)
|
|
seanhalle@64
|
352 {
|
|
seanhalle@64
|
353 fclose(output);
|
|
seanhalle@64
|
354 }else{
|
|
seanhalle@64
|
355 break;
|
|
seanhalle@64
|
356 }
|
|
seanhalle@64
|
357 }
|
|
seanhalle@64
|
358 if(n<255){
|
|
seanhalle@64
|
359 printf("Saving Counter measurements to File: %s ...\n", filename);
|
|
seanhalle@64
|
360 output = fopen(filename,"w+");
|
|
seanhalle@64
|
361 if(output!=NULL){
|
|
seanhalle@64
|
362 set_counter_file(output);
|
|
seanhalle@64
|
363 int i;
|
|
seanhalle@64
|
364 for(i=0;i<NUM_CORES;i++){
|
|
seanhalle@64
|
365 forAllInListOfArraysDo( semanticEnv->counterList[i], &print_counter_events_to_file );
|
|
seanhalle@64
|
366 fflush(output);
|
|
seanhalle@64
|
367 }
|
|
seanhalle@64
|
368
|
|
seanhalle@64
|
369 } else
|
|
seanhalle@64
|
370 printf("Opening UCC file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");
|
|
seanhalle@64
|
371 } else {
|
|
seanhalle@64
|
372 printf("Could not open UCC file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
|
|
seanhalle@64
|
373 }
|
|
seanhalle@64
|
374
|
|
seanhalle@64
|
375 #endif
|
|
seanhalle@64
|
376 /* It's all allocated inside VMS's big chunk -- that's about to be freed, so
|
|
seanhalle@64
|
377 * nothing to do here
|
|
seanhalle@64
|
378
|
|
seanhalle@64
|
379
|
|
seanhalle@64
|
380 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
|
|
seanhalle@64
|
381 {
|
|
seanhalle@64
|
382 VMS_int__free( semanticEnv->readyVPQs[coreIdx]->startOfData );
|
|
seanhalle@64
|
383 VMS_int__free( semanticEnv->readyVPQs[coreIdx] );
|
|
seanhalle@64
|
384 }
|
|
seanhalle@64
|
385 VMS_int__free( semanticEnv->readyVPQs );
|
|
seanhalle@64
|
386
|
|
seanhalle@64
|
387 freeHashTable( semanticEnv->commHashTbl );
|
|
seanhalle@64
|
388 VMS_int__free( _VMSMasterEnv->semanticEnv );
|
|
seanhalle@64
|
389 */
|
|
seanhalle@64
|
390 VMS_SS__cleanup_at_end_of_shutdown();
|
|
seanhalle@64
|
391 }
|
|
seanhalle@64
|
392
|
|
seanhalle@64
|
393
|
|
seanhalle@64
|
394 //===========================================================================
|
|
seanhalle@64
|
395
|
|
seanhalle@64
|
396 /*
|
|
seanhalle@64
|
397 */
|
|
seanhalle@64
|
398 SlaveVP *
|
|
seanhalle@64
|
399 SSR__create_procr_with( TopLevelFnPtr fnPtr, void *initData,
|
|
seanhalle@64
|
400 SlaveVP *creatingPr )
|
|
seanhalle@64
|
401 { SSRSemReq reqData;
|
|
seanhalle@64
|
402
|
|
seanhalle@64
|
403 //the semantic request data is on the stack and disappears when this
|
|
seanhalle@64
|
404 // call returns -- it's guaranteed to remain in the VP's stack for as
|
|
seanhalle@64
|
405 // long as the VP is suspended.
|
|
seanhalle@64
|
406 reqData.reqType = 0; //know type because in a VMS create req
|
|
seanhalle@64
|
407 reqData.coreToAssignOnto = -1; //means round-robin assign
|
|
seanhalle@64
|
408 reqData.fnPtr = fnPtr;
|
|
seanhalle@64
|
409 reqData.initData = initData;
|
|
seanhalle@64
|
410 reqData.sendPr = creatingPr;
|
|
seanhalle@64
|
411
|
|
seanhalle@64
|
412 VMS_WL__send_create_slaveVP_req( &reqData, creatingPr );
|
|
seanhalle@64
|
413
|
|
seanhalle@64
|
414 return creatingPr->dataRetFromReq;
|
|
seanhalle@64
|
415 }
|
|
seanhalle@64
|
416
|
|
seanhalle@64
|
417 SlaveVP *
|
|
seanhalle@64
|
418 SSR__create_procr_with_affinity( TopLevelFnPtr fnPtr, void *initData,
|
|
seanhalle@64
|
419 SlaveVP *creatingPr, int32 coreToAssignOnto )
|
|
seanhalle@64
|
420 { SSRSemReq reqData;
|
|
seanhalle@64
|
421
|
|
seanhalle@64
|
422 //the semantic request data is on the stack and disappears when this
|
|
seanhalle@64
|
423 // call returns -- it's guaranteed to remain in the VP's stack for as
|
|
seanhalle@64
|
424 // long as the VP is suspended.
|
|
seanhalle@64
|
425 reqData.reqType = 0; //know type because in a VMS create req
|
|
seanhalle@64
|
426 reqData.coreToAssignOnto = coreToAssignOnto;
|
|
seanhalle@64
|
427 reqData.fnPtr = fnPtr;
|
|
seanhalle@64
|
428 reqData.initData = initData;
|
|
seanhalle@64
|
429 reqData.sendPr = creatingPr;
|
|
seanhalle@64
|
430
|
|
seanhalle@64
|
431 VMS_WL__send_create_slaveVP_req( &reqData, creatingPr );
|
|
seanhalle@64
|
432
|
|
seanhalle@64
|
433 return creatingPr->dataRetFromReq;
|
|
seanhalle@64
|
434 }
|
|
seanhalle@64
|
435
|
|
seanhalle@64
|
436
|
|
seanhalle@64
|
437 void
|
|
seanhalle@64
|
438 SSR__dissipate_procr( SlaveVP *procrToDissipate )
|
|
seanhalle@64
|
439 {
|
|
seanhalle@64
|
440 VMS_WL__send_dissipate_req( procrToDissipate );
|
|
seanhalle@64
|
441 }
|
|
seanhalle@64
|
442
|
|
seanhalle@64
|
443
|
|
seanhalle@64
|
444 //===========================================================================
|
|
seanhalle@64
|
445
|
|
seanhalle@64
|
446 void *
|
|
seanhalle@64
|
447 SSR__malloc_to( int32 sizeToMalloc, SlaveVP *owningPr )
|
|
seanhalle@64
|
448 { SSRSemReq reqData;
|
|
seanhalle@64
|
449
|
|
seanhalle@64
|
450 reqData.reqType = malloc_req;
|
|
seanhalle@64
|
451 reqData.sendPr = owningPr;
|
|
seanhalle@64
|
452 reqData.sizeToMalloc = sizeToMalloc;
|
|
seanhalle@64
|
453
|
|
seanhalle@64
|
454 VMS_WL__send_sem_request( &reqData, owningPr );
|
|
seanhalle@64
|
455
|
|
seanhalle@64
|
456 return owningPr->dataRetFromReq;
|
|
seanhalle@64
|
457 }
|
|
seanhalle@64
|
458
|
|
seanhalle@64
|
459
|
|
seanhalle@64
|
460 /*Sends request to Master, which does the work of freeing
|
|
seanhalle@64
|
461 */
|
|
seanhalle@64
|
462 void
|
|
seanhalle@64
|
463 SSR__free( void *ptrToFree, SlaveVP *owningPr )
|
|
seanhalle@64
|
464 { SSRSemReq reqData;
|
|
seanhalle@64
|
465
|
|
seanhalle@64
|
466 reqData.reqType = free_req;
|
|
seanhalle@64
|
467 reqData.sendPr = owningPr;
|
|
seanhalle@64
|
468 reqData.ptrToFree = ptrToFree;
|
|
seanhalle@64
|
469
|
|
seanhalle@64
|
470 VMS_WL__send_sem_request( &reqData, owningPr );
|
|
seanhalle@64
|
471 }
|
|
seanhalle@64
|
472
|
|
seanhalle@64
|
473
|
|
seanhalle@64
|
474 void
|
|
seanhalle@64
|
475 SSR__transfer_ownership_of_from_to( void *data, SlaveVP *oldOwnerSlv,
|
|
seanhalle@64
|
476 SlaveVP *newOwnerPr )
|
|
seanhalle@64
|
477 {
|
|
seanhalle@64
|
478 //TODO: put in the ownership system that automatically frees when no
|
|
seanhalle@64
|
479 // owners of data left -- will need keeper for keeping data around when
|
|
seanhalle@64
|
480 // future created processors might need it but don't exist yet
|
|
seanhalle@64
|
481 }
|
|
seanhalle@64
|
482
|
|
seanhalle@64
|
483
|
|
seanhalle@64
|
484 void
|
|
seanhalle@64
|
485 SSR__add_ownership_by_to( SlaveVP *newOwnerSlv, void *data )
|
|
seanhalle@64
|
486 {
|
|
seanhalle@64
|
487
|
|
seanhalle@64
|
488 }
|
|
seanhalle@64
|
489
|
|
seanhalle@64
|
490
|
|
seanhalle@64
|
491 void
|
|
seanhalle@64
|
492 SSR__remove_ownership_by_from( SlaveVP *loserSlv, void *dataLosing )
|
|
seanhalle@64
|
493 {
|
|
seanhalle@64
|
494
|
|
seanhalle@64
|
495 }
|
|
seanhalle@64
|
496
|
|
seanhalle@64
|
497
|
|
seanhalle@64
|
498 /*Causes the SSR system to remove internal ownership, so data won't be
|
|
seanhalle@64
|
499 * freed when SSR shuts down, and will persist in the external program.
|
|
seanhalle@64
|
500 *
|
|
seanhalle@64
|
501 *Must be called from the processor that currently owns the data.
|
|
seanhalle@64
|
502 *
|
|
seanhalle@64
|
503 *IMPL: Transferring ownership touches two different virtual processor's
|
|
seanhalle@64
|
504 * state -- which means it has to be done carefully -- the VMS rules for
|
|
seanhalle@64
|
505 * semantic layers say that a work-unit is only allowed to touch the
|
|
seanhalle@64
|
506 * virtual processor it is part of, and that only a single work-unit per
|
|
seanhalle@64
|
507 * virtual processor be assigned to a slave at a time. So, this has to
|
|
seanhalle@64
|
508 * modify the virtual processor that owns the work-unit that called this
|
|
seanhalle@64
|
509 * function, then create a request to have the other processor modified.
|
|
seanhalle@64
|
510 *However, in this case, the TO processor is the outside, and transfers
|
|
seanhalle@64
|
511 * are only allowed to be called by the giver-upper, so can mark caller of
|
|
seanhalle@64
|
512 * this function as no longer owner, and return -- done.
|
|
seanhalle@64
|
513 */
|
|
seanhalle@64
|
514 void
|
|
seanhalle@64
|
515 SSR__transfer_ownership_to_outside( void *data )
|
|
seanhalle@64
|
516 {
|
|
seanhalle@64
|
517 //TODO: removeAllOwnersFrom( data );
|
|
seanhalle@64
|
518 }
|
|
seanhalle@64
|
519
|
|
seanhalle@64
|
520
|
|
seanhalle@64
|
521 //===========================================================================
|
|
seanhalle@64
|
522
|
|
seanhalle@64
|
523 void
|
|
seanhalle@64
|
524 SSR__send_of_type_to( SlaveVP *sendPr, void *msg, const int type,
|
|
seanhalle@64
|
525 SlaveVP *receivePr)
|
|
seanhalle@64
|
526 { SSRSemReq reqData;
|
|
seanhalle@64
|
527
|
|
seanhalle@64
|
528 reqData.receivePr = receivePr;
|
|
seanhalle@64
|
529 reqData.sendPr = sendPr;
|
|
seanhalle@64
|
530 reqData.reqType = send_type;
|
|
seanhalle@64
|
531 reqData.msgType = type;
|
|
seanhalle@64
|
532 reqData.msg = msg;
|
|
seanhalle@64
|
533 reqData.nextReqInHashEntry = NULL;
|
|
seanhalle@64
|
534
|
|
seanhalle@64
|
535 //On ownership -- remove inside the send and let ownership sit in limbo
|
|
seanhalle@64
|
536 // as a potential in an entry in the hash table, when this receive msg
|
|
seanhalle@64
|
537 // gets paired to a send, the ownership gets added to the receivePr --
|
|
seanhalle@64
|
538 // the next work-unit in the receivePr's trace will have ownership.
|
|
seanhalle@64
|
539 VMS_WL__send_sem_request( &reqData, sendPr );
|
|
seanhalle@64
|
540
|
|
seanhalle@64
|
541 //When come back from suspend, no longer own data reachable from msg
|
|
seanhalle@64
|
542 //TODO: release ownership here
|
|
seanhalle@64
|
543 }
|
|
seanhalle@64
|
544
|
|
seanhalle@64
|
545 void
|
|
seanhalle@64
|
546 SSR__send_from_to( void *msg, SlaveVP *sendPr, SlaveVP *receivePr )
|
|
seanhalle@64
|
547 { SSRSemReq reqData;
|
|
seanhalle@64
|
548
|
|
seanhalle@64
|
549 //hash on the receiver, 'cause always know it, but sometimes want to
|
|
seanhalle@64
|
550 // receive from anonymous sender
|
|
seanhalle@64
|
551
|
|
seanhalle@64
|
552 reqData.receivePr = receivePr;
|
|
seanhalle@64
|
553 reqData.sendPr = sendPr;
|
|
seanhalle@64
|
554 reqData.reqType = send_from_to;
|
|
seanhalle@64
|
555 reqData.msg = msg;
|
|
seanhalle@64
|
556 reqData.nextReqInHashEntry = NULL;
|
|
seanhalle@64
|
557
|
|
seanhalle@64
|
558 VMS_WL__send_sem_request( &reqData, sendPr );
|
|
seanhalle@64
|
559 }
|
|
seanhalle@64
|
560
|
|
seanhalle@64
|
561
|
|
seanhalle@64
|
562 //===========================================================================
|
|
seanhalle@64
|
563
|
|
seanhalle@64
|
564 void *
|
|
seanhalle@64
|
565 SSR__receive_any_to( SlaveVP *receivePr )
|
|
seanhalle@64
|
566 {
|
|
seanhalle@64
|
567
|
|
seanhalle@64
|
568 }
|
|
seanhalle@64
|
569
|
|
seanhalle@64
|
570 void *
|
|
seanhalle@64
|
571 SSR__receive_type_to( const int type, SlaveVP *receivePr )
|
|
seanhalle@67
|
572 { DEBUG__printf1(dbgRqstHdlr,"WL: receive type to: %d", receivePr->slaveID);
|
|
seanhalle@64
|
573 SSRSemReq reqData;
|
|
seanhalle@64
|
574
|
|
seanhalle@64
|
575 reqData.receivePr = receivePr;
|
|
seanhalle@64
|
576 reqData.reqType = receive_type;
|
|
seanhalle@64
|
577 reqData.msgType = type;
|
|
seanhalle@64
|
578 reqData.nextReqInHashEntry = NULL;
|
|
seanhalle@64
|
579
|
|
seanhalle@64
|
580 VMS_WL__send_sem_request( &reqData, receivePr );
|
|
seanhalle@64
|
581
|
|
seanhalle@64
|
582 return receivePr->dataRetFromReq;
|
|
seanhalle@64
|
583 }
|
|
seanhalle@64
|
584
|
|
seanhalle@64
|
585
|
|
seanhalle@64
|
586
|
|
seanhalle@64
|
587 /*Call this at point receiving virt pr wants in-coming data.
|
|
seanhalle@64
|
588 *
|
|
seanhalle@64
|
589 *The reason receivePr must call this is that it modifies the receivPr
|
|
seanhalle@64
|
590 * loc structure directly -- and the VMS rules state a virtual processor
|
|
seanhalle@64
|
591 * loc structure can only be modified by itself.
|
|
seanhalle@64
|
592 */
|
|
seanhalle@64
|
593 void *
|
|
seanhalle@64
|
594 SSR__receive_from_to( SlaveVP *sendPr, SlaveVP *receivePr )
|
|
seanhalle@67
|
595 { DEBUG__printf2(dbgRqstHdlr,"WL: receive from %d to: %d", sendPr->slaveID, receivePr->slaveID);
|
|
seanhalle@67
|
596 SSRSemReq reqData;
|
|
seanhalle@64
|
597
|
|
seanhalle@64
|
598 //hash on the receiver, 'cause always know it, but sometimes want to
|
|
seanhalle@64
|
599 // receive from anonymous sender
|
|
seanhalle@64
|
600
|
|
seanhalle@64
|
601 reqData.receivePr = receivePr;
|
|
seanhalle@64
|
602 reqData.sendPr = sendPr;
|
|
seanhalle@64
|
603 reqData.reqType = receive_from_to;
|
|
seanhalle@64
|
604 reqData.nextReqInHashEntry = NULL;
|
|
seanhalle@64
|
605
|
|
seanhalle@64
|
606 VMS_WL__send_sem_request( &reqData, receivePr );
|
|
seanhalle@64
|
607
|
|
seanhalle@64
|
608 return receivePr->dataRetFromReq;
|
|
seanhalle@64
|
609 }
|
|
seanhalle@64
|
610
|
|
seanhalle@64
|
611
|
|
seanhalle@64
|
612 //===========================================================================
|
|
seanhalle@64
|
613 //
|
|
seanhalle@64
|
614 /*A function singleton is a function whose body executes exactly once, on a
|
|
seanhalle@64
|
615 * single core, no matter how many times the fuction is called and no
|
|
seanhalle@64
|
616 * matter how many cores or the timing of cores calling it.
|
|
seanhalle@64
|
617 *
|
|
seanhalle@64
|
618 *A data singleton is a ticket attached to data. That ticket can be used
|
|
seanhalle@64
|
619 * to get the data through the function exactly once, no matter how many
|
|
seanhalle@64
|
620 * times the data is given to the function, and no matter the timing of
|
|
seanhalle@64
|
621 * trying to get the data through from different cores.
|
|
seanhalle@64
|
622 */
|
|
seanhalle@64
|
623
|
|
seanhalle@64
|
624 /*asm function declarations*/
|
|
seanhalle@64
|
625 void asm_save_ret_to_singleton(SSRSingleton *singletonPtrAddr);
|
|
seanhalle@64
|
626 void asm_write_ret_from_singleton(SSRSingleton *singletonPtrAddr);
|
|
seanhalle@64
|
627
|
|
seanhalle@64
|
628 /*Fn singleton uses ID as index into array of singleton structs held in the
|
|
seanhalle@64
|
629 * semantic environment.
|
|
seanhalle@64
|
630 */
|
|
seanhalle@64
|
631 void
|
|
seanhalle@64
|
632 SSR__start_fn_singleton( int32 singletonID, SlaveVP *animPr )
|
|
seanhalle@64
|
633 {
|
|
seanhalle@64
|
634 SSRSemReq reqData;
|
|
seanhalle@64
|
635
|
|
seanhalle@64
|
636 //
|
|
seanhalle@64
|
637 reqData.reqType = singleton_fn_start;
|
|
seanhalle@64
|
638 reqData.singletonID = singletonID;
|
|
seanhalle@64
|
639
|
|
seanhalle@64
|
640 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
641 if( animPr->dataRetFromReq ) //will be 0 or addr of label in end singleton
|
|
seanhalle@64
|
642 {
|
|
seanhalle@64
|
643 SSRSemEnv *semEnv = VMS_int__give_sem_env_for( animPr );
|
|
seanhalle@64
|
644 asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID]));
|
|
seanhalle@64
|
645 }
|
|
seanhalle@64
|
646 }
|
|
seanhalle@64
|
647
|
|
seanhalle@64
|
648 /*Data singleton hands addr of loc holding a pointer to a singleton struct.
|
|
seanhalle@64
|
649 * The start_data_singleton makes the structure and puts its addr into the
|
|
seanhalle@64
|
650 * location.
|
|
seanhalle@64
|
651 */
|
|
seanhalle@64
|
652 void
|
|
seanhalle@64
|
653 SSR__start_data_singleton( SSRSingleton **singletonAddr, SlaveVP *animPr )
|
|
seanhalle@64
|
654 {
|
|
seanhalle@64
|
655 SSRSemReq reqData;
|
|
seanhalle@64
|
656
|
|
seanhalle@64
|
657 if( *singletonAddr && (*singletonAddr)->hasFinished )
|
|
seanhalle@64
|
658 goto JmpToEndSingleton;
|
|
seanhalle@64
|
659
|
|
seanhalle@64
|
660 reqData.reqType = singleton_data_start;
|
|
seanhalle@64
|
661 reqData.singletonPtrAddr = singletonAddr;
|
|
seanhalle@64
|
662
|
|
seanhalle@64
|
663 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
664 if( animPr->dataRetFromReq ) //either 0 or end singleton's return addr
|
|
seanhalle@64
|
665 { //Assembly code changes the return addr on the stack to the one
|
|
seanhalle@64
|
666 // saved into the singleton by the end-singleton-fn
|
|
seanhalle@64
|
667 //The return addr is at 0x4(%%ebp)
|
|
seanhalle@64
|
668 JmpToEndSingleton:
|
|
seanhalle@64
|
669 asm_write_ret_from_singleton(*singletonAddr);
|
|
seanhalle@64
|
670 }
|
|
seanhalle@64
|
671 //now, simply return
|
|
seanhalle@64
|
672 //will exit either from the start singleton call or the end-singleton call
|
|
seanhalle@64
|
673 }
|
|
seanhalle@64
|
674
|
|
seanhalle@64
|
675 /*Uses ID as index into array of flags. If flag already set, resumes from
|
|
seanhalle@64
|
676 * end-label. Else, sets flag and resumes normally.
|
|
seanhalle@64
|
677 *
|
|
seanhalle@64
|
678 *Note, this call cannot be inlined because the instr addr at the label
|
|
seanhalle@64
|
679 * inside is shared by all invocations of a given singleton ID.
|
|
seanhalle@64
|
680 */
|
|
seanhalle@64
|
681 void
|
|
seanhalle@64
|
682 SSR__end_fn_singleton( int32 singletonID, SlaveVP *animPr )
|
|
seanhalle@64
|
683 {
|
|
seanhalle@64
|
684 SSRSemReq reqData;
|
|
seanhalle@64
|
685
|
|
seanhalle@64
|
686 //don't need this addr until after at least one singleton has reached
|
|
seanhalle@64
|
687 // this function
|
|
seanhalle@64
|
688 SSRSemEnv *semEnv = VMS_int__give_sem_env_for( animPr );
|
|
seanhalle@64
|
689 asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID]));
|
|
seanhalle@64
|
690
|
|
seanhalle@64
|
691 reqData.reqType = singleton_fn_end;
|
|
seanhalle@64
|
692 reqData.singletonID = singletonID;
|
|
seanhalle@64
|
693
|
|
seanhalle@64
|
694 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
695
|
|
seanhalle@64
|
696 EndSingletonInstrAddr:
|
|
seanhalle@64
|
697 return;
|
|
seanhalle@64
|
698 }
|
|
seanhalle@64
|
699
|
|
seanhalle@64
|
700 void
|
|
seanhalle@64
|
701 SSR__end_data_singleton( SSRSingleton **singletonPtrAddr, SlaveVP *animPr )
|
|
seanhalle@64
|
702 {
|
|
seanhalle@64
|
703 SSRSemReq reqData;
|
|
seanhalle@64
|
704
|
|
seanhalle@64
|
705 //don't need this addr until after singleton struct has reached
|
|
seanhalle@64
|
706 // this function for first time
|
|
seanhalle@64
|
707 //do assembly that saves the return addr of this fn call into the
|
|
seanhalle@64
|
708 // data singleton -- that data-singleton can only be given to exactly
|
|
seanhalle@64
|
709 // one instance in the code of this function. However, can use this
|
|
seanhalle@64
|
710 // function in different places for different data-singletons.
|
|
seanhalle@64
|
711 // (*(singletonAddr))->endInstrAddr = &&EndDataSingletonInstrAddr;
|
|
seanhalle@64
|
712
|
|
seanhalle@64
|
713
|
|
seanhalle@64
|
714 asm_save_ret_to_singleton(*singletonPtrAddr);
|
|
seanhalle@64
|
715
|
|
seanhalle@64
|
716 reqData.reqType = singleton_data_end;
|
|
seanhalle@64
|
717 reqData.singletonPtrAddr = singletonPtrAddr;
|
|
seanhalle@64
|
718
|
|
seanhalle@64
|
719 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
720 }
|
|
seanhalle@64
|
721
|
|
seanhalle@64
|
722 /*This executes the function in the masterVP, so it executes in isolation
|
|
seanhalle@64
|
723 * from any other copies -- only one copy of the function can ever execute
|
|
seanhalle@64
|
724 * at a time.
|
|
seanhalle@64
|
725 *
|
|
seanhalle@64
|
726 *It suspends to the master, and the request handler takes the function
|
|
seanhalle@64
|
727 * pointer out of the request and calls it, then resumes the VP.
|
|
seanhalle@64
|
728 *Only very short functions should be called this way -- for longer-running
|
|
seanhalle@64
|
729 * isolation, use transaction-start and transaction-end, which run the code
|
|
seanhalle@64
|
730 * between as work-code.
|
|
seanhalle@64
|
731 */
|
|
seanhalle@64
|
732 void
|
|
seanhalle@64
|
733 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
|
|
seanhalle@64
|
734 void *data, SlaveVP *animPr )
|
|
seanhalle@64
|
735 {
|
|
seanhalle@64
|
736 SSRSemReq reqData;
|
|
seanhalle@64
|
737
|
|
seanhalle@64
|
738 //
|
|
seanhalle@64
|
739 reqData.reqType = atomic;
|
|
seanhalle@64
|
740 reqData.fnToExecInMaster = ptrToFnToExecInMaster;
|
|
seanhalle@64
|
741 reqData.dataForFn = data;
|
|
seanhalle@64
|
742
|
|
seanhalle@64
|
743 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
744 }
|
|
seanhalle@64
|
745
|
|
seanhalle@64
|
746
|
|
seanhalle@64
|
747 /*This suspends to the master.
|
|
seanhalle@64
|
748 *First, it looks at the VP's data, to see the highest transactionID that VP
|
|
seanhalle@64
|
749 * already has entered. If the current ID is not larger, it throws an
|
|
seanhalle@64
|
750 * exception stating a bug in the code. Otherwise it puts the current ID
|
|
seanhalle@64
|
751 * there, and adds the ID to a linked list of IDs entered -- the list is
|
|
seanhalle@64
|
752 * used to check that exits are properly ordered.
|
|
seanhalle@64
|
753 *Next it is uses transactionID as index into an array of transaction
|
|
seanhalle@64
|
754 * structures.
|
|
seanhalle@64
|
755 *If the "VP_currently_executing" field is non-null, then put requesting VP
|
|
seanhalle@64
|
756 * into queue in the struct. (At some point a holder will request
|
|
seanhalle@64
|
757 * end-transaction, which will take this VP from the queue and resume it.)
|
|
seanhalle@64
|
758 *If NULL, then write requesting into the field and resume.
|
|
seanhalle@64
|
759 */
|
|
seanhalle@64
|
760 void
|
|
seanhalle@64
|
761 SSR__start_transaction( int32 transactionID, SlaveVP *animPr )
|
|
seanhalle@64
|
762 {
|
|
seanhalle@64
|
763 SSRSemReq reqData;
|
|
seanhalle@64
|
764
|
|
seanhalle@64
|
765 //
|
|
seanhalle@64
|
766 reqData.sendPr = animPr;
|
|
seanhalle@64
|
767 reqData.reqType = trans_start;
|
|
seanhalle@64
|
768 reqData.transID = transactionID;
|
|
seanhalle@64
|
769
|
|
seanhalle@64
|
770 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
771 }
|
|
seanhalle@64
|
772
|
|
seanhalle@64
|
773 /*This suspends to the master, then uses transactionID as index into an
|
|
seanhalle@64
|
774 * array of transaction structures.
|
|
seanhalle@64
|
775 *It looks at VP_currently_executing to be sure it's same as requesting VP.
|
|
seanhalle@64
|
776 * If different, throws an exception, stating there's a bug in the code.
|
|
seanhalle@64
|
777 *Next it looks at the queue in the structure.
|
|
seanhalle@64
|
778 *If it's empty, it sets VP_currently_executing field to NULL and resumes.
|
|
seanhalle@64
|
779 *If something in, gets it, sets VP_currently_executing to that VP, then
|
|
seanhalle@64
|
780 * resumes both.
|
|
seanhalle@64
|
781 */
|
|
seanhalle@64
|
782 void
|
|
seanhalle@64
|
783 SSR__end_transaction( int32 transactionID, SlaveVP *animPr )
|
|
seanhalle@64
|
784 {
|
|
seanhalle@64
|
785 SSRSemReq reqData;
|
|
seanhalle@64
|
786
|
|
seanhalle@64
|
787 //
|
|
seanhalle@64
|
788 reqData.sendPr = animPr;
|
|
seanhalle@64
|
789 reqData.reqType = trans_end;
|
|
seanhalle@64
|
790 reqData.transID = transactionID;
|
|
seanhalle@64
|
791
|
|
seanhalle@64
|
792 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
793 }
|