1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 
11 
12 #include "instrument.h"
13 #include <dx/dx.h>
14 
15 #ifdef INSTRUMENT
16 Instrumentation	*exInstrument;
17 int 		exDoInstrumentation = 1;
18 static int	instNprocs = 0;
19 
20 void
ExResetInstrument(void)21 ExResetInstrument(void)
22 {
23     int i;
24 
25     for (i = 0; i < instNprocs; ++i) {
26 	exInstrument[i].tasks		= 0;
27 	exInstrument[i].modules		= 0;
28 	exInstrument[i].numSlaveTry	= 0;
29 	exInstrument[i].numMasterTry	= 0;
30     }
31 }
32 
33 void
ExAllocateInstrument(int nprocs)34 ExAllocateInstrument(int nprocs)
35 {
36     instNprocs = nprocs;
37     exInstrument = (Instrumentation*) DXAllocate
38 	(sizeof (Instrumentation) * instNprocs);
39     ExResetInstrument();
40 }
41 
42 void
ExFreeInstrument(void)43 ExFreeInstrument(void)
44 {
45     DXFree ((Pointer)exInstrument);
46 }
47 
48 void
ExPrintInstrument(void)49 ExPrintInstrument(void)
50 {
51     int i;
52     float taskSum;
53     float moduleSum;
54     int minTasks;
55     int maxTasks;
56     int minMods;
57     int maxMods;
58 
59     if (!exDoInstrumentation)
60 	return;
61 
62     taskSum = 0;
63     moduleSum = 0;
64     maxTasks = minTasks = exInstrument[0].tasks;
65     maxMods = minMods = exInstrument[0].modules;
66     for (i = 0; i < instNprocs; ++i) {
67 	DXMessage ("#1240", i, exInstrument[i].tasks, exInstrument[i].modules);
68 	maxTasks = MAX(maxTasks, exInstrument[i].tasks);
69 	minTasks = MIN(minTasks, exInstrument[i].tasks);
70 	maxMods = MAX(maxMods, exInstrument[i].modules);
71 	minMods = MIN(minMods, exInstrument[i].modules);
72 	taskSum += exInstrument[i].tasks;
73 	moduleSum += exInstrument[i].modules;
74     }
75     DXMessage ("#1250", taskSum / instNprocs, minTasks, maxTasks);
76     DXMessage ("#1260", moduleSum / instNprocs, minMods, maxMods);
77 
78     for (i = 0; i < instNprocs; ++i) {
79 	DXMessage ("#1270", i, exInstrument[i].numSlaveTry,
80 	    exInstrument[i].numMasterTry);
81     }
82 }
83 #endif
84