intel / intel/llvm

Warn about unused but bound placeholder accessors

Open
#8,234 0 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
LLVM
Stars
1.5k
Forks
854
Avg merge
3d 17h
Merged PRs (30d)
137

Description

**Is your feature request related to a problem? Please describe**

When using placeholder accessors, they must be bound before use.

This trips up most of the "unused variable" diagnostics since the accessor is used as an argument to `handler::require`, even if it is not used in the kernel later.

This makes it harder to diagnose erroneous dependencies between operations.

Example code, no warnings when compiled with `clang++ -Wall -Wextra -fsycl`:

```cpp
#include

using sycl::access::mode;

template
using PlaceholderAccessor =
sycl::accessor;

auto myKernel(sycl::handler &cgh, PlaceholderAccessor data_1,
PlaceholderAccessor data_2) {
cgh.require(data_1);
cgh.require(data_2);
return [=](sycl::item<1> itemIdx) {
const int v = itemIdx.get_linear_id();
data_1[v] = v;
};
}

class KernelName;

int main() {
sycl::device dev{};
sycl::queue q{dev};
sycl::buffer buffer_1(1);
sycl::buffer buffer_2(1);
sycl::event e = q.submit([&](sycl::handler &cgh) {
auto kernel = myKernel(cgh, buffer_1, buffer_2);
cgh.parallel_for(1, kernel);
});
e.wait_and_throw();
return 0;
}
```

**Describe the solution you would like**

A compile-time warning about an unused accessor.

**Describe alternatives you have considered**

- Analyzing the code manually instead of hoping for the compiler to do it.

**Additional context**

It is a follow-up from #3078.

Not a priority for GROMACS (we ditched accessors in favor of USM a while ago), but theoretically, a helpful diagnostic.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.