Skip to content

Commit

Permalink
[WIP] format subranges with +
Browse files Browse the repository at this point in the history
  • Loading branch information
fknorr committed Sep 13, 2023
1 parent fbe116c commit a0d550c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 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
14 changes: 7 additions & 7 deletions test/print_graph_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ TEST_CASE("task-graph printing is unchanged", "[print_graph][task-graph]") {
// replace the `expected` value with the new dot 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 \"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[];}";

const auto dot = tm.print_graph(std::numeric_limits<size_t>::max()).value();
CHECK(dot == expected);
Expand All @@ -66,9 +66,9 @@ TEST_CASE("command graph printing is unchanged", "[print_graph][command-graph]")
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 \"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_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[];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_5[label=<C5 on "
Expand Down Expand Up @@ -104,7 +104,7 @@ TEST_CASE_METHOD(test_utils::runtime_fixture, "Buffer debug names show up in the
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 \"print_graph_buffer_name_12\" "
"(device-compute)</font>>;color=darkgray;id_0_1[label=<C1 on N0<br/><b>execution</b> [0,0,0] - [16,1,1]<br/><i>write</i> B0 \"my_buffer\" {[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>write</i> B0 \"my_buffer\" {[0,0,0] "
"- [16,1,1]}> fontcolor=black shape=box];}subgraph cluster_id_0_2{label=<<font color=\"#606060\">T2 (epoch)</font>>;color=darkgray;id_0_2[label=<C2 "
"on N0<br/><b>epoch</b> (barrier)> fontcolor=black shape=box];}id_0_1->id_0_2[color=orange];id_0_0->id_0_1[];}";

Expand Down

0 comments on commit a0d550c

Please sign in to comment.