Skip to content

Commit

Permalink
Reintroduce unittest for range update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanC committed Oct 23, 2024
1 parent c838513 commit 12decab
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sycl/source/detail/graph_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class node_impl : public std::enable_shared_from_this<node_impl> {
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};
Expand All @@ -441,7 +441,7 @@ class node_impl : public std::enable_shared_from_this<node_impl> {
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};
Expand Down
31 changes: 31 additions & 0 deletions sycl/unittests/Extensions/CommandGraph/Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestKernel<>>(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<TestKernel<>>(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:
Expand Down

0 comments on commit 12decab

Please sign in to comment.