Ready to run the first test series.
1.1 --- a/src/benchmark/bench_tools.h Wed Jul 21 07:01:14 2004 +0000
1.2 +++ b/src/benchmark/bench_tools.h Wed Jul 21 07:03:20 2004 +0000
1.3 @@ -3,6 +3,9 @@
1.4 #define HUGO_BENCH_TEST_H
1.5
1.6 #include<vector>
1.7 +#include<iostream>
1.8 +
1.9 +#include<hugo/time_measure.h>
1.10
1.11 ///An experimental typedef factory
1.12 #define GRAPH_TYPEDEF_FACTORY(Graph) \
1.13 @@ -23,6 +26,8 @@
1.14
1.15
1.16 ///A primitive primtest
1.17 +
1.18 +///\bug 2 is not a prime according to this function!
1.19 bool isPrim(int n)
1.20 {
1.21 if(n%2) {
1.22 @@ -69,5 +74,13 @@
1.23 }
1.24 };
1.25
1.26 +inline void PrintTime(char *ID,hugo::Timer &T)
1.27 +{
1.28 + hugo::TimeStamp S(T);
1.29 + std::cout << ID << ' ' << S.getUserTime() << ' '
1.30 + << S.getSystemTime() << ' ' << S.getRealTime() << std::endl;
1.31 +}
1.32 +
1.33 +
1.34
1.35 #endif
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/benchmark/benchmark Wed Jul 21 07:03:20 2004 +0000
2.3 @@ -0,0 +1,29 @@
2.4 +#!/bin/bash
2.5 +
2.6 +function runtest () # prefix, prog, args
2.7 +{
2.8 + echo $1 1>&2
2.9 + $2 $3 $4 $5 $6 $7 $8 $9|awk '{print "'$1'",$0}'
2.10 +}
2.11 +
2.12 +function runalltest() #postfix, CXX, CXXFLAGS
2.13 +{
2.14 + echo $1 1>&2
2.15 + make clean >/dev/null
2.16 + make CXX="$2" CXXFLAGS="$3" >/dev/null
2.17 + {
2.18 + runtest HCUBE19 hcube 19
2.19 + runtest GRBENCH graph-bench
2.20 + } | awk "{print \$0, \"$1\"}"
2.21 +}
2.22 +
2.23 +runalltest "gcc-3.3 -O2" g++ "-O2"
2.24 +runalltest "gcc-3.3 -O2-march=pentium-m" g++ "-O2 -march=pentium-m"
2.25 +runalltest "gcc-3.3 -O3" g++ "-O3"
2.26 +runalltest "gcc-3.3 -O3-march=pentium-m" g++ "-O3 -march=pentium-m"
2.27 +
2.28 +runalltest "gcc-3.4 -O2" g++-3.4 "-O2"
2.29 +runalltest "gcc-3.4 -O2-march=pentium-m" g++-3.4 "-O2 -march=pentium-m"
2.30 +runalltest "gcc-3.4 -O3" g++-3.4 "-O3"
2.31 +runalltest "gcc-3.4 -O3-march=pentium-m" g++-3.4 "-O3 -march=pentium-m"
2.32 +
3.1 --- a/src/benchmark/graph-bench.cc Wed Jul 21 07:01:14 2004 +0000
3.2 +++ b/src/benchmark/graph-bench.cc Wed Jul 21 07:03:20 2004 +0000
3.3 @@ -1,7 +1,5 @@
3.4 #include<math.h>
3.5 #include<hugo/list_graph.h>
3.6 -#include<hugo/time_measure.h>
3.7 -#include<iostream>
3.8
3.9 #include"bench_tools.h"
3.10
3.11 @@ -28,7 +26,7 @@
3.12 //Edge equ[rat];
3.13 std::vector<Edge> equ(rat);
3.14
3.15 - unsigned long long int count;
3.16 + long long int count;
3.17
3.18 for(count=0;count<rat;count++) {
3.19 equ[count%rat]=G.addEdge(nodes[(count*p)%n],nodes[(count*p/n)%n]);
3.20 @@ -38,21 +36,21 @@
3.21 if(count%rat) G.erase(equ[count%rat]);
3.22 equ[count%rat]=G.addEdge(nodes[(count*p)%n],nodes[(count*p/n)%n]);
3.23 }
3.24 - std::cout << "Added " << count
3.25 - << " ( " << n << "^2 * " << rat << " ) edges\n";
3.26 +// std::cout << "Added " << count
3.27 +// << " ( " << n << "^2 * " << rat << " ) edges\n";
3.28 +
3.29 +
3.30 // for(int i=0;1;i++) ;
3.31 }
3.32
3.33 int main()
3.34 {
3.35 - std::cout << "START: n=" << nextPrim(1000) << " rat="
3.36 - << nextPrim(300) << " p=" << nextPrim(100) << '\n';
3.37 hugo::Timer T;
3.38 makeFullGraph<ListGraph>(nextPrim(1000),nextPrim(300),nextPrim(100));
3.39 - std::cout << T << '\n';
3.40 - std::cout << "START: n=" << nextPrim(1000) << " rat="
3.41 - << nextPrim(300) << " p=" << nextPrim(100) << '\n';
3.42 +
3.43 + PrintTime("BIG",T);
3.44 T.reset();
3.45 makeFullGraph<ListGraph>(nextPrim(100),nextPrim(30000),nextPrim(150));
3.46 - std::cout << T << '\n';
3.47 +
3.48 + PrintTime("SMALL",T);
3.49 }
4.1 --- a/src/benchmark/hcube.cc Wed Jul 21 07:01:14 2004 +0000
4.2 +++ b/src/benchmark/hcube.cc Wed Jul 21 07:03:20 2004 +0000
4.3 @@ -4,9 +4,7 @@
4.4 #include<hugo/list_graph.h>
4.5 #include<hugo/smart_graph.h>
4.6 #include<hugo/dijkstra.h>
4.7 -#include<hugo/time_measure.h>
4.8 -#include<iostream>
4.9 -//#include<../work/jacint/max_flow.h>
4.10 +#include<../work/jacint/max_flow_no_stack.h>
4.11 #include"bench_tools.h"
4.12
4.13 using namespace std;
4.14 @@ -23,7 +21,7 @@
4.15
4.16 for(int i=0;i<bits[dim];i++) {
4.17 nodes.push_back(G.addNode());
4.18 - for(j=0;j<dim;j++) if(i&bits[j]) G.addEdge(nodes[i-bits[j]],nodes[i]);
4.19 + for(int j=0;j<dim;j++) if(i&bits[j]) G.addEdge(nodes[i-bits[j]],nodes[i]);
4.20 }
4.21 }
4.22
4.23 @@ -46,6 +44,26 @@
4.24 }
4.25 }
4.26
4.27 +inline int numOfOnes(int n,int dim)
4.28 +{
4.29 + int s=0;
4.30 + for(int i=0;i<dim;i++) {
4.31 + s+=n%2;
4.32 + n>>=1;
4.33 + }
4.34 + return s;
4.35 +}
4.36 +
4.37 +inline int numOfZeros(int n,int dim)
4.38 +{
4.39 + int s=dim;
4.40 + for(int i=0;i<dim;i++) {
4.41 + s-=n&1;
4.42 + n>>=1;
4.43 + }
4.44 + return s;
4.45 +}
4.46 +
4.47 int main(int argc, char *argv[])
4.48 {
4.49 // typedef ListGraph Graph;
4.50 @@ -65,13 +83,15 @@
4.51
4.52 int dim=atoi(argv[1]);
4.53
4.54 - cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
4.55 - << dim*(1<<dim) << " edges):";
4.56 +// cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
4.57 +// << dim*(1<<dim) << " edges):";
4.58
4.59 + T.reset();
4.60 vector<Node> nodes;
4.61 addBiDirHiperCube(G,dim,nodes);
4.62 - cout << T;
4.63 - cout << "\nGenerating the lengths: ";
4.64 +
4.65 + PrintTime("GENGRAPH",T);
4.66 +
4.67 T.reset();
4.68 Graph::EdgeMap<int> map(G);
4.69 {
4.70 @@ -82,24 +102,30 @@
4.71 for(int i=0;i<dim*(1<<dim);i++)
4.72 // map[Edge(((long long int)(i)*2987)%(dim*(1<<dim)))]=P();
4.73 map[Edge(((long long int)(i)*93505)%(dim*(1<<dim)))]=P();
4.74 +
4.75 +// for(int i=0;i<(1<<dim);i++) {
4.76 +// int mul= (1<<(numOfZeros(i,dim)/4));
4.77 +// for(OutEdgeIt e(G,nodes[i]);G.valid(e);G.next(e))
4.78 +// map[e]*=mul;
4.79 +// }
4.80 }
4.81
4.82 - cout << T;
4.83 - cout << "\nRunning Dijkstra: ";
4.84 + PrintTime("GENLENGTHS",T);
4.85 +
4.86 T.reset();
4.87 {
4.88 Dijkstra<Graph> Dij(G,map);
4.89 Dij.run(nodes[0]);
4.90 }
4.91 - cout << T;
4.92 -// cout << "\nRunning MaxFlow: ";
4.93 -// T.reset();
4.94 -// {
4.95 -// Graph::EdgeMap<int> flow(G);
4.96 + PrintTime("DIJKSTRA",T);
4.97 +
4.98 + T.reset();
4.99 + {
4.100 + Graph::EdgeMap<int> flow(G);
4.101
4.102 -// MaxFlow<Graph,int> MF(G,nodes[0],nodes[1<<dim-1],map,flow);
4.103 -// MF.run(MF.NO_FLOW);
4.104 -// }
4.105 -// cout << T;
4.106 - cout << "\n";
4.107 + MaxFlowNoStack<Graph,int> MF(G,nodes[0],nodes[1<<dim-1],map,flow);
4.108 + MF.run(MF.NO_FLOW);
4.109 + }
4.110 + PrintTime("PREFLOW",T);
4.111 +
4.112 }