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