intel / intel/llvm

Application aborted when passing nullptr as a kernel argument on OpenCL backend

Open
#4,969 7 comments 0 reactions 0 assignees View on GitHub
bug confirmed
Dominant language
LLVM
Stars
1.5k
Forks
854
Avg merge
3d 17h
Merged PRs (30d)
137

Description

**Describe the bug**

Templated code that sometimes passes a local accessor to the kernel and sometimes passes a `nullptr` fails with a runtime error during kernel setup when running on Intel GPU via OpenCL. Using LevelZero or enabling dead argument optimization during compilation resolves the problem. So does simply using the accessor, without extracting the pointer from it.

**To Reproduce**

1. Code snippet: https://gist.github.com/al42and/b2eb3bd19c30fdda11f7551294684c13. Could not make it much shorter. The example is artificial, but such a pattern appears in a larger codebase.
2. Compile: `clang++ -fsycl local_accessors.cpp -o local_accessors`
3. Rub: `SYCL_DEVICE_FILTER=opencl:gpu ./local_accessors`
4. Output:

```
Device name: Intel(R) Iris(R) Xe Graphics [0x9a49]
Running kernel with SLM:
Done
Running kernel without SLM:
Abort was called at 211 line in file:
../../neo/shared/source/kernel/kernel_arg_descriptor.h
Aborted (core dumped)
```

Adding `-fsycl-dead-args-optimization` to the compiler arguments or switching to LevelZero backend with `SYCL_DEVICE_FILTER=level_zero:gpu` makes both tests pass.

**Environment:**

Tested on two systems:

Laptop:

- OS: Ubuntu 20.10
- Target device and vendor: Intel(R) Iris(R) Xe Graphics [0x9a49]
- DPC++ version: Intel(R) oneAPI DPC++/C++ Compiler 2021.4.0 (2021.4.0.20210924)
- Dependencies version: compute-runtime 21.45.21574

Dev server:

- OS: Ubuntu 20.04
- Target device and vendor: Intel(R) Iris(R) Xe MAX Graphics [0x4905]
- DPC++ version: clang version 14.0.0 (https://github.com/intel/llvm.git 3205368f67e0c60db08ac51cb26a9e978879d992)
- Dependencies version: compute-runtime 21.31.20514

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.