adding a test case
[IRC.git] / Robust / src / Benchmarks / Prefetch / SOR / dsm / JGFInstrumentor.java
1 /**************************************************************************
2  *                                                                         *
3  *         Java Grande Forum Benchmark Suite - Thread Version 1.0          *
4  *                                                                         *
5  *                            produced by                                  *
6  *                                                                         *
7  *                  Java Grande Benchmarking Project                       *
8  *                                                                         *
9  *                                at                                       *
10  *                                                                         *
11  *                Edinburgh Parallel Computing Centre                      *
12  *                                                                         * 
13  *                email: epcc-javagrande@epcc.ed.ac.uk                     *
14  *                                                                         *
15  *                                                                         *
16  *      This version copyright (c) The University of Edinburgh, 1999.      *
17  *                         All rights reserved.                            *
18  *                                                                         *
19  **************************************************************************/
20 public class JGFInstrumentor{
21
22   protected HashMap timers;
23   protected HashMap data; 
24
25   public JGFInstrumentor() {
26     timers = new HashMap();
27     data = new HashMap(); 
28   }
29
30   public static void addTimer (String name, HashMap timers){
31
32     if (timers.containsKey(name)) {
33       System.printString("JGFInstrumentor.addTimer: warning -  timer " + name + 
34           " already exists\n");
35     }
36     else {
37       timers.put(name, new JGFTimer(name));
38     }
39   }
40
41   public static void addTimer (String name, String opname, HashMap timers){
42
43     if (timers.containsKey(name)) {
44       System.printString("JGFInstrumentor.addTimer: warning -  timer " + name + 
45           " already exists\n");
46     }
47     else {
48       timers.put(name, new JGFTimer(name,opname));
49     }
50
51   }
52
53   public static void addTimer (String name, String opname, int size, HashMap timers){
54
55     if (timers.containsKey(name)) {
56       System.printString("JGFInstrumentor.addTimer: warning -  timer " + name +
57           " already exists\n");
58     }
59     else {
60       timers.put(name, new JGFTimer(name,opname,size));
61     }
62
63   }
64
65   public static void startTimer(String name, HashMap timers){
66     if (timers.containsKey(name)) {
67       ((JGFTimer) timers.get(name)).start();
68     }
69     else {
70       System.printString("JGFInstrumentor.startTimer: failed -  timer " + name + 
71           " does not exist\n");
72     }
73
74   }
75
76   public static void stopTimer(String name, HashMap timers){
77     if (timers.containsKey(name)) {
78       ((JGFTimer) timers.get(name)).stop();
79     }
80     else {
81       System.printString("JGFInstrumentor.stopTimer: failed -  timer " + name + 
82           " does not exist\n");
83     }
84   }
85
86   public static void addOpsToTimer(String name, double count, HashMap timers){
87     if (timers.containsKey(name)) {
88       ((JGFTimer) timers.get(name)).addops(count);
89     }
90     else {
91       System.printString("JGFInstrumentor.addOpsToTimer: failed -  timer " + name + 
92           " does not exist\n");
93     }
94   }  
95
96   public static void addTimeToTimer(String name, double added_time, HashMap timers){
97     if (timers.containsKey(name)) {
98       ((JGFTimer) timers.get(name)).addtime(added_time);
99     }
100     else {
101       System.printString("JGFInstrumentor.addTimeToTimer: failed -  timer " + name +
102           " does not exist\n");
103     }
104
105
106
107   }
108
109   public static double readTimer(String name, HashMap timers){
110     double time; 
111     if (timers.containsKey(name)) {
112       time = ((JGFTimer) timers.get(name)).time;
113     }
114     else {
115       System.printString("JGFInstrumentor.readTimer: failed -  timer " + name + 
116           " does not exist\n");
117       time = 0.0; 
118     }
119     return time; 
120   }  
121
122   public static void resetTimer(String name, HashMap timers){
123     if (timers.containsKey(name)) {
124       ((JGFTimer) timers.get(name)).reset();
125     }
126     else {
127       System.printString("JGFInstrumentor.resetTimer: failed -  timer " + name +
128           " does not exist\n");
129     }
130   }
131
132   public static void printTimer(String name, HashMap timers){
133     if (timers.containsKey(name)) {
134       ((JGFTimer) timers.get(name)).print();
135     }
136     else {
137       System.printString("JGFInstrumentor.printTimer: failed -  timer " + name +
138           " does not exist\n");
139     }
140   }
141
142   public static void printperfTimer(String name, HashMap timers){
143     if (timers.containsKey(name)) {
144       ((JGFTimer) timers.get(name)).printperf();
145     }
146     else {
147       System.printString("JGFInstrumentor.printTimer: failed -  timer " + name +
148           " does not exist\n");
149     }
150   }
151
152   public static void storeData(String name, Object obj, HashMap data){
153     data.put(name,obj); 
154   }
155
156   public static void retrieveData(String name, Object obj, HashMap data){
157     obj = data.get(name); 
158   }
159
160   public static void printHeader(int section, int size,int nthreads) {
161
162     String header, base; 
163
164     header = "";
165     base = "Java Grande Forum Thread Benchmark Suite - Version 1.0 - Section "; 
166
167     if (section == 1)
168     {
169       header = base + "1";
170     }
171     else if (section == 2)
172     {
173       if (size == 0)
174         header = base + "2 - Size A";
175       else if (size == 1)
176         header = base + "2 - Size B";
177       else if (size == 2)
178         header = base + "2 - Size C";
179     }
180     else if (section == 3)
181     {
182       if (size == 0)
183         header = base + "3 - Size A";
184       else if (size == 1)
185         header = base + "3 - Size B";
186     }
187
188     System.printString(header+"\n"); 
189
190     if (nthreads == 1) {
191       System.printString("Executing on " + nthreads + " thread\n");
192     }
193     else {
194       System.printString("Executing on " + nthreads + " threads\n");
195     }
196
197     System.printString("\n");
198   } 
199 }