Skip to content

[SYCL] Stop throwing exception when passing empty accessor to handler::require() #10597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1601,9 +1601,6 @@ class __SYCL_EXPORT handler {
template <typename DataT, int Dims, access::mode AccMode,
access::target AccTarget, access::placeholder isPlaceholder>
void require(accessor<DataT, Dims, AccMode, AccTarget, isPlaceholder> Acc) {
if (Acc.empty())
throw sycl::exception(make_error_code(errc::invalid),
"require() cannot be called on empty accessors");
if (Acc.is_placeholder())
associateWithHandler(&Acc, AccTarget);
}
Expand Down
8 changes: 3 additions & 5 deletions sycl/test-e2e/Basic/accessor/accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,20 +818,18 @@ int main() {
}
}

// SYCL2020 4.9.4.1: calling require() on empty accessor should throw
// SYCL2020 4.9.4.1: calling require() on empty accessor should not throw.
Copy link
Contributor

@cperkinsintel cperkinsintel Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. This is exactly wrong. The spec at 4.9.4.1 table 131 first entry says:

Throws exception with the
errc::invalid error code if
(acc.empty() == true).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/KhronosGroup/SYCL-Docs/pull/434/files in this PR, it was updated to say it's allowed.

{
sycl::queue q;
try {
AccT acc;

q.submit([&](sycl::handler &cgh) { cgh.require(acc); });
q.wait_and_throw();
assert(false && "we should not be here, missing exception");
} catch (sycl::exception &e) {
std::cout << "exception received: " << e.what() << std::endl;
assert(e.code() == sycl::errc::invalid && "error code should be invalid");
assert("Unexpected exception");
} catch (...) {
std::cout << "Some other exception (line " << __LINE__ << ")"
std::cout << "Some other unexpected exception (line " << __LINE__ << ")"
<< std::endl;
return 1;
}
Expand Down