Skip to content

Commit

Permalink
Workaround for cs2 failing with sparse node IDs in flow network.
Browse files Browse the repository at this point in the history
This commit brings in a somewhat hacky workaround for the problem
described in #25: when using the cs2 solver, the maximum node ID in the
output can be no greater than the number of nodes in the flow graph. The
workaround fix is to return the maximum ID in use instead of the true
number of nodes, which leads to cs2 implicitly assuming disconnected
nodes for the unused IDs.

This commit does not currently affect correctness of any code, but care
is required, since FlowGraph::NumNodes() does not necessarily return the
true number of nodes any more.

Affected modules: scheduling/flow
Bug: #26

Change-Id: I5de0b35cc84f1d4e53e050ac96e25924d031c7ae
  • Loading branch information
ms705 committed Jun 26, 2015
1 parent cfdc28b commit 28bb418
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/scheduling/flow/flow_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "scheduling/flow/flow_graph_node.h"

DECLARE_bool(preemption);
DECLARE_string(flow_scheduling_solver);

namespace firmament {

Expand Down Expand Up @@ -75,7 +76,15 @@ class FlowGraph {
return unsched_agg_nodes_;
}
inline uint64_t NumArcs() const { return arc_set_.size(); }
inline uint64_t NumNodes() const { return node_map_.size(); }
inline uint64_t NumNodes() const {
if (FLAGS_flow_scheduling_solver != "cs2") {
return node_map_.size();
} else {
// TODO(malte): This is a work-around as cs2 does not allow sparse node
// IDs, and will get tripped up if current_id > graph.NumNodes().
return current_id_;
}
}
inline FlowGraphNode* Node(uint64_t id) {
FlowGraphNode* const* npp = FindOrNull(node_map_, id);
return (npp ? *npp : NULL);
Expand Down

0 comments on commit 28bb418

Please sign in to comment.