check in latest versions
[IRC.git] / Robust / src / Benchmarks / Prefetch / threadv1.0 / section2 / crypt / JGFCryptBench.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, 2001.      *
17 *                         All rights reserved.                            *
18 *                                                                         *
19 **************************************************************************/
20 /**************************************************************************
21 *                       Ported for DSTM Benchmark                         *
22 **************************************************************************/
23
24
25 package crypt;
26 import jgfutil.*; 
27
28
29 public class JGFCryptBench extends IDEATest { 
30
31   private int size; 
32   private int datasizes[];
33   public int nthreads;
34   global JGFInstrumentor instr;
35
36   public JGFCryptBench(int nthreads, JGFInstrumentor instr)
37   {
38     this.nthreads = nthreads;
39     this.instr = instr;
40     datasizes = new int[3];
41     datasizes[0] = 3000000;
42     datasizes[1] = 20000000;
43     datasizes[2] = 50000000;
44   }
45
46
47   public void JGFsetsize(int size){
48     this.size = size;
49   }
50
51   public void JGFinitialise(){
52     array_rows = datasizes[size];
53     buildTestData();
54   }
55  
56   public void JGFkernel(){
57     Do(); 
58   }
59
60   public void JGFvalidate(){
61     boolean error;
62
63     error = false; 
64     for (int i = 0; i < array_rows; i++){
65       error = (plain1 [i] != plain2 [i]); 
66       if (error){
67         System.printString("Validation failed");
68         System.printString("Original Byte " + i + " = " + plain1[i]); 
69         System.printString("Encrypted Byte " + i + " = " + crypt1[i]); 
70         System.printString("Decrypted Byte " + i + " = " + plain2[i]); 
71         //break;
72       }
73     }
74   }
75
76
77   public void JGFtidyup(){
78     freeTestData(); 
79   }  
80
81
82
83   public void JGFrun(int size){
84
85
86     instr.addTimer("Section2:Crypt:Kernel", "Kbyte",size);
87
88     JGFsetsize(size); 
89     JGFinitialise(); 
90     JGFkernel(); 
91     JGFvalidate(); 
92     JGFtidyup(); 
93
94      
95     instr.addOpsToTimer("Section2:Crypt:Kernel", (2*array_rows)/1000.); 
96     instr.printTimer("Section2:Crypt:Kernel"); 
97   }
98 }