From d65e8d90dde36ea07f6f38863e18536880ed99f0 Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Tue, 24 Oct 2023 13:48:32 +0100 Subject: [PATCH] [SYCL][Graph] Verbose E2E error messages The current error output from Graph E2E tests isn't particularly informative on the data that caused an assert to fail verification. As asserts are done on the whole container, rather than individual values. This change verifies each value individually so that a more informative error message can be printed when the assert fails. This is helpful for debugging issues that appear in CI but are hard to reproduce locally. Co-authored-by: Maxime France-Pillois --- sycl/test-e2e/Graph/Explicit/depends_on.cpp | 6 +++--- .../Graph/Explicit/enqueue_ordering.cpp | 3 ++- .../test-e2e/Graph/Explicit/node_ordering.cpp | 5 +++-- sycl/test-e2e/Graph/Explicit/single_node.cpp | 14 ++++++++------ .../Graph/Inputs/add_nodes_after_finalize.cpp | 6 ++++-- sycl/test-e2e/Graph/Inputs/basic_buffer.cpp | 6 +++--- sycl/test-e2e/Graph/Inputs/basic_usm.cpp | 8 +++++--- sycl/test-e2e/Graph/Inputs/basic_usm_host.cpp | 8 +++++--- .../test-e2e/Graph/Inputs/basic_usm_mixed.cpp | 8 +++++--- .../Graph/Inputs/basic_usm_shared.cpp | 8 +++++--- .../Graph/Inputs/basic_usm_system.cpp | 8 +++++--- sycl/test-e2e/Graph/Inputs/buffer_copy.cpp | 8 ++++---- sycl/test-e2e/Graph/Inputs/buffer_copy_2d.cpp | 9 +++++---- .../Graph/Inputs/buffer_copy_host2target.cpp | 2 +- .../Inputs/buffer_copy_host2target_2d.cpp | 3 ++- .../Inputs/buffer_copy_host2target_offset.cpp | 2 +- .../Graph/Inputs/buffer_copy_offsets.cpp | 4 ++-- .../Graph/Inputs/buffer_copy_target2host.cpp | 4 ++-- .../Inputs/buffer_copy_target2host_2d.cpp | 4 ++-- .../Inputs/buffer_copy_target2host_offset.cpp | 4 ++-- .../test-e2e/Graph/Inputs/buffer_ordering.cpp | 8 +++++--- sycl/test-e2e/Graph/Inputs/double_buffer.cpp | 16 +++++++++------- sycl/test-e2e/Graph/Inputs/empty_node.cpp | 5 +++-- .../Graph/Inputs/event_status_querying.cpp | 6 +++--- .../Graph/Inputs/executable_graph_update.cpp | 16 +++++++++------- .../executable_graph_update_ordering.cpp | 18 ++++++++++-------- sycl/test-e2e/Graph/Inputs/host_task.cpp | 4 +++- .../Graph/Inputs/multiple_exec_graphs.cpp | 8 +++++--- .../Graph/Inputs/multiple_kernel_bundles.cpp | 2 +- .../test-e2e/Graph/Inputs/queue_shortcuts.cpp | 8 +++++--- sycl/test-e2e/Graph/Inputs/repeated_exec.cpp | 19 +++++++++++-------- sycl/test-e2e/Graph/Inputs/sub_graph.cpp | 11 +++++++---- .../sub_graph_execute_without_parent.cpp | 4 ++-- .../Inputs/sub_graph_multiple_submission.cpp | 3 ++- .../Graph/Inputs/sub_graph_nested.cpp | 4 ++-- .../Inputs/sub_graph_two_parent_graphs.cpp | 5 +++-- .../Graph/Inputs/temp_buffer_reinterpret.cpp | 8 +++++--- sycl/test-e2e/Graph/Inputs/usm_copy.cpp | 10 ++++++---- sycl/test-e2e/Graph/Inputs/usm_fill.cpp | 4 ++-- sycl/test-e2e/Graph/Inputs/usm_fill_host.cpp | 4 ++-- .../test-e2e/Graph/Inputs/usm_fill_shared.cpp | 4 ++-- .../test-e2e/Graph/RecordReplay/after_use.cpp | 8 +++++--- .../Graph/RecordReplay/barrier_with_work.cpp | 8 +++++--- .../Graph/RecordReplay/temp_buffer.cpp | 2 +- .../Graph/RecordReplay/temp_scope.cpp | 2 +- .../Graph/RecordReplay/usm_copy_in_order.cpp | 3 ++- sycl/test-e2e/Graph/graph_common.hpp | 13 +++++++++++++ .../Graph/submission_while_executing.cpp | 8 +++++--- 48 files changed, 198 insertions(+), 133 deletions(-) diff --git a/sycl/test-e2e/Graph/Explicit/depends_on.cpp b/sycl/test-e2e/Graph/Explicit/depends_on.cpp index 47b76272f8e09..2165b2d0ad5b5 100644 --- a/sycl/test-e2e/Graph/Explicit/depends_on.cpp +++ b/sycl/test-e2e/Graph/Explicit/depends_on.cpp @@ -37,11 +37,11 @@ int main() { Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }).wait(); - constexpr int ref = 42 * 2; + constexpr int Ref = 42 * 2; std::vector Output(N); Queue.memcpy(Output.data(), Arr, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(Output[i] == ref); + for (size_t i = 0; i < N; i++) + assert(check_value(i, Output[i], Ref, "Ref")); sycl::free(Arr, Queue); diff --git a/sycl/test-e2e/Graph/Explicit/enqueue_ordering.cpp b/sycl/test-e2e/Graph/Explicit/enqueue_ordering.cpp index 87dba2a29da27..54b96cfcbaa23 100644 --- a/sycl/test-e2e/Graph/Explicit/enqueue_ordering.cpp +++ b/sycl/test-e2e/Graph/Explicit/enqueue_ordering.cpp @@ -80,8 +80,9 @@ int main() { Queue.wait(); + const int Expected = 22; for (size_t i = 0; i < N; i++) { - assert(Arr[i] == 22); + assert(check_value(i, Arr[i], Expected, "Expected")); } // Free the allocated memory diff --git a/sycl/test-e2e/Graph/Explicit/node_ordering.cpp b/sycl/test-e2e/Graph/Explicit/node_ordering.cpp index 7f51f56b2a10f..4462127667477 100644 --- a/sycl/test-e2e/Graph/Explicit/node_ordering.cpp +++ b/sycl/test-e2e/Graph/Explicit/node_ordering.cpp @@ -42,8 +42,9 @@ int main() { std::vector Output(N); Queue.memcpy(Output.data(), X, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(Output[i] == 8); + const int Expected = 8; + for (size_t i = 0; i < N; i++) + assert(check_value(i, Output[i], Expected, "Expected")); sycl::free(X, Queue); diff --git a/sycl/test-e2e/Graph/Explicit/single_node.cpp b/sycl/test-e2e/Graph/Explicit/single_node.cpp index f9fcc76c4ef3c..47d06e20b701d 100644 --- a/sycl/test-e2e/Graph/Explicit/single_node.cpp +++ b/sycl/test-e2e/Graph/Explicit/single_node.cpp @@ -31,20 +31,22 @@ int main() { std::vector Output(N); Queue.memcpy(Output.data(), Arr, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(Output[i] == 0); + int Expected = 0; + for (size_t i = 0; i < N; i++) + assert(check_value(i, Output[i], Expected, "Expected")); auto ExecGraph = Graph.finalize(); Queue.memcpy(Output.data(), Arr, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(Output[i] == 0); + for (size_t i = 0; i < N; i++) + assert(check_value(i, Output[i], Expected, "Expected")); Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }).wait(); Queue.memcpy(Output.data(), Arr, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(Output[i] == 3); + Expected = 3; + for (size_t i = 0; i < N; i++) + assert(check_value(i, Output[i], Expected, "Expected")); sycl::free(Arr, Queue); diff --git a/sycl/test-e2e/Graph/Inputs/add_nodes_after_finalize.cpp b/sycl/test-e2e/Graph/Inputs/add_nodes_after_finalize.cpp index 68e1712409281..3a11b20cb997a 100644 --- a/sycl/test-e2e/Graph/Inputs/add_nodes_after_finalize.cpp +++ b/sycl/test-e2e/Graph/Inputs/add_nodes_after_finalize.cpp @@ -85,8 +85,10 @@ int main() { free(PtrC, Queue); free(PtrOut, Queue); - assert(ReferenceC == DataC); - assert(ReferenceOut == DataOut); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + assert(check_value(i, ReferenceOut[i], DataOut[i], "DataOut")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/basic_buffer.cpp b/sycl/test-e2e/Graph/Inputs/basic_buffer.cpp index e3446e1cc0a60..91308be25761d 100644 --- a/sycl/test-e2e/Graph/Inputs/basic_buffer.cpp +++ b/sycl/test-e2e/Graph/Inputs/basic_buffer.cpp @@ -51,9 +51,9 @@ int main() { host_accessor HostAccC(BufferC); for (size_t i = 0; i < Size; i++) { - assert(ReferenceA[i] == HostAccA[i]); - assert(ReferenceB[i] == HostAccB[i]); - assert(ReferenceC[i] == HostAccC[i]); + assert(check_value(i, ReferenceA[i], HostAccA[i], "HostAccA")); + assert(check_value(i, ReferenceB[i], HostAccB[i], "HostAccB")); + assert(check_value(i, ReferenceC[i], HostAccC[i], "HostAccC")); } return 0; diff --git a/sycl/test-e2e/Graph/Inputs/basic_usm.cpp b/sycl/test-e2e/Graph/Inputs/basic_usm.cpp index cf48b955b9459..6caa3a5d42aef 100644 --- a/sycl/test-e2e/Graph/Inputs/basic_usm.cpp +++ b/sycl/test-e2e/Graph/Inputs/basic_usm.cpp @@ -63,9 +63,11 @@ int main() { free(PtrB, Queue); free(PtrC, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/basic_usm_host.cpp b/sycl/test-e2e/Graph/Inputs/basic_usm_host.cpp index 44cae7ac52235..59447ee3a213d 100644 --- a/sycl/test-e2e/Graph/Inputs/basic_usm_host.cpp +++ b/sycl/test-e2e/Graph/Inputs/basic_usm_host.cpp @@ -58,9 +58,11 @@ int main() { free(PtrB, Queue); free(PtrC, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/basic_usm_mixed.cpp b/sycl/test-e2e/Graph/Inputs/basic_usm_mixed.cpp index a11b201d1476b..3db89123a69fb 100644 --- a/sycl/test-e2e/Graph/Inputs/basic_usm_mixed.cpp +++ b/sycl/test-e2e/Graph/Inputs/basic_usm_mixed.cpp @@ -61,9 +61,11 @@ int main() { free(PtrB, Queue); free(PtrC, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/basic_usm_shared.cpp b/sycl/test-e2e/Graph/Inputs/basic_usm_shared.cpp index da4d951583c0f..d769b4af34072 100644 --- a/sycl/test-e2e/Graph/Inputs/basic_usm_shared.cpp +++ b/sycl/test-e2e/Graph/Inputs/basic_usm_shared.cpp @@ -58,9 +58,11 @@ int main() { free(PtrB, Queue); free(PtrC, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/basic_usm_system.cpp b/sycl/test-e2e/Graph/Inputs/basic_usm_system.cpp index 57d0c135ee39b..1b199cc55a4a3 100644 --- a/sycl/test-e2e/Graph/Inputs/basic_usm_system.cpp +++ b/sycl/test-e2e/Graph/Inputs/basic_usm_system.cpp @@ -57,9 +57,11 @@ int main() { free(PtrB, Queue); delete[] PtrC; - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/buffer_copy.cpp b/sycl/test-e2e/Graph/Inputs/buffer_copy.cpp index 3430cc8cf9124..76be8ec030534 100644 --- a/sycl/test-e2e/Graph/Inputs/buffer_copy.cpp +++ b/sycl/test-e2e/Graph/Inputs/buffer_copy.cpp @@ -16,7 +16,7 @@ int main() { // Create reference data for output std::vector ReferenceA(DataA), ReferenceB(DataB), ReferenceC(DataC); - for (unsigned i = 0; i < Iterations; i++) { + for (size_t i = 0; i < Iterations; i++) { for (size_t j = 0; j < Size; j++) { ReferenceA[j] = ReferenceB[j]; ReferenceA[j] += ModValue; @@ -120,9 +120,9 @@ int main() { host_accessor HostAccC(BufferC); for (size_t i = 0; i < Size; i++) { - assert(ReferenceA[i] == HostAccA[i]); - assert(ReferenceB[i] == HostAccB[i]); - assert(ReferenceC[i] == HostAccC[i]); + assert(check_value(i, ReferenceA[i], HostAccA[i], "HostAccA")); + assert(check_value(i, ReferenceB[i], HostAccB[i], "HostAccB")); + assert(check_value(i, ReferenceC[i], HostAccC[i], "HostAccC")); } return 0; diff --git a/sycl/test-e2e/Graph/Inputs/buffer_copy_2d.cpp b/sycl/test-e2e/Graph/Inputs/buffer_copy_2d.cpp index 2b2020d68faf9..3476e4a534527 100644 --- a/sycl/test-e2e/Graph/Inputs/buffer_copy_2d.cpp +++ b/sycl/test-e2e/Graph/Inputs/buffer_copy_2d.cpp @@ -17,7 +17,7 @@ int main() { // Create reference data for output std::vector ReferenceA(DataA), ReferenceB(DataB), ReferenceC(DataC); - for (unsigned i = 0; i < Iterations; i++) { + for (size_t i = 0; i < Iterations; i++) { for (size_t j = 0; j < Size * Size; j++) { ReferenceA[j] = ReferenceB[j]; ReferenceA[j] += ModValue; @@ -116,9 +116,10 @@ int main() { for (size_t i = 0; i < Size; i++) { for (size_t j = 0; j < Size; j++) { - assert(ReferenceA[i * Size + j] == HostAccA[i][j]); - assert(ReferenceB[i * Size + j] == HostAccB[i][j]); - assert(ReferenceC[i * Size + j] == HostAccC[i][j]); + const size_t index = i * Size + j; + assert(check_value(index, ReferenceA[index], HostAccA[i][j], "HostAccA")); + assert(check_value(index, ReferenceB[index], HostAccB[i][j], "HostAccB")); + assert(check_value(index, ReferenceC[index], HostAccC[i][j], "HostAccC")); } } diff --git a/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target.cpp b/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target.cpp index 5bbf0cd472f93..3cafeec7068bb 100644 --- a/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target.cpp +++ b/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target.cpp @@ -38,7 +38,7 @@ int main() { host_accessor HostAccA(BufferA); for (size_t i = 0; i < Size; i++) { - assert(ReferenceA[i] == HostAccA[i]); + assert(check_value(i, ReferenceA[i], HostAccA[i], "HostAccA")); } return 0; diff --git a/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_2d.cpp b/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_2d.cpp index 63127ed672f3c..48081164859b1 100644 --- a/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_2d.cpp +++ b/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_2d.cpp @@ -39,7 +39,8 @@ int main() { for (size_t i = 0; i < Size; i++) { for (size_t j = 0; j < Size; j++) { - assert(ReferenceA[i * Size + j] == HostAccA[i][j]); + const size_t index = i * Size + j; + assert(check_value(index, ReferenceA[index], HostAccA[i][j], "HostAccA")); } } diff --git a/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_offset.cpp b/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_offset.cpp index cb3c96da84ea9..42a9d7a4f69b4 100644 --- a/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_offset.cpp +++ b/sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_offset.cpp @@ -42,7 +42,7 @@ int main() { host_accessor HostAccA(BufferA); for (size_t i = 0; i < Size + Offset; i++) { - assert(ReferenceA[i] == HostAccA[i]); + assert(check_value(i, ReferenceA[i], HostAccA[i], "HostAccA")); } return 0; diff --git a/sycl/test-e2e/Graph/Inputs/buffer_copy_offsets.cpp b/sycl/test-e2e/Graph/Inputs/buffer_copy_offsets.cpp index 6cd96097830ec..ae70dfd4c44da 100644 --- a/sycl/test-e2e/Graph/Inputs/buffer_copy_offsets.cpp +++ b/sycl/test-e2e/Graph/Inputs/buffer_copy_offsets.cpp @@ -53,8 +53,8 @@ int main() { host_accessor HostAccB(BufferB); for (size_t i = 0; i < Size; i++) { - assert(ReferenceA[i] == HostAccA[i]); - assert(ReferenceB[i] == HostAccB[i]); + assert(check_value(i, ReferenceA[i], HostAccA[i], "HostAccA")); + assert(check_value(i, ReferenceB[i], HostAccB[i], "HostAccB")); } return 0; diff --git a/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host.cpp b/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host.cpp index 5d906ad7d0ae3..a37b941ac40e3 100644 --- a/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host.cpp +++ b/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host.cpp @@ -37,8 +37,8 @@ int main() { } for (size_t i = 0; i < Size; i++) { - assert(ReferenceA[i] == DataA[i]); - assert(ReferenceB[i] == DataB[i]); + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); } return 0; diff --git a/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_2d.cpp b/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_2d.cpp index 6a36fac81711b..5f5058814f261 100644 --- a/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_2d.cpp +++ b/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_2d.cpp @@ -40,8 +40,8 @@ int main() { host_accessor HostAccA(BufferA); for (size_t i = 0; i < Size * Size; i++) { - assert(ReferenceA[i] == DataA[i]); - assert(ReferenceB[i] == DataB[i]); + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); } return 0; diff --git a/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_offset.cpp b/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_offset.cpp index 3f0880a318cf5..9f6338a7436b8 100644 --- a/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_offset.cpp +++ b/sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_offset.cpp @@ -41,8 +41,8 @@ int main() { } for (size_t i = 0; i < Size; i++) { - assert(ReferenceA[i] == DataA[i]); - assert(ReferenceB[i] == DataB[i]); + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); } return 0; diff --git a/sycl/test-e2e/Graph/Inputs/buffer_ordering.cpp b/sycl/test-e2e/Graph/Inputs/buffer_ordering.cpp index e86ed69aabfce..cd826f5109f6a 100644 --- a/sycl/test-e2e/Graph/Inputs/buffer_ordering.cpp +++ b/sycl/test-e2e/Graph/Inputs/buffer_ordering.cpp @@ -44,8 +44,9 @@ int main() { }); }); + const int Zero = 0; for (size_t i = 0; i < N; i++) { - assert(Arr[i] == 0); + assert(check_value(i, Arr[i], Zero, "Zero")); } // Buffer elements set to 4 @@ -60,7 +61,7 @@ int main() { auto ExecGraph = Graph.finalize(); for (size_t i = 0; i < N; i++) { - assert(Arr[i] == 0); + assert(check_value(i, Arr[i], Zero, "Zero")); } // Buffer elements set to 8 @@ -96,8 +97,9 @@ int main() { Queue.wait(); } + const int Expected = 22; for (size_t i = 0; i < N; i++) { - assert(Arr[i] == 22); + assert(check_value(i, Arr[i], Expected, "Expected")); } return 0; diff --git a/sycl/test-e2e/Graph/Inputs/double_buffer.cpp b/sycl/test-e2e/Graph/Inputs/double_buffer.cpp index 7a9551251e117..413a9bc105437 100644 --- a/sycl/test-e2e/Graph/Inputs/double_buffer.cpp +++ b/sycl/test-e2e/Graph/Inputs/double_buffer.cpp @@ -56,7 +56,7 @@ int main() { add_nodes(GraphUpdate, Queue, Size, PtrA, PtrB, PtrC); event Event; - for (unsigned i = 0; i < Iterations; i++) { + for (size_t i = 0; i < Iterations; i++) { Event = Queue.submit([&](handler &CGH) { CGH.depends_on(Event); CGH.ext_oneapi_graph(ExecGraph); @@ -90,13 +90,15 @@ int main() { free(PtrB2, Queue); free(PtrC2, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); - assert(ReferenceA2 == DataA2); - assert(ReferenceB2 == DataB2); - assert(ReferenceC2 == DataC2); + assert(check_value(i, ReferenceA2[i], DataA2[i], "DataA2")); + assert(check_value(i, ReferenceB2[i], DataB2[i], "DataB2")); + assert(check_value(i, ReferenceC2[i], DataC2[i], "DataC2")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/empty_node.cpp b/sycl/test-e2e/Graph/Inputs/empty_node.cpp index cac05e4a2d5ba..fc8001f106ba7 100644 --- a/sycl/test-e2e/Graph/Inputs/empty_node.cpp +++ b/sycl/test-e2e/Graph/Inputs/empty_node.cpp @@ -50,8 +50,9 @@ int main() { std::vector HostData(N); Queue.memcpy(HostData.data(), Arr, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(HostData[i] == 1); + const int Expected = 1; + for (size_t i = 0; i < N; i++) + assert(check_value(i, HostData[i], Expected, "Expected")); sycl::free(Arr, Queue); diff --git a/sycl/test-e2e/Graph/Inputs/event_status_querying.cpp b/sycl/test-e2e/Graph/Inputs/event_status_querying.cpp index 1e2bb02577955..2ed308bfccad9 100644 --- a/sycl/test-e2e/Graph/Inputs/event_status_querying.cpp +++ b/sycl/test-e2e/Graph/Inputs/event_status_querying.cpp @@ -137,9 +137,9 @@ int main() { host_accessor HostAccC(BufferC); for (size_t i = 0; i < Size; i++) { - assert(ReferenceA[i] == HostAccA[i]); - assert(ReferenceB[i] == HostAccB[i]); - assert(ReferenceC[i] == HostAccC[i]); + assert(check_value(i, ReferenceA[i], HostAccA[i], "HostAccA")); + assert(check_value(i, ReferenceB[i], HostAccB[i], "HostAccB")); + assert(check_value(i, ReferenceC[i], HostAccC[i], "HostAccC")); } return 0; diff --git a/sycl/test-e2e/Graph/Inputs/executable_graph_update.cpp b/sycl/test-e2e/Graph/Inputs/executable_graph_update.cpp index 709194d55716f..9e5aca403420c 100644 --- a/sycl/test-e2e/Graph/Inputs/executable_graph_update.cpp +++ b/sycl/test-e2e/Graph/Inputs/executable_graph_update.cpp @@ -89,13 +89,15 @@ int main() { free(PtrB2, Queue); free(PtrC2, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); - - assert(ReferenceA == DataA2); - assert(ReferenceB == DataB2); - assert(ReferenceC == DataC2); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + + assert(check_value(i, ReferenceA[i], DataA2[i], "DataA2")); + assert(check_value(i, ReferenceB[i], DataB2[i], "DataB2")); + assert(check_value(i, ReferenceC[i], DataC2[i], "DataC2")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/executable_graph_update_ordering.cpp b/sycl/test-e2e/Graph/Inputs/executable_graph_update_ordering.cpp index 7572029cebc07..e920daf7addf2 100644 --- a/sycl/test-e2e/Graph/Inputs/executable_graph_update_ordering.cpp +++ b/sycl/test-e2e/Graph/Inputs/executable_graph_update_ordering.cpp @@ -126,14 +126,16 @@ int main() { free(PtrB2, Queue); free(PtrC2, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); - assert(ReferenceC == HostTaskOutput); - - assert(ReferenceA == DataA2); - assert(ReferenceB == DataB2); - assert(ReferenceC == DataC2); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + assert(check_value(i, ReferenceC[i], HostTaskOutput[i], "HostTaskOutput")); + + assert(check_value(i, ReferenceA[i], DataA2[i], "DataA2")); + assert(check_value(i, ReferenceB[i], DataB2[i], "DataB2")); + assert(check_value(i, ReferenceC[i], DataC2[i], "DataC2")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/host_task.cpp b/sycl/test-e2e/Graph/Inputs/host_task.cpp index 89cc03e1de3b0..bfc00bde45776 100644 --- a/sycl/test-e2e/Graph/Inputs/host_task.cpp +++ b/sycl/test-e2e/Graph/Inputs/host_task.cpp @@ -82,7 +82,9 @@ int main() { free(PtrB, Queue); free(PtrC, Queue); - assert(Reference == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/multiple_exec_graphs.cpp b/sycl/test-e2e/Graph/Inputs/multiple_exec_graphs.cpp index 2ae801851eaf6..21b4ed1ba4145 100644 --- a/sycl/test-e2e/Graph/Inputs/multiple_exec_graphs.cpp +++ b/sycl/test-e2e/Graph/Inputs/multiple_exec_graphs.cpp @@ -54,9 +54,11 @@ int main() { free(PtrB, Queue); free(PtrC, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/multiple_kernel_bundles.cpp b/sycl/test-e2e/Graph/Inputs/multiple_kernel_bundles.cpp index 67f5113ddc497..a250bb5037c23 100644 --- a/sycl/test-e2e/Graph/Inputs/multiple_kernel_bundles.cpp +++ b/sycl/test-e2e/Graph/Inputs/multiple_kernel_bundles.cpp @@ -107,7 +107,7 @@ int main() { host_accessor HostAccA(BufferA); for (size_t i = 0; i < Size; i++) - assert(ReferenceA[i] == HostAccA[i]); + assert(check_value(i, ReferenceA[i], HostAccA[i], "HostAccA")); return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/queue_shortcuts.cpp b/sycl/test-e2e/Graph/Inputs/queue_shortcuts.cpp index 7e5cc9c3a99d4..45041b7486708 100644 --- a/sycl/test-e2e/Graph/Inputs/queue_shortcuts.cpp +++ b/sycl/test-e2e/Graph/Inputs/queue_shortcuts.cpp @@ -59,9 +59,11 @@ int main() { free(PtrB, Queue); free(PtrC, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/repeated_exec.cpp b/sycl/test-e2e/Graph/Inputs/repeated_exec.cpp index 2dd57f53a7335..6ae4b43d61042 100644 --- a/sycl/test-e2e/Graph/Inputs/repeated_exec.cpp +++ b/sycl/test-e2e/Graph/Inputs/repeated_exec.cpp @@ -22,26 +22,29 @@ int main() { std::vector Output(N); Queue.memcpy(Output.data(), Arr, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(Output[i] == 0); + int Expected = 0; + for (size_t i = 0; i < N; i++) + assert(check_value(i, Output[i], Expected, "Expected")); auto ExecGraph = Graph.finalize(); Queue.memcpy(Output.data(), Arr, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(Output[i] == 0); + for (size_t i = 0; i < N; i++) + assert(check_value(i, Output[i], Expected, "Expected")); Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }).wait(); Queue.memcpy(Output.data(), Arr, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(Output[i] == 1); + Expected = 1; + for (size_t i = 0; i < N; i++) + assert(check_value(i, Output[i], Expected, "Expected")); Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }).wait(); Queue.memcpy(Output.data(), Arr, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(Output[i] == 2); + Expected = 2; + for (size_t i = 0; i < N; i++) + assert(check_value(i, Output[i], Expected, "Expected")); sycl::free(Arr, Queue); diff --git a/sycl/test-e2e/Graph/Inputs/sub_graph.cpp b/sycl/test-e2e/Graph/Inputs/sub_graph.cpp index 203bb41544fa2..b1cb2a8299f0d 100644 --- a/sycl/test-e2e/Graph/Inputs/sub_graph.cpp +++ b/sycl/test-e2e/Graph/Inputs/sub_graph.cpp @@ -118,9 +118,12 @@ int main() { free(PtrC, Queue); free(PtrOut, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); - assert(ReferenceOut == DataOut); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + assert(check_value(i, ReferenceOut[i], DataOut[i], "DataOut")); + } + return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/sub_graph_execute_without_parent.cpp b/sycl/test-e2e/Graph/Inputs/sub_graph_execute_without_parent.cpp index 3ee2d270c9160..a008b045c61fb 100644 --- a/sycl/test-e2e/Graph/Inputs/sub_graph_execute_without_parent.cpp +++ b/sycl/test-e2e/Graph/Inputs/sub_graph_execute_without_parent.cpp @@ -64,9 +64,9 @@ int main() { std::vector Output(N); Queue.memcpy(Output.data(), X, N * sizeof(int), Event3).wait(); - const int ref = ((1 * 3 + 2) * 2 * 3 + 2) * -1; + const int Ref = ((1 * 3 + 2) * 2 * 3 + 2) * -1; for (size_t i = 0; i < N; i++) { - assert(Output[i] == ref); + assert(check_value(i, Output[i], Ref, "Ref")); } sycl::free(X, Queue); diff --git a/sycl/test-e2e/Graph/Inputs/sub_graph_multiple_submission.cpp b/sycl/test-e2e/Graph/Inputs/sub_graph_multiple_submission.cpp index 57f5f539b7c9e..6b6e3e08e896a 100644 --- a/sycl/test-e2e/Graph/Inputs/sub_graph_multiple_submission.cpp +++ b/sycl/test-e2e/Graph/Inputs/sub_graph_multiple_submission.cpp @@ -61,8 +61,9 @@ int main() { std::vector Output(N); Queue.memcpy(Output.data(), X, N * sizeof(int), E).wait(); + const int Expected = -5; for (size_t i = 0; i < N; i++) { - assert(Output[i] == -5); + assert(check_value(i, Output[i], Expected, "Expected")); } sycl::free(X, Queue); diff --git a/sycl/test-e2e/Graph/Inputs/sub_graph_nested.cpp b/sycl/test-e2e/Graph/Inputs/sub_graph_nested.cpp index e5af84025fd50..822db5c54aa91 100644 --- a/sycl/test-e2e/Graph/Inputs/sub_graph_nested.cpp +++ b/sycl/test-e2e/Graph/Inputs/sub_graph_nested.cpp @@ -131,8 +131,8 @@ int main() { Queue.memcpy(Output.data(), Z, N * sizeof(int), E).wait(); for (size_t i = 0; i < N; i++) { - int ref = reference(i); - assert(Output[i] == ref); + int Ref = reference(i); + assert(check_value(i, Output[i], Ref, "Ref")); } sycl::free(X, Queue); diff --git a/sycl/test-e2e/Graph/Inputs/sub_graph_two_parent_graphs.cpp b/sycl/test-e2e/Graph/Inputs/sub_graph_two_parent_graphs.cpp index 1568b64d8b293..ee58b95496954 100644 --- a/sycl/test-e2e/Graph/Inputs/sub_graph_two_parent_graphs.cpp +++ b/sycl/test-e2e/Graph/Inputs/sub_graph_two_parent_graphs.cpp @@ -91,9 +91,10 @@ int main() { return result; }; + const int NegThree = -3; for (size_t i = 0; i < N; i++) { - assert(OutputA[i] == -3); - assert(OutputB[i] == refB(i)); + assert(check_value(i, OutputA[i], NegThree, "NegThree")); + assert(check_value(i, OutputB[i], refB(i), "refB")); } sycl::free(X, Queue); diff --git a/sycl/test-e2e/Graph/Inputs/temp_buffer_reinterpret.cpp b/sycl/test-e2e/Graph/Inputs/temp_buffer_reinterpret.cpp index b5b98c4a884cc..f98a2bac8896e 100644 --- a/sycl/test-e2e/Graph/Inputs/temp_buffer_reinterpret.cpp +++ b/sycl/test-e2e/Graph/Inputs/temp_buffer_reinterpret.cpp @@ -58,9 +58,11 @@ int main() { Queue.wait_and_throw(); } - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/usm_copy.cpp b/sycl/test-e2e/Graph/Inputs/usm_copy.cpp index 640565364cc52..ca75bb844b747 100644 --- a/sycl/test-e2e/Graph/Inputs/usm_copy.cpp +++ b/sycl/test-e2e/Graph/Inputs/usm_copy.cpp @@ -16,7 +16,7 @@ int main() { // Create reference data for output std::vector ReferenceA(DataA), ReferenceB(DataB), ReferenceC(DataC); - for (unsigned i = 0; i < Iterations; i++) { + for (size_t i = 0; i < Iterations; i++) { for (size_t j = 0; j < Size; j++) { ReferenceA[j] = ReferenceB[j]; ReferenceA[j] += ModValue; @@ -115,9 +115,11 @@ int main() { free(PtrB, Queue); free(PtrC, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/Inputs/usm_fill.cpp b/sycl/test-e2e/Graph/Inputs/usm_fill.cpp index 1cc60faf3e91f..269f58cffc242 100644 --- a/sycl/test-e2e/Graph/Inputs/usm_fill.cpp +++ b/sycl/test-e2e/Graph/Inputs/usm_fill.cpp @@ -21,8 +21,8 @@ int main() { std::vector Output(N); Queue.memcpy(Output.data(), Arr, N * sizeof(int)).wait(); - for (int i = 0; i < N; i++) - assert(Output[i] == Pattern); + for (size_t i = 0; i < N; i++) + assert(check_value(i, Output[i], Pattern, "Pattern")); sycl::free(Arr, Queue); diff --git a/sycl/test-e2e/Graph/Inputs/usm_fill_host.cpp b/sycl/test-e2e/Graph/Inputs/usm_fill_host.cpp index d5c97c52e5209..e77f6c7662ee3 100644 --- a/sycl/test-e2e/Graph/Inputs/usm_fill_host.cpp +++ b/sycl/test-e2e/Graph/Inputs/usm_fill_host.cpp @@ -22,8 +22,8 @@ int main() { Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }).wait(); - for (int i = 0; i < N; i++) - assert(Arr[i] == Pattern); + for (size_t i = 0; i < N; i++) + assert(check_value(i, Arr[i], Pattern, "Pattern")); sycl::free(Arr, Queue); diff --git a/sycl/test-e2e/Graph/Inputs/usm_fill_shared.cpp b/sycl/test-e2e/Graph/Inputs/usm_fill_shared.cpp index fa6aaf2290110..cfba42f6dcf63 100644 --- a/sycl/test-e2e/Graph/Inputs/usm_fill_shared.cpp +++ b/sycl/test-e2e/Graph/Inputs/usm_fill_shared.cpp @@ -23,8 +23,8 @@ int main() { Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }).wait(); - for (int i = 0; i < N; i++) - assert(Arr[i] == Pattern); + for (size_t i = 0; i < N; i++) + assert(check_value(i, Arr[i], Pattern, "Pattern")); sycl::free(Arr, Queue); diff --git a/sycl/test-e2e/Graph/RecordReplay/after_use.cpp b/sycl/test-e2e/Graph/RecordReplay/after_use.cpp index 5aa8fdf37426a..9fe5536f62a1e 100644 --- a/sycl/test-e2e/Graph/RecordReplay/after_use.cpp +++ b/sycl/test-e2e/Graph/RecordReplay/after_use.cpp @@ -67,9 +67,11 @@ int main() { free(PtrB, Queue); free(PtrC, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/RecordReplay/barrier_with_work.cpp b/sycl/test-e2e/Graph/RecordReplay/barrier_with_work.cpp index 8a049271ad135..b543383e35e03 100644 --- a/sycl/test-e2e/Graph/RecordReplay/barrier_with_work.cpp +++ b/sycl/test-e2e/Graph/RecordReplay/barrier_with_work.cpp @@ -113,9 +113,11 @@ int main() { free(PtrB, Queue); free(PtrC, Queue); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; } diff --git a/sycl/test-e2e/Graph/RecordReplay/temp_buffer.cpp b/sycl/test-e2e/Graph/RecordReplay/temp_buffer.cpp index c86ea7e5aec99..d5ae8492b92df 100644 --- a/sycl/test-e2e/Graph/RecordReplay/temp_buffer.cpp +++ b/sycl/test-e2e/Graph/RecordReplay/temp_buffer.cpp @@ -79,7 +79,7 @@ int main() { host_accessor HostAccC(BufferC); for (size_t i = 0; i < Size; i++) { - assert(ReferenceC[i] == HostAccC[i]); + assert(check_value(i, ReferenceC[i], HostAccC[i], "HostAccC")); } } diff --git a/sycl/test-e2e/Graph/RecordReplay/temp_scope.cpp b/sycl/test-e2e/Graph/RecordReplay/temp_scope.cpp index d2bc0985a143c..fbfc0329cfb61 100644 --- a/sycl/test-e2e/Graph/RecordReplay/temp_scope.cpp +++ b/sycl/test-e2e/Graph/RecordReplay/temp_scope.cpp @@ -45,7 +45,7 @@ int main() { std::vector Output(N); Queue.memcpy(Output.data(), Arr, N * sizeof(int)).wait(); for (size_t i = 0; i < N; i++) { - assert(Output[i] == ExpectedValue); + assert(check_value(i, Output[i], ExpectedValue, "ExpectedValue")); } sycl::free(Arr, Queue); diff --git a/sycl/test-e2e/Graph/RecordReplay/usm_copy_in_order.cpp b/sycl/test-e2e/Graph/RecordReplay/usm_copy_in_order.cpp index 11132db966132..7306b66375b52 100644 --- a/sycl/test-e2e/Graph/RecordReplay/usm_copy_in_order.cpp +++ b/sycl/test-e2e/Graph/RecordReplay/usm_copy_in_order.cpp @@ -76,8 +76,9 @@ int main() { std::vector Output(N); Queue.memcpy(Output.data(), Z, N * sizeof(int)).wait(); + const int Expected = 2; for (size_t i = 0; i < N; i++) { - assert(Output[i] == 2); + assert(check_value(i, Output[i], Expected, "Expected")); } sycl::free(X, Queue); diff --git a/sycl/test-e2e/Graph/graph_common.hpp b/sycl/test-e2e/Graph/graph_common.hpp index 0e96a7bf49a0e..cd2ca0bf366ae 100644 --- a/sycl/test-e2e/Graph/graph_common.hpp +++ b/sycl/test-e2e/Graph/graph_common.hpp @@ -432,3 +432,16 @@ class Barrier { std::condition_variable cv; std::size_t threadNum; }; + +template +bool inline check_value(const size_t index, const T &Ref, const T &Got, + const std::string &VariableName) { + if (Got != Ref) { + std::cout << "Unexpected value at index " << index << " for " + << VariableName << ": " << Got << " (got) vs " << Ref + << " (expected)" << std::endl; + return false; + } + + return true; +} diff --git a/sycl/test-e2e/Graph/submission_while_executing.cpp b/sycl/test-e2e/Graph/submission_while_executing.cpp index 0035c8b26044a..4f57321f69539 100644 --- a/sycl/test-e2e/Graph/submission_while_executing.cpp +++ b/sycl/test-e2e/Graph/submission_while_executing.cpp @@ -115,9 +115,11 @@ int main() { calculate_reference_data(NumIterations + SuccessfulSubmissions, LargeSize, ReferenceA, ReferenceB, ReferenceC); - assert(ReferenceA == DataA); - assert(ReferenceB == DataB); - assert(ReferenceC == DataC); + for (size_t i = 0; i < Size; i++) { + assert(check_value(i, ReferenceA[i], DataA[i], "DataA")); + assert(check_value(i, ReferenceB[i], DataB[i], "DataB")); + assert(check_value(i, ReferenceC[i], DataC[i], "DataC")); + } return 0; }