Skip to content

Commit 735410d

Browse files
authored
[SYCL][NATIVECPU] remove Comdat from kernel whose name was taken/renamed (#18726)
Taking the kernel name and renaming the original function afterwards caused recently a number of check-sycl tests to fail on Windows: ``` SYCL :: check_device_code/native_cpu/native_cpu_builtins.cpp SYCL :: check_device_code/native_cpu/vectorization.cpp SYCL :: native_cpu/link-noinline.cpp SYCL :: native_cpu/no-opt.cpp SYCL :: native_cpu/vector-add.cpp ``` This is a quick fix for these fails by removing the Comdat from such kernels. Maintaining the Comdat info properly for such kernels will be addressed in a subsequent PR. A new test was added to ensure launches from functions with multiple definitions work.
1 parent f5e3bd7 commit 735410d

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

llvm/lib/SYCLNativeCPUUtils/PrepareSYCLNativeCPU.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ PreservedAnalyses PrepareSYCLNativeCPUPass::run(Module &M,
357357
if (OrigF->use_empty()) {
358358
RemovableFuncs.insert(OrigF);
359359
} else {
360+
OrigF->setComdat(nullptr);
360361
OrigF->setName(Name + ".orig");
361362
}
362363
} else {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// check kernel launches from function with multiple definitions work/link
2+
// REQUIRES: native_cpu
3+
// RUN: %clangxx -fsycl -fsycl-targets=native_cpu -DSOURCE1 %s -fno-inline -c -o %t1.o
4+
// RUN: %clangxx -fsycl -fsycl-targets=native_cpu -DSOURCE2 %s -fno-inline -c -o %t2.o
5+
// RUN: %clangxx -fsycl -fsycl-targets=native_cpu %t1.o %t2.o -fno-inline -mllvm -sycl-native-cpu-vecz-width=4 -o %t
6+
// RUN: env ONEAPI_DEVICE_SELECTOR="native_cpu:cpu" %t
7+
// RUN: %clangxx -fsycl -fsycl-targets=native_cpu %t1.o %t2.o -mllvm -sycl-native-cpu-vecz-width=4 -o %t2
8+
// RUN: env ONEAPI_DEVICE_SELECTOR="native_cpu:cpu" %t2
9+
10+
#include <sycl/sycl.hpp>
11+
12+
constexpr unsigned N = 5;
13+
using _Array = int[N];
14+
15+
using namespace ::sycl;
16+
17+
inline int func() {
18+
queue deviceQueue;
19+
sycl::range<1> range{N};
20+
const device dev = deviceQueue.get_device();
21+
const context ctx = deviceQueue.get_context();
22+
auto OUT_acc = (_Array *)malloc_shared(sizeof(_Array), dev, ctx);
23+
for (int i = 0; i < N; i++)
24+
(*OUT_acc)[i] = 2;
25+
26+
deviceQueue.submit([&](handler &cgh) {
27+
cgh.parallel_for<class Test>(
28+
range, [=](sycl::id<1> ID) { (*OUT_acc)[ID.get(0)] = 1; });
29+
});
30+
31+
deviceQueue.wait();
32+
33+
for (int i = 0; i < N; i++) {
34+
if ((*OUT_acc)[i] != 1)
35+
return 1;
36+
}
37+
38+
sycl::free(OUT_acc, deviceQueue);
39+
return 0;
40+
}
41+
42+
#ifdef SOURCE1
43+
int (*fref)() = &func;
44+
#endif
45+
#ifdef SOURCE2
46+
int (*fref2)() = &func;
47+
extern int (*fref)();
48+
int main(void) { return fref() + fref2(); }
49+
#endif // SOURCE2

0 commit comments

Comments
 (0)