| 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@66
|
202 semanticEnv->shutdownInitiated = FALSE;
|
|
seanhalle@64
|
203 for(i=0;i<NUM_CORES;++i){
|
|
seanhalle@69
|
204 for(j=0;j<NUM_ANIM_SLOTS;++j){
|
|
seanhalle@64
|
205 semanticEnv->idlePr[i][j] = VMS_int__create_slaveVP(&idle_fn,NULL);
|
|
seanhalle@64
|
206 semanticEnv->idlePr[i][j]->coreAnimatedBy = i;
|
|
seanhalle@64
|
207 }
|
|
seanhalle@64
|
208 }
|
|
seanhalle@64
|
209
|
|
seanhalle@64
|
210 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
|
|
seanhalle@64
|
211 semanticEnv->unitList = makeListOfArrays(sizeof(Unit),128);
|
|
seanhalle@64
|
212 semanticEnv->ctlDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
|
seanhalle@64
|
213 semanticEnv->commDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
|
seanhalle@64
|
214 semanticEnv->dynDependenciesList = makeListOfArrays(sizeof(Dependency),128);
|
|
seanhalle@64
|
215 semanticEnv->ntonGroupsInfo = makePrivDynArrayOfSize((void***)&(semanticEnv->ntonGroups),8);
|
|
seanhalle@64
|
216
|
|
seanhalle@64
|
217 semanticEnv->hwArcs = makeListOfArrays(sizeof(Dependency),128);
|
|
seanhalle@69
|
218 memset(semanticEnv->last_in_slot,0,sizeof(NUM_CORES * NUM_ANIM_SLOTS * sizeof(Unit)));
|
|
seanhalle@64
|
219 #endif
|
|
seanhalle@64
|
220
|
|
seanhalle@64
|
221 //create the ready queue, hash tables used for pairing send to receive
|
|
seanhalle@64
|
222 // and so forth
|
|
seanhalle@64
|
223 //TODO: add hash tables for pairing sends with receives, and
|
|
seanhalle@64
|
224 // initialize the data ownership system
|
|
seanhalle@64
|
225 readyVPQs = VMS_int__malloc( NUM_CORES * sizeof(PrivQueueStruc *) );
|
|
seanhalle@64
|
226
|
|
seanhalle@64
|
227 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
|
|
seanhalle@64
|
228 {
|
|
seanhalle@64
|
229 readyVPQs[ coreIdx ] = makeVMSQ();
|
|
seanhalle@64
|
230 }
|
|
seanhalle@64
|
231
|
|
seanhalle@64
|
232 semanticEnv->readyVPQs = readyVPQs;
|
|
seanhalle@64
|
233
|
|
seanhalle@64
|
234 semanticEnv->nextCoreToGetNewPr = 0;
|
|
seanhalle@64
|
235 semanticEnv->numSlaveVP = 0;
|
|
seanhalle@64
|
236
|
|
seanhalle@64
|
237 semanticEnv->commHashTbl = makeHashTable( 1<<16, &VMS_int__free );//start big
|
|
seanhalle@64
|
238
|
|
seanhalle@64
|
239 //TODO: bug -- turn these arrays into dyn arrays to eliminate limit
|
|
seanhalle@64
|
240 //semanticEnv->singletonHasBeenExecutedFlags = makeDynArrayInfo( );
|
|
seanhalle@64
|
241 //semanticEnv->transactionStrucs = makeDynArrayInfo( );
|
|
seanhalle@64
|
242 for( i = 0; i < NUM_STRUCS_IN_SEM_ENV; i++ )
|
|
seanhalle@64
|
243 {
|
|
seanhalle@64
|
244 semanticEnv->fnSingletons[i].endInstrAddr = NULL;
|
|
seanhalle@64
|
245 semanticEnv->fnSingletons[i].hasBeenStarted = FALSE;
|
|
seanhalle@64
|
246 semanticEnv->fnSingletons[i].hasFinished = FALSE;
|
|
seanhalle@64
|
247 semanticEnv->fnSingletons[i].waitQ = makeVMSQ();
|
|
seanhalle@64
|
248 semanticEnv->transactionStrucs[i].waitingVPQ = makeVMSQ();
|
|
seanhalle@64
|
249 }
|
|
seanhalle@64
|
250 }
|
|
seanhalle@64
|
251
|
|
seanhalle@64
|
252
|
|
seanhalle@64
|
253 /*Frees any memory allocated by SSR__init() then calls VMS_int__shutdown
|
|
seanhalle@64
|
254 */
|
|
seanhalle@64
|
255 void
|
|
seanhalle@64
|
256 SSR__cleanup_after_shutdown()
|
|
seanhalle@64
|
257 { SSRSemEnv *semanticEnv;
|
|
seanhalle@64
|
258
|
|
seanhalle@64
|
259 semanticEnv = _VMSMasterEnv->semanticEnv;
|
|
seanhalle@64
|
260
|
|
seanhalle@64
|
261 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
|
|
seanhalle@64
|
262 //UCC
|
|
seanhalle@64
|
263 FILE* output;
|
|
seanhalle@64
|
264 int n;
|
|
seanhalle@64
|
265 char filename[255];
|
|
seanhalle@64
|
266 for(n=0;n<255;n++)
|
|
seanhalle@64
|
267 {
|
|
seanhalle@64
|
268 sprintf(filename, "./counters/UCC.%d",n);
|
|
seanhalle@64
|
269 output = fopen(filename,"r");
|
|
seanhalle@64
|
270 if(output)
|
|
seanhalle@64
|
271 {
|
|
seanhalle@64
|
272 fclose(output);
|
|
seanhalle@64
|
273 }else{
|
|
seanhalle@64
|
274 break;
|
|
seanhalle@64
|
275 }
|
|
seanhalle@64
|
276 }
|
|
seanhalle@64
|
277 if(n<255){
|
|
seanhalle@64
|
278 printf("Saving UCC to File: %s ...\n", filename);
|
|
seanhalle@64
|
279 output = fopen(filename,"w+");
|
|
seanhalle@64
|
280 if(output!=NULL){
|
|
seanhalle@64
|
281 set_dependency_file(output);
|
|
seanhalle@64
|
282 //fprintf(output,"digraph Dependencies {\n");
|
|
seanhalle@64
|
283 //set_dot_file(output);
|
|
seanhalle@64
|
284 //FIXME: first line still depends on counters being enabled, replace w/ unit struct!
|
|
seanhalle@64
|
285 //forAllInDynArrayDo(_VMSMasterEnv->counter_history_array_info, &print_dot_node_info );
|
|
seanhalle@64
|
286 forAllInListOfArraysDo(semanticEnv->unitList, &print_unit_to_file);
|
|
seanhalle@64
|
287 forAllInListOfArraysDo( semanticEnv->commDependenciesList, &print_comm_dependency_to_file );
|
|
seanhalle@64
|
288 forAllInListOfArraysDo( semanticEnv->ctlDependenciesList, &print_ctl_dependency_to_file );
|
|
seanhalle@64
|
289 forAllInDynArrayDo(semanticEnv->ntonGroupsInfo,&print_nton_to_file);
|
|
seanhalle@64
|
290 //fprintf(output,"}\n");
|
|
seanhalle@64
|
291 fflush(output);
|
|
seanhalle@64
|
292
|
|
seanhalle@64
|
293 } else
|
|
seanhalle@64
|
294 printf("Opening UCC file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");
|
|
seanhalle@64
|
295 } else {
|
|
seanhalle@64
|
296 printf("Could not open UCC file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
|
|
seanhalle@64
|
297 }
|
|
seanhalle@64
|
298 //Loop Graph
|
|
seanhalle@64
|
299 for(n=0;n<255;n++)
|
|
seanhalle@64
|
300 {
|
|
seanhalle@64
|
301 sprintf(filename, "./counters/LoopGraph.%d",n);
|
|
seanhalle@64
|
302 output = fopen(filename,"r");
|
|
seanhalle@64
|
303 if(output)
|
|
seanhalle@64
|
304 {
|
|
seanhalle@64
|
305 fclose(output);
|
|
seanhalle@64
|
306 }else{
|
|
seanhalle@64
|
307 break;
|
|
seanhalle@64
|
308 }
|
|
seanhalle@64
|
309 }
|
|
seanhalle@64
|
310 if(n<255){
|
|
seanhalle@64
|
311 printf("Saving LoopGraph to File: %s ...\n", filename);
|
|
seanhalle@64
|
312 output = fopen(filename,"w+");
|
|
seanhalle@64
|
313 if(output!=NULL){
|
|
seanhalle@64
|
314 set_dependency_file(output);
|
|
seanhalle@64
|
315 //fprintf(output,"digraph Dependencies {\n");
|
|
seanhalle@64
|
316 //set_dot_file(output);
|
|
seanhalle@64
|
317 //FIXME: first line still depends on counters being enabled, replace w/ unit struct!
|
|
seanhalle@64
|
318 //forAllInDynArrayDo(_VMSMasterEnv->counter_history_array_info, &print_dot_node_info );
|
|
seanhalle@64
|
319 forAllInListOfArraysDo( semanticEnv->unitList, &print_unit_to_file );
|
|
seanhalle@64
|
320 forAllInListOfArraysDo( semanticEnv->commDependenciesList, &print_comm_dependency_to_file );
|
|
seanhalle@64
|
321 forAllInListOfArraysDo( semanticEnv->ctlDependenciesList, &print_ctl_dependency_to_file );
|
|
seanhalle@64
|
322 forAllInListOfArraysDo( semanticEnv->dynDependenciesList, &print_dyn_dependency_to_file );
|
|
seanhalle@64
|
323 forAllInListOfArraysDo( semanticEnv->hwArcs, &print_hw_dependency_to_file );
|
|
seanhalle@64
|
324 //fprintf(output,"}\n");
|
|
seanhalle@64
|
325 fflush(output);
|
|
seanhalle@64
|
326
|
|
seanhalle@64
|
327 } else
|
|
seanhalle@64
|
328 printf("Opening LoopGraph file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");
|
|
seanhalle@64
|
329 } else {
|
|
seanhalle@64
|
330 printf("Could not open LoopGraph file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
|
|
seanhalle@64
|
331 }
|
|
seanhalle@64
|
332
|
|
seanhalle@64
|
333
|
|
seanhalle@64
|
334 freeListOfArrays(semanticEnv->unitList);
|
|
seanhalle@64
|
335 freeListOfArrays(semanticEnv->commDependenciesList);
|
|
seanhalle@64
|
336 freeListOfArrays(semanticEnv->ctlDependenciesList);
|
|
seanhalle@64
|
337 freeListOfArrays(semanticEnv->dynDependenciesList);
|
|
seanhalle@64
|
338
|
|
seanhalle@64
|
339 #endif
|
|
seanhalle@64
|
340 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
|
|
seanhalle@64
|
341 for(n=0;n<255;n++)
|
|
seanhalle@64
|
342 {
|
|
seanhalle@64
|
343 sprintf(filename, "./counters/Counters.%d.csv",n);
|
|
seanhalle@64
|
344 output = fopen(filename,"r");
|
|
seanhalle@64
|
345 if(output)
|
|
seanhalle@64
|
346 {
|
|
seanhalle@64
|
347 fclose(output);
|
|
seanhalle@64
|
348 }else{
|
|
seanhalle@64
|
349 break;
|
|
seanhalle@64
|
350 }
|
|
seanhalle@64
|
351 }
|
|
seanhalle@64
|
352 if(n<255){
|
|
seanhalle@64
|
353 printf("Saving Counter measurements to File: %s ...\n", filename);
|
|
seanhalle@64
|
354 output = fopen(filename,"w+");
|
|
seanhalle@64
|
355 if(output!=NULL){
|
|
seanhalle@64
|
356 set_counter_file(output);
|
|
seanhalle@64
|
357 int i;
|
|
seanhalle@64
|
358 for(i=0;i<NUM_CORES;i++){
|
|
seanhalle@64
|
359 forAllInListOfArraysDo( semanticEnv->counterList[i], &print_counter_events_to_file );
|
|
seanhalle@64
|
360 fflush(output);
|
|
seanhalle@64
|
361 }
|
|
seanhalle@64
|
362
|
|
seanhalle@64
|
363 } else
|
|
seanhalle@64
|
364 printf("Opening UCC file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");
|
|
seanhalle@64
|
365 } else {
|
|
seanhalle@64
|
366 printf("Could not open UCC file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
|
|
seanhalle@64
|
367 }
|
|
seanhalle@64
|
368
|
|
seanhalle@64
|
369 #endif
|
|
seanhalle@64
|
370 /* It's all allocated inside VMS's big chunk -- that's about to be freed, so
|
|
seanhalle@64
|
371 * nothing to do here
|
|
seanhalle@64
|
372
|
|
seanhalle@64
|
373
|
|
seanhalle@64
|
374 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
|
|
seanhalle@64
|
375 {
|
|
seanhalle@64
|
376 VMS_int__free( semanticEnv->readyVPQs[coreIdx]->startOfData );
|
|
seanhalle@64
|
377 VMS_int__free( semanticEnv->readyVPQs[coreIdx] );
|
|
seanhalle@64
|
378 }
|
|
seanhalle@64
|
379 VMS_int__free( semanticEnv->readyVPQs );
|
|
seanhalle@64
|
380
|
|
seanhalle@64
|
381 freeHashTable( semanticEnv->commHashTbl );
|
|
seanhalle@64
|
382 VMS_int__free( _VMSMasterEnv->semanticEnv );
|
|
seanhalle@64
|
383 */
|
|
seanhalle@64
|
384 VMS_SS__cleanup_at_end_of_shutdown();
|
|
seanhalle@64
|
385 }
|
|
seanhalle@64
|
386
|
|
seanhalle@64
|
387
|
|
seanhalle@64
|
388 //===========================================================================
|
|
seanhalle@64
|
389
|
|
seanhalle@64
|
390 /*
|
|
seanhalle@64
|
391 */
|
|
seanhalle@64
|
392 SlaveVP *
|
|
seanhalle@64
|
393 SSR__create_procr_with( TopLevelFnPtr fnPtr, void *initData,
|
|
seanhalle@64
|
394 SlaveVP *creatingPr )
|
|
seanhalle@64
|
395 { SSRSemReq reqData;
|
|
seanhalle@64
|
396
|
|
seanhalle@64
|
397 //the semantic request data is on the stack and disappears when this
|
|
seanhalle@64
|
398 // call returns -- it's guaranteed to remain in the VP's stack for as
|
|
seanhalle@64
|
399 // long as the VP is suspended.
|
|
seanhalle@64
|
400 reqData.reqType = 0; //know type because in a VMS create req
|
|
seanhalle@64
|
401 reqData.coreToAssignOnto = -1; //means round-robin assign
|
|
seanhalle@64
|
402 reqData.fnPtr = fnPtr;
|
|
seanhalle@64
|
403 reqData.initData = initData;
|
|
seanhalle@64
|
404 reqData.sendPr = creatingPr;
|
|
seanhalle@64
|
405
|
|
seanhalle@64
|
406 VMS_WL__send_create_slaveVP_req( &reqData, creatingPr );
|
|
seanhalle@64
|
407
|
|
seanhalle@64
|
408 return creatingPr->dataRetFromReq;
|
|
seanhalle@64
|
409 }
|
|
seanhalle@64
|
410
|
|
seanhalle@64
|
411 SlaveVP *
|
|
seanhalle@64
|
412 SSR__create_procr_with_affinity( TopLevelFnPtr fnPtr, void *initData,
|
|
seanhalle@64
|
413 SlaveVP *creatingPr, int32 coreToAssignOnto )
|
|
seanhalle@64
|
414 { SSRSemReq reqData;
|
|
seanhalle@64
|
415
|
|
seanhalle@64
|
416 //the semantic request data is on the stack and disappears when this
|
|
seanhalle@64
|
417 // call returns -- it's guaranteed to remain in the VP's stack for as
|
|
seanhalle@64
|
418 // long as the VP is suspended.
|
|
seanhalle@64
|
419 reqData.reqType = 0; //know type because in a VMS create req
|
|
seanhalle@64
|
420 reqData.coreToAssignOnto = coreToAssignOnto;
|
|
seanhalle@64
|
421 reqData.fnPtr = fnPtr;
|
|
seanhalle@64
|
422 reqData.initData = initData;
|
|
seanhalle@64
|
423 reqData.sendPr = creatingPr;
|
|
seanhalle@64
|
424
|
|
seanhalle@64
|
425 VMS_WL__send_create_slaveVP_req( &reqData, creatingPr );
|
|
seanhalle@64
|
426
|
|
seanhalle@64
|
427 return creatingPr->dataRetFromReq;
|
|
seanhalle@64
|
428 }
|
|
seanhalle@64
|
429
|
|
seanhalle@64
|
430
|
|
seanhalle@64
|
431 void
|
|
seanhalle@64
|
432 SSR__dissipate_procr( SlaveVP *procrToDissipate )
|
|
seanhalle@64
|
433 {
|
|
seanhalle@64
|
434 VMS_WL__send_dissipate_req( procrToDissipate );
|
|
seanhalle@64
|
435 }
|
|
seanhalle@64
|
436
|
|
seanhalle@64
|
437
|
|
seanhalle@64
|
438 //===========================================================================
|
|
seanhalle@64
|
439
|
|
seanhalle@64
|
440 void *
|
|
seanhalle@64
|
441 SSR__malloc_to( int32 sizeToMalloc, SlaveVP *owningPr )
|
|
seanhalle@64
|
442 { SSRSemReq reqData;
|
|
seanhalle@64
|
443
|
|
seanhalle@64
|
444 reqData.reqType = malloc_req;
|
|
seanhalle@64
|
445 reqData.sendPr = owningPr;
|
|
seanhalle@64
|
446 reqData.sizeToMalloc = sizeToMalloc;
|
|
seanhalle@64
|
447
|
|
seanhalle@64
|
448 VMS_WL__send_sem_request( &reqData, owningPr );
|
|
seanhalle@64
|
449
|
|
seanhalle@64
|
450 return owningPr->dataRetFromReq;
|
|
seanhalle@64
|
451 }
|
|
seanhalle@64
|
452
|
|
seanhalle@64
|
453
|
|
seanhalle@64
|
454 /*Sends request to Master, which does the work of freeing
|
|
seanhalle@64
|
455 */
|
|
seanhalle@64
|
456 void
|
|
seanhalle@64
|
457 SSR__free( void *ptrToFree, SlaveVP *owningPr )
|
|
seanhalle@64
|
458 { SSRSemReq reqData;
|
|
seanhalle@64
|
459
|
|
seanhalle@64
|
460 reqData.reqType = free_req;
|
|
seanhalle@64
|
461 reqData.sendPr = owningPr;
|
|
seanhalle@64
|
462 reqData.ptrToFree = ptrToFree;
|
|
seanhalle@64
|
463
|
|
seanhalle@64
|
464 VMS_WL__send_sem_request( &reqData, owningPr );
|
|
seanhalle@64
|
465 }
|
|
seanhalle@64
|
466
|
|
seanhalle@64
|
467
|
|
seanhalle@64
|
468 void
|
|
seanhalle@64
|
469 SSR__transfer_ownership_of_from_to( void *data, SlaveVP *oldOwnerSlv,
|
|
seanhalle@64
|
470 SlaveVP *newOwnerPr )
|
|
seanhalle@64
|
471 {
|
|
seanhalle@64
|
472 //TODO: put in the ownership system that automatically frees when no
|
|
seanhalle@64
|
473 // owners of data left -- will need keeper for keeping data around when
|
|
seanhalle@64
|
474 // future created processors might need it but don't exist yet
|
|
seanhalle@64
|
475 }
|
|
seanhalle@64
|
476
|
|
seanhalle@64
|
477
|
|
seanhalle@64
|
478 void
|
|
seanhalle@64
|
479 SSR__add_ownership_by_to( SlaveVP *newOwnerSlv, void *data )
|
|
seanhalle@64
|
480 {
|
|
seanhalle@64
|
481
|
|
seanhalle@64
|
482 }
|
|
seanhalle@64
|
483
|
|
seanhalle@64
|
484
|
|
seanhalle@64
|
485 void
|
|
seanhalle@64
|
486 SSR__remove_ownership_by_from( SlaveVP *loserSlv, void *dataLosing )
|
|
seanhalle@64
|
487 {
|
|
seanhalle@64
|
488
|
|
seanhalle@64
|
489 }
|
|
seanhalle@64
|
490
|
|
seanhalle@64
|
491
|
|
seanhalle@64
|
492 /*Causes the SSR system to remove internal ownership, so data won't be
|
|
seanhalle@64
|
493 * freed when SSR shuts down, and will persist in the external program.
|
|
seanhalle@64
|
494 *
|
|
seanhalle@64
|
495 *Must be called from the processor that currently owns the data.
|
|
seanhalle@64
|
496 *
|
|
seanhalle@64
|
497 *IMPL: Transferring ownership touches two different virtual processor's
|
|
seanhalle@64
|
498 * state -- which means it has to be done carefully -- the VMS rules for
|
|
seanhalle@64
|
499 * semantic layers say that a work-unit is only allowed to touch the
|
|
seanhalle@64
|
500 * virtual processor it is part of, and that only a single work-unit per
|
|
seanhalle@64
|
501 * virtual processor be assigned to a slave at a time. So, this has to
|
|
seanhalle@64
|
502 * modify the virtual processor that owns the work-unit that called this
|
|
seanhalle@64
|
503 * function, then create a request to have the other processor modified.
|
|
seanhalle@64
|
504 *However, in this case, the TO processor is the outside, and transfers
|
|
seanhalle@64
|
505 * are only allowed to be called by the giver-upper, so can mark caller of
|
|
seanhalle@64
|
506 * this function as no longer owner, and return -- done.
|
|
seanhalle@64
|
507 */
|
|
seanhalle@64
|
508 void
|
|
seanhalle@64
|
509 SSR__transfer_ownership_to_outside( void *data )
|
|
seanhalle@64
|
510 {
|
|
seanhalle@64
|
511 //TODO: removeAllOwnersFrom( data );
|
|
seanhalle@64
|
512 }
|
|
seanhalle@64
|
513
|
|
seanhalle@64
|
514
|
|
seanhalle@64
|
515 //===========================================================================
|
|
seanhalle@64
|
516
|
|
seanhalle@64
|
517 void
|
|
seanhalle@64
|
518 SSR__send_of_type_to( SlaveVP *sendPr, void *msg, const int type,
|
|
seanhalle@64
|
519 SlaveVP *receivePr)
|
|
seanhalle@64
|
520 { SSRSemReq reqData;
|
|
seanhalle@64
|
521
|
|
seanhalle@64
|
522 reqData.receivePr = receivePr;
|
|
seanhalle@64
|
523 reqData.sendPr = sendPr;
|
|
seanhalle@64
|
524 reqData.reqType = send_type;
|
|
seanhalle@64
|
525 reqData.msgType = type;
|
|
seanhalle@64
|
526 reqData.msg = msg;
|
|
seanhalle@64
|
527 reqData.nextReqInHashEntry = NULL;
|
|
seanhalle@64
|
528
|
|
seanhalle@64
|
529 //On ownership -- remove inside the send and let ownership sit in limbo
|
|
seanhalle@64
|
530 // as a potential in an entry in the hash table, when this receive msg
|
|
seanhalle@64
|
531 // gets paired to a send, the ownership gets added to the receivePr --
|
|
seanhalle@64
|
532 // the next work-unit in the receivePr's trace will have ownership.
|
|
seanhalle@64
|
533 VMS_WL__send_sem_request( &reqData, sendPr );
|
|
seanhalle@64
|
534
|
|
seanhalle@64
|
535 //When come back from suspend, no longer own data reachable from msg
|
|
seanhalle@64
|
536 //TODO: release ownership here
|
|
seanhalle@64
|
537 }
|
|
seanhalle@64
|
538
|
|
seanhalle@64
|
539 void
|
|
seanhalle@64
|
540 SSR__send_from_to( void *msg, SlaveVP *sendPr, SlaveVP *receivePr )
|
|
seanhalle@64
|
541 { SSRSemReq reqData;
|
|
seanhalle@64
|
542
|
|
seanhalle@64
|
543 //hash on the receiver, 'cause always know it, but sometimes want to
|
|
seanhalle@64
|
544 // receive from anonymous sender
|
|
seanhalle@64
|
545
|
|
seanhalle@64
|
546 reqData.receivePr = receivePr;
|
|
seanhalle@64
|
547 reqData.sendPr = sendPr;
|
|
seanhalle@64
|
548 reqData.reqType = send_from_to;
|
|
seanhalle@64
|
549 reqData.msg = msg;
|
|
seanhalle@64
|
550 reqData.nextReqInHashEntry = NULL;
|
|
seanhalle@64
|
551
|
|
seanhalle@64
|
552 VMS_WL__send_sem_request( &reqData, sendPr );
|
|
seanhalle@64
|
553 }
|
|
seanhalle@64
|
554
|
|
seanhalle@64
|
555
|
|
seanhalle@64
|
556 //===========================================================================
|
|
seanhalle@64
|
557
|
|
seanhalle@64
|
558 void *
|
|
seanhalle@64
|
559 SSR__receive_any_to( SlaveVP *receivePr )
|
|
seanhalle@64
|
560 {
|
|
seanhalle@64
|
561
|
|
seanhalle@64
|
562 }
|
|
seanhalle@64
|
563
|
|
seanhalle@64
|
564 void *
|
|
seanhalle@64
|
565 SSR__receive_type_to( const int type, SlaveVP *receivePr )
|
|
seanhalle@67
|
566 { DEBUG__printf1(dbgRqstHdlr,"WL: receive type to: %d", receivePr->slaveID);
|
|
seanhalle@64
|
567 SSRSemReq reqData;
|
|
seanhalle@64
|
568
|
|
seanhalle@64
|
569 reqData.receivePr = receivePr;
|
|
seanhalle@64
|
570 reqData.reqType = receive_type;
|
|
seanhalle@64
|
571 reqData.msgType = type;
|
|
seanhalle@64
|
572 reqData.nextReqInHashEntry = NULL;
|
|
seanhalle@64
|
573
|
|
seanhalle@64
|
574 VMS_WL__send_sem_request( &reqData, receivePr );
|
|
seanhalle@64
|
575
|
|
seanhalle@64
|
576 return receivePr->dataRetFromReq;
|
|
seanhalle@64
|
577 }
|
|
seanhalle@64
|
578
|
|
seanhalle@64
|
579
|
|
seanhalle@64
|
580
|
|
seanhalle@64
|
581 /*Call this at point receiving virt pr wants in-coming data.
|
|
seanhalle@64
|
582 *
|
|
seanhalle@64
|
583 *The reason receivePr must call this is that it modifies the receivPr
|
|
seanhalle@64
|
584 * loc structure directly -- and the VMS rules state a virtual processor
|
|
seanhalle@64
|
585 * loc structure can only be modified by itself.
|
|
seanhalle@64
|
586 */
|
|
seanhalle@64
|
587 void *
|
|
seanhalle@64
|
588 SSR__receive_from_to( SlaveVP *sendPr, SlaveVP *receivePr )
|
|
seanhalle@67
|
589 { DEBUG__printf2(dbgRqstHdlr,"WL: receive from %d to: %d", sendPr->slaveID, receivePr->slaveID);
|
|
seanhalle@67
|
590 SSRSemReq reqData;
|
|
seanhalle@64
|
591
|
|
seanhalle@64
|
592 //hash on the receiver, 'cause always know it, but sometimes want to
|
|
seanhalle@64
|
593 // receive from anonymous sender
|
|
seanhalle@64
|
594
|
|
seanhalle@64
|
595 reqData.receivePr = receivePr;
|
|
seanhalle@64
|
596 reqData.sendPr = sendPr;
|
|
seanhalle@64
|
597 reqData.reqType = receive_from_to;
|
|
seanhalle@64
|
598 reqData.nextReqInHashEntry = NULL;
|
|
seanhalle@64
|
599
|
|
seanhalle@64
|
600 VMS_WL__send_sem_request( &reqData, receivePr );
|
|
seanhalle@64
|
601
|
|
seanhalle@64
|
602 return receivePr->dataRetFromReq;
|
|
seanhalle@64
|
603 }
|
|
seanhalle@64
|
604
|
|
seanhalle@64
|
605
|
|
seanhalle@64
|
606 //===========================================================================
|
|
seanhalle@64
|
607 //
|
|
seanhalle@64
|
608 /*A function singleton is a function whose body executes exactly once, on a
|
|
seanhalle@64
|
609 * single core, no matter how many times the fuction is called and no
|
|
seanhalle@64
|
610 * matter how many cores or the timing of cores calling it.
|
|
seanhalle@64
|
611 *
|
|
seanhalle@64
|
612 *A data singleton is a ticket attached to data. That ticket can be used
|
|
seanhalle@64
|
613 * to get the data through the function exactly once, no matter how many
|
|
seanhalle@64
|
614 * times the data is given to the function, and no matter the timing of
|
|
seanhalle@64
|
615 * trying to get the data through from different cores.
|
|
seanhalle@64
|
616 */
|
|
seanhalle@64
|
617
|
|
seanhalle@64
|
618 /*asm function declarations*/
|
|
seanhalle@64
|
619 void asm_save_ret_to_singleton(SSRSingleton *singletonPtrAddr);
|
|
seanhalle@64
|
620 void asm_write_ret_from_singleton(SSRSingleton *singletonPtrAddr);
|
|
seanhalle@64
|
621
|
|
seanhalle@64
|
622 /*Fn singleton uses ID as index into array of singleton structs held in the
|
|
seanhalle@64
|
623 * semantic environment.
|
|
seanhalle@64
|
624 */
|
|
seanhalle@64
|
625 void
|
|
seanhalle@64
|
626 SSR__start_fn_singleton( int32 singletonID, SlaveVP *animPr )
|
|
seanhalle@64
|
627 {
|
|
seanhalle@64
|
628 SSRSemReq reqData;
|
|
seanhalle@64
|
629
|
|
seanhalle@64
|
630 //
|
|
seanhalle@64
|
631 reqData.reqType = singleton_fn_start;
|
|
seanhalle@64
|
632 reqData.singletonID = singletonID;
|
|
seanhalle@64
|
633
|
|
seanhalle@64
|
634 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
635 if( animPr->dataRetFromReq ) //will be 0 or addr of label in end singleton
|
|
seanhalle@64
|
636 {
|
|
seanhalle@64
|
637 SSRSemEnv *semEnv = VMS_int__give_sem_env_for( animPr );
|
|
seanhalle@64
|
638 asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID]));
|
|
seanhalle@64
|
639 }
|
|
seanhalle@64
|
640 }
|
|
seanhalle@64
|
641
|
|
seanhalle@64
|
642 /*Data singleton hands addr of loc holding a pointer to a singleton struct.
|
|
seanhalle@64
|
643 * The start_data_singleton makes the structure and puts its addr into the
|
|
seanhalle@64
|
644 * location.
|
|
seanhalle@64
|
645 */
|
|
seanhalle@64
|
646 void
|
|
seanhalle@64
|
647 SSR__start_data_singleton( SSRSingleton **singletonAddr, SlaveVP *animPr )
|
|
seanhalle@64
|
648 {
|
|
seanhalle@64
|
649 SSRSemReq reqData;
|
|
seanhalle@64
|
650
|
|
seanhalle@64
|
651 if( *singletonAddr && (*singletonAddr)->hasFinished )
|
|
seanhalle@64
|
652 goto JmpToEndSingleton;
|
|
seanhalle@64
|
653
|
|
seanhalle@64
|
654 reqData.reqType = singleton_data_start;
|
|
seanhalle@64
|
655 reqData.singletonPtrAddr = singletonAddr;
|
|
seanhalle@64
|
656
|
|
seanhalle@64
|
657 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
658 if( animPr->dataRetFromReq ) //either 0 or end singleton's return addr
|
|
seanhalle@64
|
659 { //Assembly code changes the return addr on the stack to the one
|
|
seanhalle@64
|
660 // saved into the singleton by the end-singleton-fn
|
|
seanhalle@64
|
661 //The return addr is at 0x4(%%ebp)
|
|
seanhalle@64
|
662 JmpToEndSingleton:
|
|
seanhalle@64
|
663 asm_write_ret_from_singleton(*singletonAddr);
|
|
seanhalle@64
|
664 }
|
|
seanhalle@64
|
665 //now, simply return
|
|
seanhalle@64
|
666 //will exit either from the start singleton call or the end-singleton call
|
|
seanhalle@64
|
667 }
|
|
seanhalle@64
|
668
|
|
seanhalle@64
|
669 /*Uses ID as index into array of flags. If flag already set, resumes from
|
|
seanhalle@64
|
670 * end-label. Else, sets flag and resumes normally.
|
|
seanhalle@64
|
671 *
|
|
seanhalle@64
|
672 *Note, this call cannot be inlined because the instr addr at the label
|
|
seanhalle@64
|
673 * inside is shared by all invocations of a given singleton ID.
|
|
seanhalle@64
|
674 */
|
|
seanhalle@64
|
675 void
|
|
seanhalle@64
|
676 SSR__end_fn_singleton( int32 singletonID, SlaveVP *animPr )
|
|
seanhalle@64
|
677 {
|
|
seanhalle@64
|
678 SSRSemReq reqData;
|
|
seanhalle@64
|
679
|
|
seanhalle@64
|
680 //don't need this addr until after at least one singleton has reached
|
|
seanhalle@64
|
681 // this function
|
|
seanhalle@64
|
682 SSRSemEnv *semEnv = VMS_int__give_sem_env_for( animPr );
|
|
seanhalle@64
|
683 asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID]));
|
|
seanhalle@64
|
684
|
|
seanhalle@64
|
685 reqData.reqType = singleton_fn_end;
|
|
seanhalle@64
|
686 reqData.singletonID = singletonID;
|
|
seanhalle@64
|
687
|
|
seanhalle@64
|
688 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
689
|
|
seanhalle@64
|
690 EndSingletonInstrAddr:
|
|
seanhalle@64
|
691 return;
|
|
seanhalle@64
|
692 }
|
|
seanhalle@64
|
693
|
|
seanhalle@64
|
694 void
|
|
seanhalle@64
|
695 SSR__end_data_singleton( SSRSingleton **singletonPtrAddr, SlaveVP *animPr )
|
|
seanhalle@64
|
696 {
|
|
seanhalle@64
|
697 SSRSemReq reqData;
|
|
seanhalle@64
|
698
|
|
seanhalle@64
|
699 //don't need this addr until after singleton struct has reached
|
|
seanhalle@64
|
700 // this function for first time
|
|
seanhalle@64
|
701 //do assembly that saves the return addr of this fn call into the
|
|
seanhalle@64
|
702 // data singleton -- that data-singleton can only be given to exactly
|
|
seanhalle@64
|
703 // one instance in the code of this function. However, can use this
|
|
seanhalle@64
|
704 // function in different places for different data-singletons.
|
|
seanhalle@64
|
705 // (*(singletonAddr))->endInstrAddr = &&EndDataSingletonInstrAddr;
|
|
seanhalle@64
|
706
|
|
seanhalle@64
|
707
|
|
seanhalle@64
|
708 asm_save_ret_to_singleton(*singletonPtrAddr);
|
|
seanhalle@64
|
709
|
|
seanhalle@64
|
710 reqData.reqType = singleton_data_end;
|
|
seanhalle@64
|
711 reqData.singletonPtrAddr = singletonPtrAddr;
|
|
seanhalle@64
|
712
|
|
seanhalle@64
|
713 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
714 }
|
|
seanhalle@64
|
715
|
|
seanhalle@64
|
716 /*This executes the function in the masterVP, so it executes in isolation
|
|
seanhalle@64
|
717 * from any other copies -- only one copy of the function can ever execute
|
|
seanhalle@64
|
718 * at a time.
|
|
seanhalle@64
|
719 *
|
|
seanhalle@64
|
720 *It suspends to the master, and the request handler takes the function
|
|
seanhalle@64
|
721 * pointer out of the request and calls it, then resumes the VP.
|
|
seanhalle@64
|
722 *Only very short functions should be called this way -- for longer-running
|
|
seanhalle@64
|
723 * isolation, use transaction-start and transaction-end, which run the code
|
|
seanhalle@64
|
724 * between as work-code.
|
|
seanhalle@64
|
725 */
|
|
seanhalle@64
|
726 void
|
|
seanhalle@64
|
727 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
|
|
seanhalle@64
|
728 void *data, SlaveVP *animPr )
|
|
seanhalle@64
|
729 {
|
|
seanhalle@64
|
730 SSRSemReq reqData;
|
|
seanhalle@64
|
731
|
|
seanhalle@64
|
732 //
|
|
seanhalle@64
|
733 reqData.reqType = atomic;
|
|
seanhalle@64
|
734 reqData.fnToExecInMaster = ptrToFnToExecInMaster;
|
|
seanhalle@64
|
735 reqData.dataForFn = data;
|
|
seanhalle@64
|
736
|
|
seanhalle@64
|
737 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
738 }
|
|
seanhalle@64
|
739
|
|
seanhalle@64
|
740
|
|
seanhalle@64
|
741 /*This suspends to the master.
|
|
seanhalle@64
|
742 *First, it looks at the VP's data, to see the highest transactionID that VP
|
|
seanhalle@64
|
743 * already has entered. If the current ID is not larger, it throws an
|
|
seanhalle@64
|
744 * exception stating a bug in the code. Otherwise it puts the current ID
|
|
seanhalle@64
|
745 * there, and adds the ID to a linked list of IDs entered -- the list is
|
|
seanhalle@64
|
746 * used to check that exits are properly ordered.
|
|
seanhalle@64
|
747 *Next it is uses transactionID as index into an array of transaction
|
|
seanhalle@64
|
748 * structures.
|
|
seanhalle@64
|
749 *If the "VP_currently_executing" field is non-null, then put requesting VP
|
|
seanhalle@64
|
750 * into queue in the struct. (At some point a holder will request
|
|
seanhalle@64
|
751 * end-transaction, which will take this VP from the queue and resume it.)
|
|
seanhalle@64
|
752 *If NULL, then write requesting into the field and resume.
|
|
seanhalle@64
|
753 */
|
|
seanhalle@64
|
754 void
|
|
seanhalle@64
|
755 SSR__start_transaction( int32 transactionID, SlaveVP *animPr )
|
|
seanhalle@64
|
756 {
|
|
seanhalle@64
|
757 SSRSemReq reqData;
|
|
seanhalle@64
|
758
|
|
seanhalle@64
|
759 //
|
|
seanhalle@64
|
760 reqData.sendPr = animPr;
|
|
seanhalle@64
|
761 reqData.reqType = trans_start;
|
|
seanhalle@64
|
762 reqData.transID = transactionID;
|
|
seanhalle@64
|
763
|
|
seanhalle@64
|
764 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
765 }
|
|
seanhalle@64
|
766
|
|
seanhalle@64
|
767 /*This suspends to the master, then uses transactionID as index into an
|
|
seanhalle@64
|
768 * array of transaction structures.
|
|
seanhalle@64
|
769 *It looks at VP_currently_executing to be sure it's same as requesting VP.
|
|
seanhalle@64
|
770 * If different, throws an exception, stating there's a bug in the code.
|
|
seanhalle@64
|
771 *Next it looks at the queue in the structure.
|
|
seanhalle@64
|
772 *If it's empty, it sets VP_currently_executing field to NULL and resumes.
|
|
seanhalle@64
|
773 *If something in, gets it, sets VP_currently_executing to that VP, then
|
|
seanhalle@64
|
774 * resumes both.
|
|
seanhalle@64
|
775 */
|
|
seanhalle@64
|
776 void
|
|
seanhalle@64
|
777 SSR__end_transaction( int32 transactionID, SlaveVP *animPr )
|
|
seanhalle@64
|
778 {
|
|
seanhalle@64
|
779 SSRSemReq reqData;
|
|
seanhalle@64
|
780
|
|
seanhalle@64
|
781 //
|
|
seanhalle@64
|
782 reqData.sendPr = animPr;
|
|
seanhalle@64
|
783 reqData.reqType = trans_end;
|
|
seanhalle@64
|
784 reqData.transID = transactionID;
|
|
seanhalle@64
|
785
|
|
seanhalle@64
|
786 VMS_WL__send_sem_request( &reqData, animPr );
|
|
seanhalle@64
|
787 }
|