Skip to content

Commit

Permalink
[bfs] also use selective logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sbeamer committed Sep 29, 2023
1 parent 1642dcf commit 403fc77
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/bfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,16 @@ pvector<NodeID> InitParent(const Graph &g) {
return parent;
}

pvector<NodeID> DOBFS(const Graph &g, NodeID source, int alpha = 15,
int beta = 18) {
PrintStep("Source", static_cast<int64_t>(source));
pvector<NodeID> DOBFS(const Graph &g, NodeID source, bool logging_enabled = false,
int alpha = 15, int beta = 18) {
if (logging_enabled)
PrintStep("Source", static_cast<int64_t>(source));
Timer t;
t.Start();
pvector<NodeID> parent = InitParent(g);
t.Stop();
PrintStep("i", t.Seconds());
if (logging_enabled)
PrintStep("i", t.Seconds());
parent[source] = source;
SlidingQueue<NodeID> queue(g.num_nodes());
queue.push_back(source);
Expand All @@ -141,7 +143,8 @@ pvector<NodeID> DOBFS(const Graph &g, NodeID source, int alpha = 15,
if (scout_count > edges_to_check / alpha) {
int64_t awake_count, old_awake_count;
TIME_OP(t, QueueToBitmap(queue, front));
PrintStep("e", t.Seconds());
if (logging_enabled)
PrintStep("e", t.Seconds());
awake_count = queue.size();
queue.slide_window();
do {
Expand All @@ -150,19 +153,22 @@ pvector<NodeID> DOBFS(const Graph &g, NodeID source, int alpha = 15,
awake_count = BUStep(g, parent, front, curr);
front.swap(curr);
t.Stop();
PrintStep("bu", t.Seconds(), awake_count);
if (logging_enabled)
PrintStep("bu", t.Seconds(), awake_count);
} while ((awake_count >= old_awake_count) ||
(awake_count > g.num_nodes() / beta));
TIME_OP(t, BitmapToQueue(g, front, queue));
PrintStep("c", t.Seconds());
if (logging_enabled)
PrintStep("c", t.Seconds());
scout_count = 1;
} else {
t.Start();
edges_to_check -= scout_count;
scout_count = TDStep(g, parent, queue);
queue.slide_window();
t.Stop();
PrintStep("td", t.Seconds(), queue.size());
if (logging_enabled)
PrintStep("td", t.Seconds(), queue.size());
}
}
#pragma omp parallel for
Expand Down Expand Up @@ -248,7 +254,9 @@ int main(int argc, char* argv[]) {
Builder b(cli);
Graph g = b.MakeGraph();
SourcePicker<Graph> sp(g, cli.start_vertex());
auto BFSBound = [&sp] (const Graph &g) { return DOBFS(g, sp.PickNext()); };
auto BFSBound = [&sp,&cli] (const Graph &g) {
return DOBFS(g, sp.PickNext(), cli.logging_en());
};
SourcePicker<Graph> vsp(g, cli.start_vertex());
auto VerifierBound = [&vsp] (const Graph &g, const pvector<NodeID> &parent) {
return BFSVerifier(g, vsp.PickNext(), parent);
Expand Down

0 comments on commit 403fc77

Please sign in to comment.