optimized version of crypt benchmark.
authoryeom <yeom>
Fri, 30 Jul 2010 19:30:56 +0000 (19:30 +0000)
committeryeom <yeom>
Fri, 30 Jul 2010 19:30:56 +0000 (19:30 +0000)
Robust/src/Benchmarks/oooJava/crypt/JGFCryptBench.java
Robust/src/Benchmarks/oooJava/crypt/makefile

index 37498d51af4ff8287b9af2fcff654c4d84e6d743..bff8a236ddd77673341836b857638eee7894db0d 100644 (file)
@@ -292,33 +292,35 @@ public class JGFCryptBench {
   }
 
   public void JGFkernel(){
-     
     byte [] crypt1 =  new byte [array_rows];
     byte [] plain2 =  new byte [array_rows];
 
     int nW=nWorker;
     // Encrypt plain1.    
-    int  ilow, iupper, slice, tslice, ttslice; 
+    int  slice, tslice, ttslice; 
     tslice = plain1.length / 8;
     ttslice = (tslice + nWorker-1) / nWorker;
     slice = ttslice*8;
  
     for(int i=0;i<nW;i++) {
       // setup worker
-      ilow = i*slice;
-      iupper = (i+1)*slice;
-      if(iupper > plain1.length) iupper = plain1.length;
-      int localSize=iupper-ilow;
-      byte local_crypt1[] =  new byte [localSize];     
-      
       sese parallel_e{
+        int ilow = i*slice;
+        int iupper = (i+1)*slice;
+        if(iupper > plain1.length) iupper = plain1.length;
+        int localSize=iupper-ilow;
+        byte local_crypt1[] =  new byte [localSize]; 
         IDEARunner runner=new IDEARunner(i,plain1,local_crypt1,localSize,Z,nWorker);
         runner.run();
       }
       
       sese serial_e{
-        for(int idx=0;idx<runner.local_size;idx++){
+        if(true){
+          System.arraycopy(runner.text2, 0, crypt1, ilow, runner.local_size);
+        }else{
+          for(int idx=0;idx<runner.local_size;idx++){
           crypt1[ilow+idx]=runner.text2[idx];
+          }
         }
       }      
       
@@ -326,25 +328,29 @@ public class JGFCryptBench {
     
     // Decrypt.
     for(int i=0;i<nW;i++) {
-      ilow = i*slice;
-      iupper = (i+1)*slice;
-      if(iupper > crypt1.length) iupper = crypt1.length;
-      int localSize=iupper-ilow;
-      byte local_plain2[] =  new byte [localSize];     
-
-      IDEARunner runner=new IDEARunner(i,crypt1,local_plain2,localSize,DK,nWorker);       
 
       sese parallel_d{
+        int ilow = i*slice;
+        int iupper = (i+1)*slice;
+        if(iupper > crypt1.length) iupper = crypt1.length;
+        int localSize=iupper-ilow;
+        byte local_plain2[] =  new byte [localSize];     
+        IDEARunner runner=new IDEARunner(i,crypt1,local_plain2,localSize,DK,nWorker);       
         runner.run();
       }
+      
       sese serial_d{
-        for(int idx=0;idx<runner.local_size;idx++){
-          plain2[ilow+idx]=runner.text2[idx];
-        }
+        if(true){
+          System.arraycopy(runner.text2, 0, plain2, ilow, runner.local_size);
+        }else{
+          for(int idx=0;idx<runner.local_size;idx++){
+            plain2[ilow+idx]=runner.text2[idx];
+          }
+        }        
       }
+      
     }   
-    
-    
+
     boolean error = false; 
     for (int i = 0; i < array_rows; i++){
       error = (plain1 [i] != plain2 [i]); 
@@ -357,18 +363,21 @@ public class JGFCryptBench {
       }
     }
     System.out.println("Validation Success");
-
   }
 
   public void JGFrun(int size, int nWorker) {
 
     JGFsetsize(size, nWorker);
+    long startT=System.currentTimeMillis();
     JGFinitialise();
+    long endT=System.currentTimeMillis();
     JGFkernel();
-
+    
+    System.out.println("init="+(endT-startT));
   }
 
   public static void main(String argv[]) {
+    
 
     JGFCryptBench cb = new JGFCryptBench();
 
index 8dfe092fcc512702cfe316d33832318f04711e87..ee571c5106411152e41d6d08a1064994316eec44 100644 (file)
@@ -6,7 +6,7 @@ SOURCE_FILES=JGFCryptBench.java
 BUILDSCRIPT=../../../buildscript
 
 #USEOOO= -ooojava 8 2  -ooodebug  
-#BSFLAGS= -32bit -nooptimize -mainclass test -garbagestats -joptimize #-debug
+#BSFLAGS= -64bit -nooptimize -mainclass $(PROGRAM) -garbagestats #-joptimize -debug
 USEOOO= -ooojava 24 2  -ooodebug  
 BSFLAGS= -64bit -mainclass $(PROGRAM) -garbagestats -joptimize
 DISJOINT= -disjoint -disjoint-k 1 -enable-assertions 
@@ -15,7 +15,7 @@ default:
        $(BUILDSCRIPT) -nojava $(USEOOO) $(BSFLAGS) $(DISJOINT) -o $(PROGRAM)p $(SOURCE_FILES) -builddir par
 
 single:
-       $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM)s -builddir sing $(SOURCE_FILES) 
+       $(BUILDSCRIPT) $(BSFLAGS) -thread -o $(PROGRAM)s -builddir sing $(SOURCE_FILES) 
 
 ooo:
        $(BUILDSCRIPT) $(USEOOO) $(BSFLAGS) $(DISJOINT) -o $(PROGRAM)p -builddir par $(SOURCE_FILES)