Skip to content

Commit 7bf1f57

Browse files
authored
[SYCL] Stop throwing exception when passing empty accessor to handler::require() (#10597)
According to the changes made in https://github.com/KhronosGroup/SYCL-Docs/pull/434/files, empty accessors can now be passed to `handler::require()` without throwing. --------- Signed-off-by: Maronas, Marcos <[email protected]>
1 parent 0fd9a4e commit 7bf1f57

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

sycl/include/sycl/handler.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,9 +1601,6 @@ class __SYCL_EXPORT handler {
16011601
template <typename DataT, int Dims, access::mode AccMode,
16021602
access::target AccTarget, access::placeholder isPlaceholder>
16031603
void require(accessor<DataT, Dims, AccMode, AccTarget, isPlaceholder> Acc) {
1604-
if (Acc.empty())
1605-
throw sycl::exception(make_error_code(errc::invalid),
1606-
"require() cannot be called on empty accessors");
16071604
if (Acc.is_placeholder())
16081605
associateWithHandler(&Acc, AccTarget);
16091606
}

sycl/test-e2e/Basic/accessor/accessor.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -818,20 +818,18 @@ int main() {
818818
}
819819
}
820820

821-
// SYCL2020 4.9.4.1: calling require() on empty accessor should throw
821+
// SYCL2020 4.9.4.1: calling require() on empty accessor should not throw.
822822
{
823823
sycl::queue q;
824824
try {
825825
AccT acc;
826826

827827
q.submit([&](sycl::handler &cgh) { cgh.require(acc); });
828828
q.wait_and_throw();
829-
assert(false && "we should not be here, missing exception");
830829
} catch (sycl::exception &e) {
831-
std::cout << "exception received: " << e.what() << std::endl;
832-
assert(e.code() == sycl::errc::invalid && "error code should be invalid");
830+
assert("Unexpected exception");
833831
} catch (...) {
834-
std::cout << "Some other exception (line " << __LINE__ << ")"
832+
std::cout << "Some other unexpected exception (line " << __LINE__ << ")"
835833
<< std::endl;
836834
return 1;
837835
}

0 commit comments

Comments
 (0)