Skip to content

[SYCL] Fix launching a kernel with a default constructed local accessor #13382

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 3 commits into from
Apr 17, 2024
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
2 changes: 1 addition & 1 deletion sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ void handler::processArg(void *Ptr, const detail::kernel_param_kind_t &Kind,
// to a single kernel argument set above.
if (!IsESIMD && !IsKernelCreatedFromSource) {
++IndexShift;
const size_t SizeAccField = Dims * sizeof(Size[0]);
const size_t SizeAccField = (Dims == 0 ? 1 : Dims) * sizeof(Size[0]);
MArgs.emplace_back(kernel_param_kind_t::kind_std_layout, &Size,
SizeAccField, Index + IndexShift);
++IndexShift;
Expand Down
20 changes: 20 additions & 0 deletions sycl/test-e2e/Regression/default-constructed-local-accessor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// -O0 is necessary; on higher levels of optimization, an error
// would not occur because of dead argument elimination of the local_accessor.
// RUN: %{build} -o %t.out -O0
// RUN: %{run} %t.out
Copy link
Contributor Author

Choose a reason for hiding this comment

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

-O0 is necessary; on higher levels of optimization, an error does not occur because of dead argument elimination of the local_accessor.

Copy link
Contributor

Choose a reason for hiding this comment

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

This comment should be moved to the test itself


#include <sycl/detail/core.hpp>

using namespace sycl;

using acc_t = local_accessor<int, 1>;

struct foo {
acc_t acc;
void operator()(nd_item<1>) const {}
};

int main() {
queue q;
q.submit([&](handler &cgh) { cgh.parallel_for(nd_range<1>(1, 1), foo{}); });
}