Skip to content

Commit cbffacd

Browse files
authored
[SYCL][NATIVECPU] Emit LocalInvocationId free function on Native CPU (#12810)
Similarly to the CUDA and Hip backends, the Native CPU pass pipeline expects the work item builtins to be of the "free function" kind, this PR ensures that for code that goes through `parallel_for_work_group`. This PR fixes the `e2e/Basic/accessor/accessor.cpp` test on Native CPU.
1 parent b664df6 commit cbffacd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

llvm/include/llvm/SYCLLowerIR/UtilsSYCLNativeCPU.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ inline llvm::Twine addSYCLNativeCPUSuffix(StringRef S) {
4747
return llvm::Twine(S, SYCLNATIVECPUSUFFIX);
4848
}
4949

50+
inline bool isSYCLNativeCPU(const Module &M) {
51+
return M.getModuleFlag("is-native-cpu") != nullptr;
52+
}
53+
5054
} // namespace utils
5155
} // namespace sycl
5256
} // namespace llvm

llvm/lib/SYCLLowerIR/LowerWGScope.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
#include "llvm/IR/Module.h"
9898
#include "llvm/InitializePasses.h"
9999
#include "llvm/Pass.h"
100+
#include "llvm/SYCLLowerIR/UtilsSYCLNativeCPU.h"
100101
#include "llvm/Support/CommandLine.h"
101102

102103
#ifndef NDEBUG
@@ -898,7 +899,7 @@ GlobalVariable *spirv::createWGLocalVariable(Module &M, Type *T,
898899
// Return a value equals to 0 if and only if the local linear id is 0.
899900
Value *spirv::genPseudoLocalID(Instruction &Before, const Triple &TT) {
900901
Module &M = *Before.getModule();
901-
if (TT.isNVPTX() || TT.isAMDGCN()) {
902+
if (TT.isNVPTX() || TT.isAMDGCN() || sycl::utils::isSYCLNativeCPU(M)) {
902903
LLVMContext &Ctx = Before.getContext();
903904
Type *RetTy = getSizeTTy(M);
904905

0 commit comments

Comments
 (0)