[Lemon-commits] [lemon_svn] alpar: r970 - hugo/trunk/src/benchmark

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:42:29 CET 2006


Author: alpar
Date: Wed Jul 21 09:03:20 2004
New Revision: 970

Added:
   hugo/trunk/src/benchmark/benchmark   (contents, props changed)
Modified:
   hugo/trunk/src/benchmark/bench_tools.h
   hugo/trunk/src/benchmark/graph-bench.cc
   hugo/trunk/src/benchmark/hcube.cc

Log:
Ready to run the first test series.


Modified: hugo/trunk/src/benchmark/bench_tools.h
==============================================================================
--- hugo/trunk/src/benchmark/bench_tools.h	(original)
+++ hugo/trunk/src/benchmark/bench_tools.h	Wed Jul 21 09:03:20 2004
@@ -3,6 +3,9 @@
 #define HUGO_BENCH_TEST_H
 
 #include<vector>
+#include<iostream>
+
+#include<hugo/time_measure.h>
 
 ///An experimental typedef factory
 #define GRAPH_TYPEDEF_FACTORY(Graph) \
@@ -23,6 +26,8 @@
  
 
 ///A primitive primtest
+
+///\bug 2 is not a prime according to this function!
 bool isPrim(int n)
 {
   if(n%2) {
@@ -69,5 +74,13 @@
     }
 };
 
+inline void PrintTime(char *ID,hugo::Timer &T) 
+{
+  hugo::TimeStamp S(T);
+  std::cout << ID << ' ' << S.getUserTime() << ' '
+	    << S.getSystemTime() << ' ' << S.getRealTime() << std::endl;
+}
+
+  
 
 #endif

Added: hugo/trunk/src/benchmark/benchmark
==============================================================================
--- (empty file)
+++ hugo/trunk/src/benchmark/benchmark	Wed Jul 21 09:03:20 2004
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+function runtest () # prefix, prog, args
+{
+    echo $1 1>&2
+    $2 $3 $4 $5 $6 $7 $8 $9|awk '{print "'$1'",$0}'
+}
+
+function runalltest() #postfix, CXX, CXXFLAGS
+{
+    echo $1 1>&2
+    make clean >/dev/null
+    make CXX="$2" CXXFLAGS="$3"  >/dev/null
+    {
+	runtest HCUBE19 hcube 19
+	runtest GRBENCH graph-bench
+    } | awk "{print \$0, \"$1\"}"
+}
+
+runalltest "gcc-3.3 -O2"                 g++ "-O2"
+runalltest "gcc-3.3 -O2-march=pentium-m" g++ "-O2 -march=pentium-m"
+runalltest "gcc-3.3 -O3"                 g++ "-O3"
+runalltest "gcc-3.3 -O3-march=pentium-m" g++ "-O3 -march=pentium-m"
+
+runalltest "gcc-3.4 -O2"                 g++-3.4 "-O2"
+runalltest "gcc-3.4 -O2-march=pentium-m" g++-3.4 "-O2 -march=pentium-m"
+runalltest "gcc-3.4 -O3"                 g++-3.4 "-O3"
+runalltest "gcc-3.4 -O3-march=pentium-m" g++-3.4 "-O3 -march=pentium-m"
+

Modified: hugo/trunk/src/benchmark/graph-bench.cc
==============================================================================
--- hugo/trunk/src/benchmark/graph-bench.cc	(original)
+++ hugo/trunk/src/benchmark/graph-bench.cc	Wed Jul 21 09:03:20 2004
@@ -1,7 +1,5 @@
 #include<math.h>
 #include<hugo/list_graph.h>
-#include<hugo/time_measure.h>
-#include<iostream>
 
 #include"bench_tools.h"
 
@@ -28,7 +26,7 @@
   //Edge equ[rat];
   std::vector<Edge> equ(rat);
   
-  unsigned long long int count;
+  long long int count;
   
   for(count=0;count<rat;count++) {
     equ[count%rat]=G.addEdge(nodes[(count*p)%n],nodes[(count*p/n)%n]);
@@ -38,21 +36,21 @@
     if(count%rat) G.erase(equ[count%rat]);
     equ[count%rat]=G.addEdge(nodes[(count*p)%n],nodes[(count*p/n)%n]);
   }
-  std::cout << "Added " << count
-	    << " ( " << n << "^2 * " << rat << " ) edges\n";
+//   std::cout << "Added " << count
+// 	    << " ( " << n << "^2 * " << rat << " ) edges\n";
+
+
   //  for(int i=0;1;i++) ;
 }
 
 int main()
 {
-  std::cout << "START: n="  << nextPrim(1000) << " rat="
-	    << nextPrim(300) << " p=" << nextPrim(100) << '\n';
   hugo::Timer T;
   makeFullGraph<ListGraph>(nextPrim(1000),nextPrim(300),nextPrim(100));
-  std::cout << T  << '\n';
-  std::cout << "START: n="  << nextPrim(1000) << " rat="
-	    << nextPrim(300) << " p=" << nextPrim(100) << '\n';
+  
+  PrintTime("BIG",T);
   T.reset();
   makeFullGraph<ListGraph>(nextPrim(100),nextPrim(30000),nextPrim(150));
-  std::cout << T  << '\n';
+
+  PrintTime("SMALL",T);
 }

Modified: hugo/trunk/src/benchmark/hcube.cc
==============================================================================
--- hugo/trunk/src/benchmark/hcube.cc	(original)
+++ hugo/trunk/src/benchmark/hcube.cc	Wed Jul 21 09:03:20 2004
@@ -4,9 +4,7 @@
 #include<hugo/list_graph.h>
 #include<hugo/smart_graph.h>
 #include<hugo/dijkstra.h>
-#include<hugo/time_measure.h>
-#include<iostream>
-//#include<../work/jacint/max_flow.h>
+#include<../work/jacint/max_flow_no_stack.h>
 #include"bench_tools.h"
 
 using namespace std;
@@ -23,7 +21,7 @@
   
   for(int i=0;i<bits[dim];i++) {
     nodes.push_back(G.addNode());
-    for(j=0;j<dim;j++) if(i&bits[j]) G.addEdge(nodes[i-bits[j]],nodes[i]);
+    for(int j=0;j<dim;j++) if(i&bits[j]) G.addEdge(nodes[i-bits[j]],nodes[i]);
   }
 }
 
@@ -46,6 +44,26 @@
   }
 }
 
+inline int numOfOnes(int n,int dim)
+{
+  int s=0;
+  for(int i=0;i<dim;i++) {
+    s+=n%2;
+    n>>=1;
+  }
+  return s;
+}
+
+inline int numOfZeros(int n,int dim)
+{
+  int s=dim;
+  for(int i=0;i<dim;i++) {
+    s-=n&1;
+    n>>=1;
+  }
+  return s;
+}
+
 int main(int argc, char *argv[])
 {
   //  typedef ListGraph Graph;
@@ -65,13 +83,15 @@
   
   int dim=atoi(argv[1]);
   
-  cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
-       << dim*(1<<dim) << " edges):";
+//   cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
+//        << dim*(1<<dim) << " edges):";
 
+  T.reset();
   vector<Node> nodes;
   addBiDirHiperCube(G,dim,nodes);
-  cout << T;
-  cout << "\nGenerating the lengths: ";
+
+  PrintTime("GENGRAPH",T);
+
   T.reset();
   Graph::EdgeMap<int> map(G);
   {
@@ -82,24 +102,30 @@
     for(int i=0;i<dim*(1<<dim);i++)
       //    map[Edge(((long long int)(i)*2987)%(dim*(1<<dim)))]=P();
       map[Edge(((long long int)(i)*93505)%(dim*(1<<dim)))]=P();
+  
+//     for(int i=0;i<(1<<dim);i++) {
+//       int mul= (1<<(numOfZeros(i,dim)/4));
+//       for(OutEdgeIt e(G,nodes[i]);G.valid(e);G.next(e))
+// 	map[e]*=mul;
+//     }
   }
   
-  cout << T;
-  cout << "\nRunning Dijkstra: ";
+  PrintTime("GENLENGTHS",T);
+
   T.reset();
   {
     Dijkstra<Graph> Dij(G,map);
     Dij.run(nodes[0]);
   }
-  cout << T;
-//   cout << "\nRunning MaxFlow: ";
-//   T.reset();
-//   {
-//    Graph::EdgeMap<int> flow(G);
+  PrintTime("DIJKSTRA",T);
+
+  T.reset();
+  {
+   Graph::EdgeMap<int> flow(G);
    
-//     MaxFlow<Graph,int> MF(G,nodes[0],nodes[1<<dim-1],map,flow);
-//     MF.run(MF.NO_FLOW);
-//   }
-//   cout << T;
-  cout << "\n";
+    MaxFlowNoStack<Graph,int> MF(G,nodes[0],nodes[1<<dim-1],map,flow);
+    MF.run(MF.NO_FLOW);
+  }
+  PrintTime("PREFLOW",T);
+
 }



More information about the Lemon-commits mailing list