From 12decabad975966017faf5f0d5f0bfd91adc4841 Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Wed, 23 Oct 2024 12:29:19 +0100 Subject: [PATCH] Reintroduce unittest for range update errors --- sycl/source/detail/graph_impl.hpp | 4 +-- .../Extensions/CommandGraph/Update.cpp | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/sycl/source/detail/graph_impl.hpp b/sycl/source/detail/graph_impl.hpp index 3b1fc3fa01641..b6cc9b9813741 100644 --- a/sycl/source/detail/graph_impl.hpp +++ b/sycl/source/detail/graph_impl.hpp @@ -420,7 +420,7 @@ class node_impl : public std::enable_shared_from_this { throw sycl::exception(sycl::errc::invalid, "Cannot update execution range of a node with an " "execution range of different dimensions than what " - "the node was originall created with."); + "the node was original created with."); } NDRDesc = sycl::detail::NDRDescT{ExecutionRange}; @@ -441,7 +441,7 @@ class node_impl : public std::enable_shared_from_this { throw sycl::exception(sycl::errc::invalid, "Cannot update execution range of a node with an " "execution range of different dimensions than what " - "the node was originall created with."); + "the node was original created with."); } NDRDesc = sycl::detail::NDRDescT{ExecutionRange}; diff --git a/sycl/unittests/Extensions/CommandGraph/Update.cpp b/sycl/unittests/Extensions/CommandGraph/Update.cpp index 676e3bead1416..b149cc08ccc88 100644 --- a/sycl/unittests/Extensions/CommandGraph/Update.cpp +++ b/sycl/unittests/Extensions/CommandGraph/Update.cpp @@ -134,6 +134,37 @@ TEST_F(CommandGraphTest, UpdateNodeTypeExceptions) { })); } +TEST_F(CommandGraphTest, UpdateRangeErrors) { + // Test that the correct errors are throw when trying to update node ranges + nd_range<1> NDRange{range{128}, range{32}}; + range<1> Range{128}; + auto NodeNDRange = Graph.add([&](sycl::handler &cgh) { + cgh.parallel_for>(NDRange, [](nd_item<1>) {}); + }); + + // OK + EXPECT_NO_THROW(NodeNDRange.update_nd_range(NDRange)); + // OK to update an nd_range node with a range of the same dimension + EXPECT_NO_THROW(NodeNDRange.update_range(Range)); + // Can't update with a different number of dimensions + EXPECT_ANY_THROW(NodeNDRange.update_nd_range( + nd_range<2>{range<2>{128, 128}, range<2>{32, 32}})); + EXPECT_ANY_THROW(NodeNDRange.update_range(range<3>{32, 32, 1})); + + auto NodeRange = Graph.add([&](sycl::handler &cgh) { + cgh.parallel_for>(range<1>{128}, [](item<1>) {}); + }); + + // OK + EXPECT_NO_THROW(NodeRange.update_range(Range)); + // OK to update a range node with an nd_range of the same dimension + EXPECT_NO_THROW(NodeRange.update_nd_range(NDRange)); + // Can't update with a different number of dimensions + EXPECT_ANY_THROW(NodeRange.update_range(range<2>{128, 128})); + EXPECT_ANY_THROW(NodeRange.update_nd_range( + nd_range<3>{range<3>{8, 8, 8}, range<3>{8, 8, 8}})); +} + class WholeGraphUpdateTest : public CommandGraphTest { protected: