[Swift-commit] r6105 - SwiftApps/SciColSim

wilde at ci.uchicago.edu wilde at ci.uchicago.edu
Mon Dec 17 14:43:23 CST 2012


Author: wilde
Date: 2012-12-17 14:43:22 -0600 (Mon, 17 Dec 2012)
New Revision: 6105

Modified:
   SwiftApps/SciColSim/Makefile
   SwiftApps/SciColSim/gengraphs.sh
   SwiftApps/SciColSim/graphsim.cpp
   SwiftApps/SciColSim/testgraph.py
   SwiftApps/SciColSim/trimgraph.sh
Log:
Updates for graph testing.

Modified: SwiftApps/SciColSim/Makefile
===================================================================
--- SwiftApps/SciColSim/Makefile	2012-12-13 23:38:53 UTC (rev 6104)
+++ SwiftApps/SciColSim/Makefile	2012-12-17 20:43:22 UTC (rev 6105)
@@ -2,7 +2,7 @@
 
 ifeq ($(UNAME), Linux)
 
-all:	openmp-optimizer graphsim
+all:	openmp-optimizer graphsim openmptest
 
 openmp-optimizer: optimizer.cpp
 	g++ -DP_OPENMP -static -O -fopenmp -I boost_1_47_0 -o openmp-optimizer optimizer.cpp
@@ -10,6 +10,9 @@
 graphsim: graphsim.cpp
 	g++ -DP_OPENMP -static -pg -O -fopenmp -I boost_1_47_0 -o graphsim graphsim.cpp
 
+openmptest: openmptest.cpp
+	g++ -DP_OPENMP -static -O -fopenmp -o openmptest openmptest.cpp
+
 clean:
 	@rm -rvf openmp-optimizer
 
@@ -17,11 +20,17 @@
 
 ifeq ($(UNAME), Darwin)
 
-all:	openmp-optimizer dispatch-optimizer orig-optimizer
+all:	openmp-optimizer dispatch-optimizer orig-optimizer graphsim openmptest
 
 openmp-optimizer: optimizer.cpp
 	g++ -DP_OPENMP -fopenmp -I boost_1_47_0 -o openmp-optimizer optimizer.cpp
 
+graphsim: graphsim.cpp
+	g++ -DP_OPENMP -fopenmp -I boost_1_47_0 -g -o graphsim graphsim.cpp
+
+openmptest: openmptest.cpp
+	g++ -DP_OPENMP -fopenmp  -g -o openmptest openmptest.cpp
+
 dispatch-optimizer: optimizer.cpp
 	g++ -DP_DISPATCH -I boost_1_47_0 -o dispatch-optimizer optimizer.cpp
 

Modified: SwiftApps/SciColSim/gengraphs.sh
===================================================================
--- SwiftApps/SciColSim/gengraphs.sh	2012-12-13 23:38:53 UTC (rev 6104)
+++ SwiftApps/SciColSim/gengraphs.sh	2012-12-17 20:43:22 UTC (rev 6105)
@@ -2,7 +2,8 @@
 
 mkdir -p graph
 
-for s in $(seq 1000 1000 10000); do
+# for s in $(seq 1000 1000 10000); do
+for s in 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000; do
   ./trimgraph.sh $s 1.0 > graph/$s.100
   ./trimgraph.sh $s 0.1 > graph/$s.10
   ./trimgraph.sh  $s 0.5 > graph/$s.50

Modified: SwiftApps/SciColSim/graphsim.cpp
===================================================================
--- SwiftApps/SciColSim/graphsim.cpp	2012-12-13 23:38:53 UTC (rev 6104)
+++ SwiftApps/SciColSim/graphsim.cpp	2012-12-17 20:43:22 UTC (rev 6105)
@@ -800,56 +800,65 @@
 
 
     //=============================================================
-    void update_probabilities(void){
+  void update_probabilities(void){
 
 
-        //=========================
-		// Compute sampling probabilities
-		// first pass: \xi_i,j
-		for(int i=0; i<N_nodes-1; i++){
-			for( int j=i+1; j<N_nodes; j++){
+    //=========================
+    // Compute sampling probabilities
+    // first pass: \xi_i,j
+    int i, j;
+    //#pragma omp parallel for private (j)
+    //#pragma omp parallel for 
 
-				double bg = 0.;
+    //    #pragma omp parallel for default(none) shared( Prob, alpha_i, alpha_m, beta, k_max, gamma, delta, Rank, Dist) private(i,j)
+    #pragma omp parallel for private(i,j)
 
-				Prob[i][j] = alpha_i*log(min(Rank[i]+1.,Rank[j]+1.)) +
-                alpha_m*log(max(Rank[i]+1.,Rank[j]+1.));
+    for( i=0; i<N_nodes-1; i++){
+      for(  j=i+1; j<N_nodes; j++){
 
-                if (Dist[i][j] > 0.){
+	double bg = 0.;
 
-                    double k = Dist[i][j];
-                    if (k >= k_max){
-                        k = k_max-1;
-                    }
+	Prob[i][j] = alpha_i*log(min(Rank[i]+1.,Rank[j]+1.)) +
+	  alpha_m*log(max(Rank[i]+1.,Rank[j]+1.));
 
-                    bg = beta * log(k/k_max) + gamma * log(1. - k/k_max);
+	if (Dist[i][j] > 0.){
 
-                } else {
-                    bg = delta;
-                }
+	  double k = Dist[i][j];
+	  if (k >= k_max){
+	    k = k_max-1;
+	  }
 
-				Prob[i][j] = exp(Prob[i][j] + bg);
-			}
-		}
+	  bg = beta * log(k/k_max) + gamma * log(1. - k/k_max);
 
+	} else {
+	  bg = delta;
+	}
 
-		// second pass: sum
-		double Summa = 0.;
+	Prob[i][j] = exp(Prob[i][j] + bg);
+      }
+    }
 
-		for(int i=0; i<N_nodes-1; i++){
-			for( int j=i+1; j<N_nodes; j++){
-				Summa += Prob[i][j];
-			}
-		}
 
-		// third pass: normalize
-		for(int i=0; i<N_nodes-1; i++){
-			for( int j=i+1; j<N_nodes; j++){
-				Prob[i][j] /= Summa;
-			}
-		}
+    // second pass: sum
+    double Summa = 0.;
 
+    #pragma omp parallel
+    for(i=0; i<N_nodes-1; i++){
+      for(j=i+1; j<N_nodes; j++){
+	Summa += Prob[i][j];
+      }
     }
 
+    // third pass: normalize
+    #pragma omp parallel 
+    for( i=0; i<N_nodes-1; i++){
+      for(  j=i+1; j<N_nodes; j++){
+	Prob[i][j] /= Summa;
+      }
+    }
+
+  }
+
 	// Now we are ready for simulations
 	//==============================================
 	void update_world(){
@@ -859,10 +868,15 @@
 		// Given current universe compute shortest paths
 		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+std::cout << "Before updates" << std::endl;
 		update_current_graph();
+std::cout << "after current" << std::endl;
 		update_ranks();
+std::cout << "after ranks" << std::endl;
 		update_distances();
+std::cout << "after distances" << std::endl;
 		update_probabilities();
+std::cout << "after probs" << std::endl;
 
 		//===============================
 		// sampling
@@ -876,12 +890,15 @@
 
 			while(publishable < N_steps){
 
+std::cout << "failed:1 before sample\n";
 		    	result = sample();
+std::cout << "failed:1 after sample\n";
 			    publishable += result;
 			    failed += (1-result);
 
 			}
 
+std::cout << "failed:1 before for\n";
 			for(int i=0; i<N_nodes-1; i++){
 				for( int j=i+1; j<N_nodes; j++){
 
@@ -889,9 +906,11 @@
 
 					if (Tried[i][j]>0. && Final[i][j]>0.){
 						novel+=1.;
+std::cout << "failed:1 novel: " << novel << std::endl;
 					}
 				}
 			}
+std::cout << "failed:1 after for\n";
 
 		}
 		//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -901,6 +920,7 @@
 			int n_failed;
 			//, n_check = 0;
 
+std::cout << "failed:0 before for\n";
 			for(int i=0; i<N_nodes-1; i++){
 				for( int j=i+1; j<N_nodes; j++){
 					if (Final[i][j] == 0.){
@@ -918,12 +938,17 @@
 				//std::cout << std::endl;
 			}
 
+std::cout << "failed:0 after for\n";
 			n_failed = sample_failed_number(pfail);
+
+
+std::cout << "failed:0 before while\n";
 			while(publishable < N_steps){
 
 		    	result = sample();
 			    publishable += result;
 			}
+std::cout << "failed:0 after while\n";
 
 
 			current_loss += (n_failed + N_steps);
@@ -934,6 +959,8 @@
 
 					if (Tried[i][j]>0. && Final[i][j]>0.){
 						novel+=1.;
+std::cout << "failed:0 novel: " << novel << std::endl;
+
 					}
 				}
 			}
@@ -943,6 +970,7 @@
 
 
 		//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+verbose_level = 2;
 		if (verbose_level == 2){
             std::cout << (current_repeat+1) << "  epoch=" << (current_epoch+1)
 
@@ -1887,7 +1915,7 @@
     double T_start=params2[0], T_end=params2[1], Target_rejection=params2[3], starting_jump=params2[4];
     int Annealing_repeats = (int) params2[2];
 
-    print_memory_status();
+    // print_memory_status();
 
 #ifdef P_DISPATCH
     dispatch_group_t group = dispatch_group_create();

Modified: SwiftApps/SciColSim/testgraph.py
===================================================================
--- SwiftApps/SciColSim/testgraph.py	2012-12-13 23:38:53 UTC (rev 6104)
+++ SwiftApps/SciColSim/testgraph.py	2012-12-17 20:43:22 UTC (rev 6105)
@@ -140,7 +140,7 @@
   optimizerRepeats = 1
   evolveReruns     = 1
   annealingSteps   = 1
-  NWorkers         = "1"
+  NWorkers         = "2"
   openmp           = "OMP_NUM_THREADS=" + NWorkers
   operation        = "m"  # n=normal, m=manual (runs 1 multi_loss call)
   seed             = "" # "123456"
@@ -159,8 +159,9 @@
 for target in range(startTarget,endTarget,incrTarget):
   for i in range(optimizerRepeats):
     args = "rm -f bestdb.txt; " + \
-           openmp + " " + app + " 0 0 0 0 0 " + str(target) + " 40000 20 " + str(evolveReruns) + \
-           " 2 1 2. 0.01 " + str(annealingSteps) + " 0.3 2.3 0 0 0 0 0 " + operation + " " + NWorkers + " " + seed + \
+           openmp + " " + "/usr/bin/time -l " + \
+                          app + " 0 0 0 0 0 " + str(target) + " 40000 20 " + str(evolveReruns) + \
+           " 2 2 2. 0.01 " + str(annealingSteps) + " 0.3 2.3 0 0 0 0 0 " + operation + " " + NWorkers + " " + seed + \
            " # >& out.T"+str(target)+".i"+str(i) + "; #mv bestdb.txt best.T" + str(target) + ".i" + str(i) 
     print("\n**** Calling optimizer: "+args+"\n")
     os.system(args);

Modified: SwiftApps/SciColSim/trimgraph.sh
===================================================================
--- SwiftApps/SciColSim/trimgraph.sh	2012-12-13 23:38:53 UTC (rev 6104)
+++ SwiftApps/SciColSim/trimgraph.sh	2012-12-17 20:43:22 UTC (rev 6105)
@@ -3,7 +3,7 @@
 vertices=${1:-100}
 fraction=${2:-1.0}
 
-tmp=$(mktemp)
+tmp=$(mktemp -t trimgraph)
 
 awk '
 NR == 1 { }




More information about the Swift-commit mailing list