Skip to content

Commit 9f0dafd

Browse files
authored
More type fixes (#32)
* wsign-compare * wsign-compare * update * BspScheduleCS fix datastructure * BspScheduleCS fix
1 parent 18cde89 commit 9f0dafd

File tree

8 files changed

+32
-37
lines changed

8 files changed

+32
-37
lines changed

include/osp/auxiliary/io/DotFileWriter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class DotFileWriter {
246246

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

249-
if (i >= colors.size()) {
249+
if (i >= static_cast<vertex_idx_t<Graph_t>>(colors.size())) {
250250
// Fallback for safety: print without color if colors vector is mismatched or palette is empty.
251251
out << i << " [";
252252
} else {

include/osp/bsp/model/BspSchedule.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class BspSchedule : public IBspSchedule<Graph_t>, public IBspScheduleEval<Graph_
237237
*/
238238
void updateNumberOfSupersteps() {
239239
number_of_supersteps = 0;
240-
for (vertex_idx_t<Graph_t> i = 0; i < instance->numberOfVertices(); ++i) {
240+
for (vertex_idx_t<Graph_t> i = 0; i < static_cast<vertex_idx_t<Graph_t>>(instance->numberOfVertices()); ++i) {
241241
if (node_to_superstep_assignment[i] >= number_of_supersteps) {
242242
number_of_supersteps = node_to_superstep_assignment[i] + 1;
243243
}

include/osp/bsp/model/BspScheduleCS.hpp

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -331,24 +331,19 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
331331
node_to_proc_been_sent[node][BspSchedule<Graph_t>::node_to_processor_assignment[node]] = true;
332332
}
333333

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

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

344341
for (const auto &target : BspSchedule<Graph_t>::instance->getComputationalDag().children(node)) {
345342
if (proc != BspSchedule<Graph_t>::assignedProcessor(target)) {
346343
require_sending[proc].insert(
347-
{static_cast<vertex_idx_t<Graph_t>>(
348-
BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(node) *
349-
BspSchedule<Graph_t>::instance->getArchitecture().sendCosts(
350-
proc, BspSchedule<Graph_t>::node_to_processor_assignment[target])),
351-
node, BspSchedule<Graph_t>::node_to_processor_assignment[target]});
344+
{BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(node) * BspSchedule<Graph_t>::instance->getArchitecture().sendCosts(proc, BspSchedule<Graph_t>::node_to_processor_assignment[target]),
345+
node,
346+
BspSchedule<Graph_t>::node_to_processor_assignment[target]});
352347
}
353348
}
354349
}
@@ -374,8 +369,8 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
374369
BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(source) *
375370
BspSchedule<Graph_t>::instance->getArchitecture().sendCosts(
376371
BspSchedule<Graph_t>::node_to_processor_assignment[source], proc);
377-
require_sending[BspSchedule<Graph_t>::assignedProcessor(source)].erase(
378-
{static_cast<vertex_idx_t<Graph_t>>(comm_cost), source, proc});
372+
require_sending[BspSchedule<Graph_t>::node_to_processor_assignment[source]].erase(
373+
{comm_cost, source, proc});
379374
send_cost[BspSchedule<Graph_t>::node_to_processor_assignment[source]] += comm_cost;
380375
receive_cost[proc] += comm_cost;
381376
}
@@ -394,24 +389,25 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
394389
// TODO: permute the order of processors
395390
for (size_t proc = 0; proc < BspSchedule<Graph_t>::instance->numberOfProcessors(); proc++) {
396391
if (require_sending[proc].empty() ||
397-
static_cast<v_commw_t<Graph_t>>((*(require_sending[proc].rbegin()))[0]) + send_cost[proc] >
392+
std::get<0>(*require_sending[proc].rbegin()) + send_cost[proc] >
398393
max_comm_cost)
399394
continue;
400395
auto iter = require_sending[proc].begin();
401-
while (iter != require_sending[proc].cend()) {
402-
if (static_cast<v_commw_t<Graph_t>>((*iter)[0]) + send_cost[proc] > max_comm_cost ||
403-
static_cast<v_commw_t<Graph_t>>((*iter)[0]) + receive_cost[(*iter)[2]] > max_comm_cost) {
396+
while (iter != require_sending[proc].end()) {
397+
const auto& [comm_cost, node_to_send, dest_proc] = *iter;
398+
if (comm_cost + send_cost[proc] > max_comm_cost ||
399+
comm_cost + receive_cost[dest_proc] > max_comm_cost) {
404400
iter++;
405401
} else {
406-
commSchedule.emplace(std::make_tuple((*iter)[1], proc, (*iter)[2]), step - 1);
407-
node_to_proc_been_sent[(*iter)[1]][(*iter)[2]] = true;
408-
send_cost[proc] += static_cast<v_commw_t<Graph_t>>((*iter)[0]);
409-
receive_cost[(*iter)[2]] += static_cast<v_commw_t<Graph_t>>((*iter)[0]);
402+
commSchedule.emplace(std::make_tuple(node_to_send, proc, dest_proc), step - 1);
403+
node_to_proc_been_sent[node_to_send][dest_proc] = true;
404+
send_cost[proc] += comm_cost;
405+
receive_cost[dest_proc] += comm_cost;
410406
iter = require_sending[proc].erase(iter);
411407
if (require_sending[proc].empty() ||
412-
static_cast<v_commw_t<Graph_t>>((*(require_sending[proc].rbegin()))[0]) + send_cost[proc] >
408+
std::get<0>(*require_sending[proc].rbegin()) + send_cost[proc] >
413409
max_comm_cost)
414-
break;
410+
break; // Exit if no more sends can possibly fit.
415411
}
416412
}
417413
}
@@ -423,10 +419,9 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
423419
for (const auto &target : BspSchedule<Graph_t>::instance->getComputationalDag().children(node))
424420
if (proc != BspSchedule<Graph_t>::assignedProcessor(target)) {
425421
require_sending[proc].insert(
426-
{static_cast<vertex_idx_t<Graph_t>>(
427-
BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(node) *
422+
{BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(node) *
428423
BspSchedule<Graph_t>::instance->getArchitecture().sendCosts(
429-
proc, BspSchedule<Graph_t>::node_to_processor_assignment[target])),
424+
proc, BspSchedule<Graph_t>::node_to_processor_assignment[target]),
430425
node, BspSchedule<Graph_t>::node_to_processor_assignment[target]});
431426
}
432427
}

include/osp/dag_divider/isomorphism_divider/OrbitGraphProcessor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class OrbitGraphProcessor {
111111
simulate_merge(VertexType u, VertexType v, const Constr_Graph_t &current_coarse_graph) const {
112112
std::vector<VertexType> temp_contraction_map(current_coarse_graph.num_vertices());
113113
VertexType new_idx = 0;
114-
for (VertexType i = 0; i < temp_contraction_map.size(); ++i) {
114+
for (VertexType i = 0; i < static_cast<VertexType>(temp_contraction_map.size()); ++i) {
115115
if (i != v) {
116116
temp_contraction_map[i] = new_idx++;
117117
}
@@ -175,7 +175,7 @@ class OrbitGraphProcessor {
175175
locked_orbits = std::move(next_locked_orbits);
176176

177177
std::vector<Group> next_groups(current_coarse_graph.num_vertices());
178-
for (VertexType i = 0; i < current_groups.size(); ++i) {
178+
for (VertexType i = 0; i < static_cast<VertexType>(current_groups.size()); ++i) {
179179
if (i != u && i != v) {
180180
next_groups[group_remap[i]] = std::move(current_groups[i]);
181181
}

include/osp/graph_algorithms/directed_graph_edge_view.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class edge_view {
4242
const Graph_t *graph; // Pointer to the graph
4343
vertex_idx_t<Graph_t> current_vertex; // Current source vertex
4444
child_iterator_t current_child; // Iterator to the current target vertex in current_vertex's adjacency list
45-
std::size_t current_edge_idx; // Global index of the current edge in the traversal order
45+
vertex_idx_t<Graph_t> current_edge_idx; // Global index of the current edge in the traversal order
4646

4747
public:
4848
directed_edge_iterator() : graph(nullptr), current_vertex(0), current_edge_idx(0) {}
@@ -69,12 +69,12 @@ class edge_view {
6969
}
7070
}
7171

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

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

77-
std::size_t tmp = 0u;
77+
vertex_idx_t<Graph_t> tmp = 0u;
7878

7979
if (tmp < current_edge_idx) {
8080

include/osp/graph_algorithms/directed_graph_top_sort.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ std::vector<vertex_idx_t<Graph_t>> GetTopOrder(const Graph_t &graph) {
107107
}
108108
}
109109

110-
if (TopOrder.size() != graph.num_vertices())
110+
if (static_cast<VertexType>(TopOrder.size()) != graph.num_vertices())
111111
throw std::runtime_error("Error during topological ordering: TopOrder.size() != graph.num_vertices() [" +
112112
std::to_string(TopOrder.size()) + " != " + std::to_string(graph.num_vertices()) +
113113
"]");

include/osp/graph_implementations/adj_list_impl/computational_dag_vector_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class computational_dag_vector_impl {
172172

173173
bool add_edge(vertex_idx source, vertex_idx target) {
174174

175-
if (source >= vertices_.size() || target >= vertices_.size() || source == target)
175+
if (source >= static_cast<vertex_idx>(vertices_.size()) || target >= static_cast<vertex_idx>(vertices_.size()) || source == target)
176176
return false;
177177

178178
for (const vertex_idx v_idx : out_neigbors[source]) {

include/osp/graph_implementations/adj_list_impl/dag_vector_adapter.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class dag_vector_adapter {
100100
: vertices_(out_neigbors_.size()), out_neigbors(&out_neigbors_), in_neigbors(&in_neigbors_), num_edges_(0),
101101
num_vertex_types_(1) {
102102

103-
for (vertex_idx i = 0; i < out_neigbors_.size(); ++i) {
103+
for (vertex_idx i = 0; i < static_cast<vertex_idx>(out_neigbors_.size()); ++i) {
104104
vertices_[i].id = i;
105105
num_edges_ += out_neigbors_[i].size();
106106
}
@@ -131,7 +131,7 @@ class dag_vector_adapter {
131131

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

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

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

0 commit comments

Comments
 (0)