Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/osp/auxiliary/io/DotFileWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class DotFileWriter {

void operator()(std::ostream &out, const vertex_idx_t<Graph_t> &i) const {

if (i >= colors.size()) {
if (i >= static_cast<vertex_idx_t<Graph_t>>(colors.size())) {
// Fallback for safety: print without color if colors vector is mismatched or palette is empty.
out << i << " [";
} else {
Expand Down
2 changes: 1 addition & 1 deletion include/osp/bsp/model/BspSchedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class BspSchedule : public IBspSchedule<Graph_t>, public IBspScheduleEval<Graph_
*/
void updateNumberOfSupersteps() {
number_of_supersteps = 0;
for (vertex_idx_t<Graph_t> i = 0; i < instance->numberOfVertices(); ++i) {
for (vertex_idx_t<Graph_t> i = 0; i < static_cast<vertex_idx_t<Graph_t>>(instance->numberOfVertices()); ++i) {
if (node_to_superstep_assignment[i] >= number_of_supersteps) {
number_of_supersteps = node_to_superstep_assignment[i] + 1;
}
Expand Down
53 changes: 24 additions & 29 deletions include/osp/bsp/model/BspScheduleCS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,24 +331,19 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
node_to_proc_been_sent[node][BspSchedule<Graph_t>::node_to_processor_assignment[node]] = true;
}

// processor, ordered list of (cost, node, to_processor)
std::vector<std::set<std::vector<vertex_idx_t<Graph_t>>, std::greater<>>> require_sending(
BspSchedule<Graph_t>::instance->numberOfProcessors());
// TODO the datastructure seems to be wrong. the vectors added to the set have elements of different types.
// it should really be std::vector<std::set<std::tuple<v_commw_t<Graph_t>, vertex_idx_t<Graph_t>,
// vertex_idx_t<Graph_t>>>> added many static_cast below as tmp fix
// The data structure stores for each processor a set of tuples representing required sends.
// Each tuple is (communication_cost, source_node, destination_processor).
std::vector<std::set<std::tuple<v_commw_t<Graph_t>, vertex_idx_t<Graph_t>, unsigned>>> require_sending(BspSchedule<Graph_t>::instance->numberOfProcessors());

for (unsigned proc = 0; proc < BspSchedule<Graph_t>::instance->numberOfProcessors(); proc++) {
for (const auto &node : step_proc_node_list[0][proc]) {

for (const auto &target : BspSchedule<Graph_t>::instance->getComputationalDag().children(node)) {
if (proc != BspSchedule<Graph_t>::assignedProcessor(target)) {
require_sending[proc].insert(
{static_cast<vertex_idx_t<Graph_t>>(
BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(node) *
BspSchedule<Graph_t>::instance->getArchitecture().sendCosts(
proc, BspSchedule<Graph_t>::node_to_processor_assignment[target])),
node, BspSchedule<Graph_t>::node_to_processor_assignment[target]});
{BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(node) * BspSchedule<Graph_t>::instance->getArchitecture().sendCosts(proc, BspSchedule<Graph_t>::node_to_processor_assignment[target]),
node,
BspSchedule<Graph_t>::node_to_processor_assignment[target]});
}
}
}
Expand All @@ -374,8 +369,8 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(source) *
BspSchedule<Graph_t>::instance->getArchitecture().sendCosts(
BspSchedule<Graph_t>::node_to_processor_assignment[source], proc);
require_sending[BspSchedule<Graph_t>::assignedProcessor(source)].erase(
{static_cast<vertex_idx_t<Graph_t>>(comm_cost), source, proc});
require_sending[BspSchedule<Graph_t>::node_to_processor_assignment[source]].erase(
{comm_cost, source, proc});
send_cost[BspSchedule<Graph_t>::node_to_processor_assignment[source]] += comm_cost;
receive_cost[proc] += comm_cost;
}
Expand All @@ -394,24 +389,25 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
// TODO: permute the order of processors
for (size_t proc = 0; proc < BspSchedule<Graph_t>::instance->numberOfProcessors(); proc++) {
if (require_sending[proc].empty() ||
static_cast<v_commw_t<Graph_t>>((*(require_sending[proc].rbegin()))[0]) + send_cost[proc] >
std::get<0>(*require_sending[proc].rbegin()) + send_cost[proc] >
max_comm_cost)
continue;
auto iter = require_sending[proc].begin();
while (iter != require_sending[proc].cend()) {
if (static_cast<v_commw_t<Graph_t>>((*iter)[0]) + send_cost[proc] > max_comm_cost ||
static_cast<v_commw_t<Graph_t>>((*iter)[0]) + receive_cost[(*iter)[2]] > max_comm_cost) {
continue; // This check is not strictly necessary with the new loop but can be a fast exit.
auto iter = require_sending[proc].rbegin();
while (iter != require_sending[proc].rend()) {
const auto& [comm_cost, node_to_send, dest_proc] = *iter;
if (comm_cost + send_cost[proc] > max_comm_cost ||
comm_cost + receive_cost[dest_proc] > max_comm_cost) {
iter++;
} else {
commSchedule.emplace(std::make_tuple((*iter)[1], proc, (*iter)[2]), step - 1);
node_to_proc_been_sent[(*iter)[1]][(*iter)[2]] = true;
send_cost[proc] += static_cast<v_commw_t<Graph_t>>((*iter)[0]);
receive_cost[(*iter)[2]] += static_cast<v_commw_t<Graph_t>>((*iter)[0]);
iter = require_sending[proc].erase(iter);
commSchedule.emplace(std::make_tuple(node_to_send, proc, dest_proc), step - 1);
node_to_proc_been_sent[node_to_send][dest_proc] = true;
send_cost[proc] += comm_cost;
receive_cost[dest_proc] += comm_cost;
iter = std::make_reverse_iterator(require_sending[proc].erase(std::next(iter).base()));
if (require_sending[proc].empty() ||
static_cast<v_commw_t<Graph_t>>((*(require_sending[proc].rbegin()))[0]) + send_cost[proc] >
std::get<0>(*require_sending[proc].rbegin()) + send_cost[proc] >
max_comm_cost)
break;
break; // Exit if no more sends can possibly fit.
}
}
}
Expand All @@ -423,10 +419,9 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
for (const auto &target : BspSchedule<Graph_t>::instance->getComputationalDag().children(node))
if (proc != BspSchedule<Graph_t>::assignedProcessor(target)) {
require_sending[proc].insert(
{static_cast<vertex_idx_t<Graph_t>>(
BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(node) *
{BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(node) *
BspSchedule<Graph_t>::instance->getArchitecture().sendCosts(
proc, BspSchedule<Graph_t>::node_to_processor_assignment[target])),
proc, BspSchedule<Graph_t>::node_to_processor_assignment[target]),
node, BspSchedule<Graph_t>::node_to_processor_assignment[target]});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class OrbitGraphProcessor {
simulate_merge(VertexType u, VertexType v, const Constr_Graph_t &current_coarse_graph) const {
std::vector<VertexType> temp_contraction_map(current_coarse_graph.num_vertices());
VertexType new_idx = 0;
for (VertexType i = 0; i < temp_contraction_map.size(); ++i) {
for (VertexType i = 0; i < static_cast<VertexType>(temp_contraction_map.size()); ++i) {
if (i != v) {
temp_contraction_map[i] = new_idx++;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ class OrbitGraphProcessor {
locked_orbits = std::move(next_locked_orbits);

std::vector<Group> next_groups(current_coarse_graph.num_vertices());
for (VertexType i = 0; i < current_groups.size(); ++i) {
for (VertexType i = 0; i < static_cast<VertexType>(current_groups.size()); ++i) {
if (i != u && i != v) {
next_groups[group_remap[i]] = std::move(current_groups[i]);
}
Expand Down
6 changes: 3 additions & 3 deletions include/osp/graph_algorithms/directed_graph_edge_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class edge_view {
const Graph_t *graph; // Pointer to the graph
vertex_idx_t<Graph_t> current_vertex; // Current source vertex
child_iterator_t current_child; // Iterator to the current target vertex in current_vertex's adjacency list
std::size_t current_edge_idx; // Global index of the current edge in the traversal order
vertex_idx_t<Graph_t> current_edge_idx; // Global index of the current edge in the traversal order

public:
directed_edge_iterator() : graph(nullptr), current_vertex(0), current_edge_idx(0) {}
Expand All @@ -69,12 +69,12 @@ class edge_view {
}
}

directed_edge_iterator(const std::size_t edge_idx, const Graph_t &graph_)
directed_edge_iterator(const vertex_idx_t<Graph_t> edge_idx, const Graph_t &graph_)
: graph(&graph_), current_vertex(0), current_edge_idx(edge_idx) {

if (current_edge_idx < graph->num_edges()) {

std::size_t tmp = 0u;
vertex_idx_t<Graph_t> tmp = 0u;

if (tmp < current_edge_idx) {

Expand Down
2 changes: 1 addition & 1 deletion include/osp/graph_algorithms/directed_graph_top_sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ std::vector<vertex_idx_t<Graph_t>> GetTopOrder(const Graph_t &graph) {
}
}

if (TopOrder.size() != graph.num_vertices())
if (static_cast<VertexType>(TopOrder.size()) != graph.num_vertices())
throw std::runtime_error("Error during topological ordering: TopOrder.size() != graph.num_vertices() [" +
std::to_string(TopOrder.size()) + " != " + std::to_string(graph.num_vertices()) +
"]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class computational_dag_vector_impl {

bool add_edge(vertex_idx source, vertex_idx target) {

if (source >= vertices_.size() || target >= vertices_.size() || source == target)
if (source >= static_cast<vertex_idx>(vertices_.size()) || target >= static_cast<vertex_idx>(vertices_.size()) || source == target)
return false;

for (const vertex_idx v_idx : out_neigbors[source]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class dag_vector_adapter {
: vertices_(out_neigbors_.size()), out_neigbors(&out_neigbors_), in_neigbors(&in_neigbors_), num_edges_(0),
num_vertex_types_(1) {

for (vertex_idx i = 0; i < out_neigbors_.size(); ++i) {
for (vertex_idx i = 0; i < static_cast<vertex_idx>(out_neigbors_.size()); ++i) {
vertices_[i].id = i;
num_edges_ += out_neigbors_[i].size();
}
Expand Down Expand Up @@ -131,7 +131,7 @@ class dag_vector_adapter {

inline vertex_idx num_vertices() const { return static_cast<vertex_idx>(vertices_.size()); }

inline std::size_t num_edges() const { return num_edges_; }
inline vertex_idx num_edges() const { return static_cast<vertex_idx>(num_edges_); }

inline auto parents(const vertex_idx v) const { return vector_cast_view<index_t, vertex_idx>(in_neigbors->at(v)); }

Expand Down