intel / intel/llvm

[SYCL] Name mangling of unnamed kernels not sufficiently robust to disambiguate them

Open
#10,659 5 comments 1 reaction 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**

When using similar (but not identical) SYCL kernels in [Catch2](https://github.com/catchorg/Catch2) test cases defined in separate source files, the mangled kernel names can be the same leading to undefined behavior. In my case, it appears as if the same device kernel is being used for each of the kernel invocations in the two test cases.

Although I have only reproduced this problem with Catch2, I presume it would be possible to reproduce without it and demonstrates that the mangled kernel names are not sufficiently unique to disambiguate.

I originally thought that this was a Catch2 problem (their "unique" naming macro does not seem to produce unique names for test cases in separate source files) but I tried reproducing the issue with Open SYCL and found that it is able to handle this code without any problems.

**To Reproduce**

Please find the code to reproduce this issue in [this repo](https://github.com/mirenradia/Catch2-SYCL) I have created. Instructions are provided in the README therein but I will copy them here for completeness:

0. First make sure you have set up your environment correctly (e.g. modules loaded/`setvars.sh` script sourced).
1. Clone the repository:
```bash
git clone https://github.com/mirenradia/Catch2-SYCL.git
```
2. Next create a build directory and change into it:
```bash
mkdir Catch2-SYCL/build && cd Catch2-SYCL/build
```
3. Configure the build. For Intel DPC++, make sure you set `icpx` as the C++
compiler:
```bash
cmake -DCMAKE_CXX_COMPILER=icpx ..
```
4. Finally, build the application using `make`:
```bash
make -j `nproc`
```
5. Run using the command
```
./catch2sycl
```

Expected behavior: Both test cases should pass.

**Environment (please complete the following information):**

- OS: Linux
- Target device and vendor: Intel GPU (Level Zero/OpenCL), Intel CPU (OpenCL), Intel FPGA Emulator (OpenCL), Nvidia GPU (CUDA)
- DPC++ version: 2023.2.1 (`sycl-nightly/20230410` for CUDA backend test)
- Dependencies version: Intel Compute Runtime [23.17.26241.22](https://github.com/intel/compute-runtime/releases/tag/23.17.26241.22) (for Intel devices), CUDA 11.8 (for Nvidia devices)

**Additional context**

Both @Pennycook and @draenog have reproduced this issue with recent DPC++ versions.

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.