From a61882d72205081a73297467ef005ee84e49166d Mon Sep 17 00:00:00 2001 From: Davi de Castro Reis Date: Sun, 15 May 2011 22:02:34 -0300 Subject: [PATCH] Enabled debug. --- cxxmph/mph_table.cc | 34 +++++++++++++++------------------- cxxmph/mph_table.h | 10 +++++----- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/cxxmph/mph_table.cc b/cxxmph/mph_table.cc index 03dcfa3..2f92498 100644 --- a/cxxmph/mph_table.cc +++ b/cxxmph/mph_table.cc @@ -61,14 +61,12 @@ bool MPHTable::GenerateQueue( } } } - /* for (unsigned int i = 0; i < marked_edge.size(); ++i) { cerr << "vertex with degree " << static_cast(graph->vertex_degree()[i]) << " marked " << marked_edge[i] << endl; } for (unsigned int i = 0; i < queue.size(); ++i) { cerr << "vertex " << i << " queued at " << queue[i] << endl; } - */ // At this point queue head is the number of edges touching at least one // vertex of degree 1. // cerr << "Queue head " << queue_head << " Queue tail " << queue_tail << endl; @@ -88,11 +86,9 @@ bool MPHTable::GenerateQueue( } } } - /* for (unsigned int i = 0; i < queue.size(); ++i) { cerr << "vertex " << i << " queued at " << queue[i] << endl; } - */ int cycles = queue_head - nedges; if (cycles == 0) queue.swap(*queue_output); return cycles == 0; @@ -110,10 +106,10 @@ void MPHTable::Assigning( for (int i = nedges - 1; i + 1 >= 1; --i) { current_edge = queue[i]; const TriGraph::Edge& e = edges[current_edge]; - // cerr << "B: " << e[0] << " " << e[1] << " " << e[2] << " -> " - // << get_2bit_value(g_, e[0]) << " " - // << get_2bit_value(g_, e[1]) << " " - // << get_2bit_value(g_, e[2]) << " edge " << current_edge << endl; + cerr << "B: " << e[0] << " " << e[1] << " " << e[2] << " -> " + << get_2bit_value(g_, e[0]) << " " + << get_2bit_value(g_, e[1]) << " " + << get_2bit_value(g_, e[2]) << " edge " << current_edge << endl; if (!marked_vertices[e[0]]) { if (!marked_vertices[e[1]]) { set_2bit_value(&g_, e[1], kUnassigned); @@ -137,10 +133,10 @@ void MPHTable::Assigning( set_2bit_value(&g_, e[2], (8 - (get_2bit_value(g_, e[0]) + get_2bit_value(g_, e[1]))) % 3); marked_vertices[e[2]] = true; } - // cerr << "A: " << e[0] << " " << e[1] << " " << e[2] << " -> " - // << get_2bit_value(g_, e[0]) << " " - // << get_2bit_value(g_, e[1]) << " " - // << get_2bit_value(g_, e[2]) << " " << endl; + cerr << "A: " << e[0] << " " << e[1] << " " << e[2] << " -> " + << get_2bit_value(g_, e[0]) << " " + << get_2bit_value(g_, e[1]) << " " + << get_2bit_value(g_, e[2]) << " " << endl; } } @@ -174,14 +170,14 @@ uint32_t MPHTable::Rank(uint32_t vertex) const { uint32_t end_idx_b = vertex >> 2; while (beg_idx_b < end_idx_b) base_rank += kBdzLookupTable[g_[beg_idx_b++]]; beg_idx_v = beg_idx_b << 2; - // cerr << "beg_idx_v: " << beg_idx_v << endl; - // cerr << "base rank: " << base_rank << endl; + cerr << "beg_idx_v: " << beg_idx_v << endl; + cerr << "base rank: " << base_rank << endl; - //cerr << "G: "; - // for (unsigned int i = 0; i < n_; ++i) { - // cerr << get_2bit_value(g_, i) << " "; - //} - // cerr << endl; + cerr << "G: "; + for (unsigned int i = 0; i < n_; ++i) { + cerr << get_2bit_value(g_, i) << " "; + } + cerr << endl; while (beg_idx_v < vertex) { if (get_2bit_value(g_, beg_idx_v) != kUnassigned) ++base_rank; ++beg_idx_v; diff --git a/cxxmph/mph_table.h b/cxxmph/mph_table.h index a2fa236..99baaa3 100644 --- a/cxxmph/mph_table.h +++ b/cxxmph/mph_table.h @@ -85,13 +85,13 @@ bool MPHTable::Reset(ForwardIterator begin, ForwardIterator end) { n_ = 3*r_; k_ = 1U << b_; - // cerr << "m " << m_ << " n " << n_ << " r " << r_ << endl; + cerr << "m " << m_ << " n " << n_ << " r " << r_ << endl; int iterations = 10; std::vector edges; std::vector queue; while (1) { - // cerr << "Iterations missing: " << iterations << endl; + cerr << "Iterations missing: " << iterations << endl; for (int i = 0; i < 3; ++i) hash_seed_[i] = random() % m_; // for (int i = 0; i < 3; ++i) hash_seed_[i] = random() + i; if (Mapping(begin, end, &edges, &queue)) break; @@ -116,7 +116,7 @@ bool MPHTable::Mapping( uint32_t v0 = h[0] % r_; uint32_t v1 = h[1] % r_ + r_; uint32_t v2 = h[2] % r_ + (r_ << 1); - // cerr << "Key: " << *it << " edge " << it - begin << " (" << v0 << "," << v1 << "," << v2 << ")" << endl; + cerr << "Key: " << *it << " edge " << it - begin << " (" << v0 << "," << v1 << "," << v2 << ")" << endl; graph.AddEdge(TriGraph::Edge(v0, v1, v2)); } if (GenerateQueue(&graph, queue)) { @@ -134,12 +134,12 @@ uint32_t MPHTable::index(const Key& key) const { h[1] = h[1] % r_ + r_; h[2] = h[2] % r_ + (r_ << 1); assert(g_.size()); - //cerr << "g_.size() " << g_.size() << " h0 >> 2 " << (h[0] >> 2) << endl; + cerr << "g_.size() " << g_.size() << " h0 >> 2 " << (h[0] >> 2) << endl; assert((h[0] >> 2) > 2) > 2)