Skip to content

Commit

Permalink
fmt format subranges as "[offset] + [range]" instead of "[min] - [max]"
Browse files Browse the repository at this point in the history
  • Loading branch information
fknorr committed Sep 14, 2023
1 parent 2e67e44 commit 17feadb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
8 changes: 6 additions & 2 deletions include/print_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ struct fmt::formatter<celerity::detail::region<Dims>> : fmt::formatter<celerity:
};

template <int Dims>
struct fmt::formatter<celerity::subrange<Dims>> : fmt::formatter<celerity::detail::box<Dims>> {
struct fmt::formatter<celerity::subrange<Dims>> : fmt::formatter<celerity::id<Dims>> {
format_context::iterator format(const celerity::subrange<Dims>& sr, format_context& ctx) const {
return fmt::formatter<celerity::detail::box<Dims>>::format(celerity::detail::box(sr), ctx);
auto out = ctx.out();
out = formatter<celerity::id<Dims>>::format(sr.offset, ctx);
out = std::copy_n(" + ", 3, out);
out = formatter<celerity::id<Dims>>::format(celerity::id(sr.range), ctx); // cast to id to avoid multiple inheritance
return out;
}
};

Expand Down
30 changes: 15 additions & 15 deletions test/print_graph_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ TEST_CASE("task-graph printing is unchanged", "[print_graph][task-graph]") {
// replace the `expected` value with the new dot graph.
const std::string expected =
"digraph G {label=\"Task Graph\" 0[shape=ellipse label=<T0<br/><b>epoch</b>>];1[shape=box style=rounded label=<T1 \"task_initialize_2\" "
"<br/><b>device-compute</b> [0,0,0] - [64,1,1]<br/><i>discard_write</i> B1 {[0,0,0] - [1,1,1]}>];0->1[color=orchid];2[shape=box style=rounded "
"label=<T2 \"task_produce_3\" <br/><b>device-compute</b> [0,0,0] - [64,1,1]<br/><i>discard_write</i> B0 {[0,0,0] - "
"[64,1,1]}>];0->2[color=orchid];3[shape=box style=rounded label=<T3 \"task_reduce_4\" <br/><b>device-compute</b> [0,0,0] - [64,1,1]<br/>(R1) "
"<br/><b>device-compute</b> [0,0,0] + [64,1,1]<br/><i>discard_write</i> B1 {[0,0,0] - [1,1,1]}>];0->1[color=orchid];2[shape=box style=rounded "
"label=<T2 \"task_produce_3\" <br/><b>device-compute</b> [0,0,0] + [64,1,1]<br/><i>discard_write</i> B0 {[0,0,0] - "
"[64,1,1]}>];0->2[color=orchid];3[shape=box style=rounded label=<T3 \"task_reduce_4\" <br/><b>device-compute</b> [0,0,0] + [64,1,1]<br/>(R1) "
"<i>read_write</i> B1 {[0,0,0] - [1,1,1]}<br/><i>read</i> B0 {[0,0,0] - [64,1,1]}>];1->3[];2->3[];4[shape=box style=rounded label=<T4 "
"\"task_consume_5\" <br/><b>device-compute</b> [0,0,0] - [64,1,1]<br/><i>read</i> B1 {[0,0,0] - [1,1,1]}>];3->4[];}";
"\"task_consume_5\" <br/><b>device-compute</b> [0,0,0] + [64,1,1]<br/><i>read</i> B1 {[0,0,0] - [1,1,1]}>];3->4[];}";

CHECK(print_task_graph(tt.trec) == expected);
}
Expand Down Expand Up @@ -78,17 +78,17 @@ TEST_CASE("command graph printing is unchanged", "[print_graph][command-graph]")
const std::string expected =
"digraph G{label=\"Command Graph\" subgraph cluster_id_0_0{label=<<font color=\"#606060\">T0 (epoch)</font>>;color=darkgray;id_0_0[label=<C0 on "
"N0<br/><b>epoch</b>> fontcolor=black shape=box];}subgraph cluster_id_0_1{label=<<font color=\"#606060\">T1 \"reduce_8\" "
"(device-compute)</font>>;color=darkgray;id_0_1[label=<C1 on N0<br/><b>execution</b> [0,0,0] - [1,1,1]<br/>(R1) <i>discard_write</i> B0 {[0,0,0] - "
"(device-compute)</font>>;color=darkgray;id_0_1[label=<C1 on N0<br/><b>execution</b> [0,0,0] + [1,1,1]<br/>(R1) <i>discard_write</i> B0 {[0,0,0] - "
"[1,1,1]}> fontcolor=black shape=box];}subgraph cluster_id_0_2{label=<<font color=\"#606060\">T2 \"consume_9\" "
"(device-compute)</font>>;color=darkgray;id_0_2[label=<C2 on N0<br/><b>execution</b> [0,0,0] - [1,1,1]<br/><i>read</i> B0 {[0,0,0] - "
"(device-compute)</font>>;color=darkgray;id_0_2[label=<C2 on N0<br/><b>execution</b> [0,0,0] + [1,1,1]<br/><i>read</i> B0 {[0,0,0] - "
"[1,1,1]}<br/><i>read_write</i> B0 {[0,0,0] - [1,1,1]}<br/><i>write</i> B0 {[0,0,0] - [1,1,1]}> fontcolor=black "
"shape=box];}id_0_0->id_0_1[color=orchid];id_0_3->id_0_2[];id_0_5->id_0_2[color=limegreen];id_0_6->id_0_2[color=limegreen];id_0_7->id_0_2[color="
"limegreen];id_0_3[label=<C3 on N0<br/><b>reduction</b> R1<br/> B0 {[0,0,0] - [1,1,1]}> fontcolor=black "
"shape=ellipse];id_0_1->id_0_3[];id_0_4->id_0_3[];id_0_4[label=<C4 on N0<br/>(R1) <b>await push</b> transfer 8589934592 <br/>BB0 {[0,0,0] - "
"[1,1,1]}> fontcolor=black shape=ellipse];id_0_0->id_0_4[color=orchid];id_0_5[label=<C5 on N0<br/>(R1) <b>push</b> transfer 8589934593 to N1<br/>BB0 "
"[0,0,0] - [1,1,1]> fontcolor=black shape=ellipse];id_0_1->id_0_5[];id_0_6[label=<C6 on N0<br/>(R1) <b>push</b> transfer 8589934594 to N2<br/>BB0 "
"[0,0,0] - [1,1,1]> fontcolor=black shape=ellipse];id_0_1->id_0_6[];id_0_7[label=<C7 on N0<br/>(R1) <b>push</b> transfer 8589934595 to N3<br/>BB0 "
"[0,0,0] - [1,1,1]> fontcolor=black shape=ellipse];id_0_1->id_0_7[];}";
"[0,0,0] + [1,1,1]> fontcolor=black shape=ellipse];id_0_1->id_0_5[];id_0_6[label=<C6 on N0<br/>(R1) <b>push</b> transfer 8589934594 to N2<br/>BB0 "
"[0,0,0] + [1,1,1]> fontcolor=black shape=ellipse];id_0_1->id_0_6[];id_0_7[label=<C7 on N0<br/>(R1) <b>push</b> transfer 8589934595 to N3<br/>BB0 "
"[0,0,0] + [1,1,1]> fontcolor=black shape=ellipse];id_0_1->id_0_7[];}";

// fully check node 0
const auto dot0 = dctx.print_command_graph(0);
Expand Down Expand Up @@ -159,11 +159,11 @@ TEST_CASE_METHOD(test_utils::runtime_fixture, "full graph is printed if CELERITY
SECTION("task graph") {
const auto* expected =
"digraph G {label=\"Task Graph\" 0[shape=ellipse label=<T0<br/><b>epoch</b>>];1[shape=box style=rounded label=<T1 \"full_graph_printing_17\" "
"<br/><b>device-compute</b> [0,0,0] - [16,1,1]<br/><i>read_write</i> B0 {[0,0,0] - [16,1,1]}>];0->1[color=orchid];2[shape=ellipse "
"<br/><b>device-compute</b> [0,0,0] + [16,1,1]<br/><i>read_write</i> B0 {[0,0,0] - [16,1,1]}>];0->1[color=orchid];2[shape=ellipse "
"label=<T2<br/><b>horizon</b>>];1->2[color=orange];3[shape=box style=rounded label=<T3 \"full_graph_printing_17\" <br/><b>device-compute</b> "
"[0,0,0] - [16,1,1]<br/><i>read_write</i> B0 {[0,0,0] - [16,1,1]}>];1->3[];4[shape=ellipse "
"[0,0,0] + [16,1,1]<br/><i>read_write</i> B0 {[0,0,0] - [16,1,1]}>];1->3[];4[shape=ellipse "
"label=<T4<br/><b>horizon</b>>];3->4[color=orange];2->4[color=orange];5[shape=box style=rounded label=<T5 \"full_graph_printing_17\" "
"<br/><b>device-compute</b> [0,0,0] - [16,1,1]<br/><i>read_write</i> B0 {[0,0,0] - [16,1,1]}>];3->5[];6[shape=ellipse "
"<br/><b>device-compute</b> [0,0,0] + [16,1,1]<br/><i>read_write</i> B0 {[0,0,0] - [16,1,1]}>];3->5[];6[shape=ellipse "
"label=<T6<br/><b>horizon</b>>];5->6[color=orange];4->6[color=orange];7[shape=ellipse label=<T7<br/><b>epoch</b>>];6->7[color=orange];}";

CHECK(runtime_testspy::print_task_graph(celerity::detail::runtime::get_instance()) == expected);
Expand All @@ -173,13 +173,13 @@ TEST_CASE_METHOD(test_utils::runtime_fixture, "full graph is printed if CELERITY
const auto* expected =
"digraph G{label=\"Command Graph\" subgraph cluster_id_0_0{label=<<font color=\"#606060\">T0 (epoch)</font>>;color=darkgray;id_0_0[label=<C0 on "
"N0<br/><b>epoch</b>> fontcolor=black shape=box];}subgraph cluster_id_0_1{label=<<font color=\"#606060\">T1 \"full_graph_printing_17\" "
"(device-compute)</font>>;color=darkgray;id_0_1[label=<C1 on N0<br/><b>execution</b> [0,0,0] - [16,1,1]<br/><i>read_write</i> B0 {[0,0,0] - "
"(device-compute)</font>>;color=darkgray;id_0_1[label=<C1 on N0<br/><b>execution</b> [0,0,0] + [16,1,1]<br/><i>read_write</i> B0 {[0,0,0] - "
"[16,1,1]}> fontcolor=black shape=box];}subgraph cluster_id_0_2{label=<<font color=\"#606060\">T2 "
"(horizon)</font>>;color=darkgray;id_0_2[label=<C2 on N0<br/><b>horizon</b>> fontcolor=black shape=box];}subgraph cluster_id_0_3{label=<<font "
"color=\"#606060\">T3 \"full_graph_printing_17\" (device-compute)</font>>;color=darkgray;id_0_3[label=<C3 on N0<br/><b>execution</b> [0,0,0] - "
"color=\"#606060\">T3 \"full_graph_printing_17\" (device-compute)</font>>;color=darkgray;id_0_3[label=<C3 on N0<br/><b>execution</b> [0,0,0] + "
"[16,1,1]<br/><i>read_write</i> B0 {[0,0,0] - [16,1,1]}> fontcolor=black shape=box];}subgraph cluster_id_0_4{label=<<font color=\"#606060\">T4 "
"(horizon)</font>>;color=darkgray;id_0_4[label=<C4 on N0<br/><b>horizon</b>> fontcolor=black shape=box];}subgraph cluster_id_0_5{label=<<font "
"color=\"#606060\">T5 \"full_graph_printing_17\" (device-compute)</font>>;color=darkgray;id_0_5[label=<C5 on N0<br/><b>execution</b> [0,0,0] - "
"color=\"#606060\">T5 \"full_graph_printing_17\" (device-compute)</font>>;color=darkgray;id_0_5[label=<C5 on N0<br/><b>execution</b> [0,0,0] + "
"[16,1,1]<br/><i>read_write</i> B0 {[0,0,0] - [16,1,1]}> fontcolor=black shape=box];}subgraph cluster_id_0_6{label=<<font color=\"#606060\">T6 "
"(horizon)</font>>;color=darkgray;id_0_6[label=<C6 on N0<br/><b>horizon</b>> fontcolor=black shape=box];}subgraph cluster_id_0_7{label=<<font "
"color=\"#606060\">T7 (epoch)</font>>;color=darkgray;id_0_7[label=<C7 on N0<br/><b>epoch</b> (barrier)> fontcolor=black "
Expand Down

0 comments on commit 17feadb

Please sign in to comment.