Skip to content

Commit daa110a

Browse files
[SYCL][Graph] Make debug print tests deterministic (#12407)
The order of root node in debug print tests was not deterministic. This PR updates these tests to make them deterministic by creating dependencies between nodes. Addresses Issue: #12397
1 parent a6cb3f3 commit daa110a

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

sycl/test-e2e/Graph/Explicit/debug_print_graph.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
// CHECK-DAG: "0x[[#NODE4]]" -> "0x[[#NODE5]]
2525
// CHECK-NEXT: "0x[[#%x,NODE6:]]"
2626
// CHECK-SAME: [style=bold, label="ID = 0x[[#NODE6]]\nTYPE = CGCopy Device-to-Host \n"];
27+
// CHECK-DAG: "0x[[#NODE4]]" -> "0x[[#NODE6]]"
2728
// CHECK-NEXT: "0x[[#%x,NODE7:]]"
2829
// CHECK-SAME: [style=bold, label="ID = 0x[[#NODE7]]\nTYPE = None \n"];
30+
// CHECK-DAG: "0x[[#NODE6]]" -> "0x[[#NODE7]]"
2931

3032
#define GRAPH_E2E_EXPLICIT
3133

sycl/test-e2e/Graph/Explicit/debug_print_graph_verbose.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
// CHECK-DAG: "0x[[#NODE4]]" -> "0x[[#NODE5]]
3333
// CHECK-NEXT: "0x[[#%x,NODE6:]]"
3434
// CHECK-SAME: [style=bold, label="ID = 0x[[#NODE6]]\nTYPE = CGCopy Device-to-Host \nSrc: 0x[[#%x,ADDR27:]] Dst: 0x[[#%x,ADDR28:]]\n"];
35+
// CHECK-DAG: "0x[[#NODE4]]" -> "0x[[#NODE6]]"
3536
// CHECK-NEXT: "0x[[#%x,NODE7:]]"
3637
// CHECK-SAME: [style=bold, label="ID = 0x[[#NODE7]]\nTYPE = None \n"];
38+
// CHECK-DAG: "0x[[#NODE6]]" -> "0x[[#NODE7]]"
3739

3840
#define GRAPH_E2E_EXPLICIT
3941

sycl/test-e2e/Graph/Inputs/debug_print_graph.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,19 @@ int main() {
1212

1313
using T = unsigned short;
1414

15-
std::vector<T> DataA(Size), DataB(Size), DataC(Size);
16-
std::vector<T> DataA2D(Size * Size), DataB2D(Size * Size);
15+
std::vector<T> DataA(Size), DataB(Size), DataC(Size), DataD(Size);
1716

1817
std::iota(DataA.begin(), DataA.end(), 1);
1918
std::iota(DataB.begin(), DataB.end(), 10);
2019
std::iota(DataC.begin(), DataC.end(), 1000);
21-
std::iota(DataA2D.begin(), DataA2D.end(), 1);
22-
std::iota(DataB2D.begin(), DataB2D.end(), 10);
20+
std::iota(DataD.begin(), DataD.end(), 1);
2321

2422
buffer<T> BufferA{DataA.data(), range<1>{DataA.size()}};
2523
BufferA.set_write_back(false);
2624
buffer<T> BufferB{DataB.data(), range<1>{DataB.size()}};
2725
BufferB.set_write_back(false);
2826
buffer<T> BufferC{DataC.data(), range<1>{DataC.size()}};
2927
BufferC.set_write_back(false);
30-
buffer BufferA2D{DataA2D.data(), range<2>(Size, Size)};
31-
BufferA2D.set_write_back(false);
3228
{
3329
exp_ext::command_graph Graph{
3430
Queue.get_context(),
@@ -45,12 +41,12 @@ int main() {
4541
CGH.copy(AccB, AccA);
4642
});
4743

48-
add_node(Graph, Queue, [&](handler &CGH) {
49-
auto AccA = BufferA2D.get_access<access::mode::read>(CGH);
50-
CGH.copy(AccA, DataB2D.data());
44+
auto Last = add_node(Graph, Queue, [&](handler &CGH) {
45+
auto Acc = BufferC.get_access<access::mode::read>(CGH);
46+
CGH.copy(Acc, DataD.data());
5147
});
5248

53-
add_empty_node(Graph, Queue);
49+
add_empty_node(Graph, Queue, Last);
5450

5551
Graph.print_graph("graph.dot");
5652

sycl/test-e2e/Graph/Inputs/debug_print_graph_verbose.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,19 @@ int main() {
1212

1313
using T = unsigned short;
1414

15-
std::vector<T> DataA(Size), DataB(Size), DataC(Size);
16-
std::vector<T> DataA2D(Size * Size), DataB2D(Size * Size);
15+
std::vector<T> DataA(Size), DataB(Size), DataC(Size), DataD(Size);
1716

1817
std::iota(DataA.begin(), DataA.end(), 1);
1918
std::iota(DataB.begin(), DataB.end(), 10);
2019
std::iota(DataC.begin(), DataC.end(), 1000);
21-
std::iota(DataA2D.begin(), DataA2D.end(), 1);
22-
std::iota(DataB2D.begin(), DataB2D.end(), 10);
20+
std::iota(DataD.begin(), DataD.end(), 1);
2321

2422
buffer<T> BufferA{DataA.data(), range<1>{DataA.size()}};
2523
BufferA.set_write_back(false);
2624
buffer<T> BufferB{DataB.data(), range<1>{DataB.size()}};
2725
BufferB.set_write_back(false);
2826
buffer<T> BufferC{DataC.data(), range<1>{DataC.size()}};
2927
BufferC.set_write_back(false);
30-
buffer BufferA2D{DataA2D.data(), range<2>(Size, Size)};
31-
BufferA2D.set_write_back(false);
3228
{
3329
exp_ext::command_graph Graph{
3430
Queue.get_context(),
@@ -45,12 +41,12 @@ int main() {
4541
CGH.copy(AccB, AccA);
4642
});
4743

48-
add_node(Graph, Queue, [&](handler &CGH) {
49-
auto AccA = BufferA2D.get_access<access::mode::read>(CGH);
50-
CGH.copy(AccA, DataB2D.data());
44+
auto Last = add_node(Graph, Queue, [&](handler &CGH) {
45+
auto AccA = BufferC.get_access<access::mode::read>(CGH);
46+
CGH.copy(AccA, DataD.data());
5147
});
5248

53-
add_node(Graph, Queue, [&](handler &CGH) { /* empty node */ });
49+
add_empty_node(Graph, Queue, Last);
5450

5551
Graph.print_graph("graph_verbose.dot", true);
5652
}

sycl/test-e2e/Graph/RecordReplay/debug_print_graph.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
// CHECK-DAG: "0x[[#NODE4]]" -> "0x[[#NODE5]]
2525
// CHECK-NEXT: "0x[[#%x,NODE6:]]"
2626
// CHECK-SAME: [style=bold, label="ID = 0x[[#NODE6]]\nTYPE = CGCopy Device-to-Host \n"];
27+
// CHECK-DAG: "0x[[#NODE4]]" -> "0x[[#NODE6]]"
2728
// CHECK-NEXT: "0x[[#%x,NODE7:]]"
2829
// CHECK-SAME: [style=bold, label="ID = 0x[[#NODE7]]\nTYPE = None \n"];
30+
// CHECK-DAG: "0x[[#NODE6]]" -> "0x[[#NODE7]]"
2931

3032
#define GRAPH_E2E_RECORD_REPLAY
3133

sycl/test-e2e/Graph/RecordReplay/debug_print_graph_verbose.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
// CHECK-DAG: "0x[[#NODE4]]" -> "0x[[#NODE5]]
3434
// CHECK-NEXT: "0x[[#%x,NODE6:]]"
3535
// CHECK-SAME: [style=bold, label="ID = 0x[[#NODE6]]\nTYPE = CGCopy Device-to-Host \nSrc: 0x[[#%x,ADDR27:]] Dst: 0x[[#%x,ADDR28:]]\n"];
36+
// CHECK-DAG: "0x[[#NODE4]]" -> "0x[[#NODE6]]"
3637
// CHECK-NEXT: "0x[[#%x,NODE7:]]"
3738
// CHECK-SAME: [style=bold, label="ID = 0x[[#NODE7]]\nTYPE = None \n"];
39+
// CHECK-DAG: "0x[[#NODE6]]" -> "0x[[#NODE7]]"
3840

3941
#define GRAPH_E2E_RECORD_REPLAY
4042

0 commit comments

Comments
 (0)