[Swift-commit] r5728 - SwiftApps/SciColSim

wilde at ci.uchicago.edu wilde at ci.uchicago.edu
Mon Mar 26 18:10:25 CDT 2012


Author: wilde
Date: 2012-03-26 18:10:25 -0500 (Mon, 26 Mar 2012)
New Revision: 5728

Modified:
   SwiftApps/SciColSim/Makefile
   SwiftApps/SciColSim/optimizer.cpp
   SwiftApps/SciColSim/testopt.py
Log:
Changed optimizer.cpp to run all reruns across all workers. Added -O and static to makefile. Adjusted testopt.py to test optimizer.cpp change.

Modified: SwiftApps/SciColSim/Makefile
===================================================================
--- SwiftApps/SciColSim/Makefile	2012-03-26 17:07:08 UTC (rev 5727)
+++ SwiftApps/SciColSim/Makefile	2012-03-26 23:10:25 UTC (rev 5728)
@@ -5,7 +5,7 @@
 all:	openmp-optimizer
 
 openmp-optimizer: optimizer.cpp
-	g++ -DP_OPENMP -fopenmp -I boost_1_47_0 -o openmp-optimizer optimizer.cpp
+	g++ -DP_OPENMP -static -O -fopenmp -I boost_1_47_0 -o openmp-optimizer optimizer.cpp
 
 clean:
 	@rm -rvf openmp-optimizer

Modified: SwiftApps/SciColSim/optimizer.cpp
===================================================================
--- SwiftApps/SciColSim/optimizer.cpp	2012-03-26 17:07:08 UTC (rev 5727)
+++ SwiftApps/SciColSim/optimizer.cpp	2012-03-26 23:10:25 UTC (rev 5728)
@@ -11,6 +11,8 @@
 #define MAXNworkers 24
 int Nworkers=MAXNworkers;
 
+#define NUniverse 240
+
 // Add operation code to enable existing code to be used at lower level from Swift scripts:
 
 char operation = 'n'; // n: normal; m: do one multi_loss (with n_reruns).
@@ -1008,7 +1010,6 @@
                 }
                 ratio = current_loss/current_novelty;
             }
-
             if( check ){
                 storage[k]=ALOT;
             }
@@ -1346,7 +1347,12 @@
     double elapsedTime;
     gettimeofday(&startTime, NULL);
 
-    for(int i=0; i<Nworkers; i++){
+    if ( N > NUniverse ) {
+      std::cerr << "Error: Number of reruns=" << N << " is greater than max NUniverse=" << NUniverse << "\n";
+      exit(1);
+    }
+
+    for(int i=0; i<N; i++){
         for(int j=0; j<5; j++){
             un[i]->set_parameter(params[j],j);
         }
@@ -1371,30 +1377,19 @@
 #else
     int i;
 
-    // Print debug in serial code to get coherent trace output
+    // Execute rerun loop in parallel
 
-    for(i=0; i<Nworkers; i++){
-        std::cout<<"multi_loss: Calling evolve_to_target_and_save i=" << i << " N=" << N << " step=" << step << " istart=" << i*step\
-	       << " iend=" << (i+1)*step << "\n";
-     }
-
-    // Execute actual loop in parallel
-
     #pragma omp parallel for private (i)
-    for(i=0; i<Nworkers; i++){
-        un[i]->evolve_to_target_and_save(i*step, min((i+1)*step,N), Results, Counters);
+    for(i=0; i<N; i++){
+        un[i]->evolve_to_target_and_save(i, i+1, Results, Counters);
      }
 #endif
 
     for (int i=0; i<N; i++){
-
         Loss+=Results[i]/(double)N;
         LossSquare+=Results[i]*Results[i]/(double)N;
-
-        // std::cout<<" " << Results[i];
     }
 
-    //std::cout<<" \n\n\n";
     double two_std = ((LossSquare - Loss*Loss)/(double)N);
 
     two_std = 2.*sqrt(two_std);
@@ -1409,8 +1404,6 @@
     cout << "multi_loss(N=" << N << ", target=" << un[0]->get_target() << ") elapsed time: " << elapsedTime << " seconds " << elapsedTime/60. << " minutes\n\n";
 
     return Res;
-
-
 }
 //============================================================
 
@@ -1673,7 +1666,7 @@
 
     int verbose_level = 2;
     const std::string one="one", two="two";
-    static Universe* un[MAXNworkers];
+    static Universe* un[NUniverse];
 #ifdef P_DISPATCH
     static dispatch_queue_t CustomQueues[MAXNworkers];
 #endif
@@ -1751,7 +1744,7 @@
 
     //...............................
 
-    for(int i=0; i<Nworkers; i++){
+    for(int i=0; i<NUniverse; i++){
         un[i] = new Universe((char *)filename,n_ep,n_st,
                              (int)n_rep,
                              identify_failed, target, i2string(i));

Modified: SwiftApps/SciColSim/testopt.py
===================================================================
--- SwiftApps/SciColSim/testopt.py	2012-03-26 17:07:08 UTC (rev 5727)
+++ SwiftApps/SciColSim/testopt.py	2012-03-26 23:10:25 UTC (rev 5728)
@@ -117,12 +117,12 @@
 elif paramset == "mw2":  # Timing TEST PARAMETERS by Mike
   
   startTarget      = 58
-  endTarget        = 1009
+  endTarget        = 209
   incrTarget       = 50
   optimizerRepeats = 1
-  evolveReruns     = 4
+  evolveReruns     = 240
   annealingSteps   = 1
-  NWorkers         = "4"
+  NWorkers         = "8"
   openmp           = "OMP_NUM_THREADS=" + NWorkers
   operation        = "m"  # n=normal, m=manual (runs 1 multi_loss call)
   seed             = "123456"




More information about the Swift-commit mailing list