Skip to content

Commit a8f3c46

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 4ff4085 + 1292532 commit a8f3c46

File tree

25 files changed

+764
-448
lines changed

25 files changed

+764
-448
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ sycl/doc/extensions/ @intel/dpcpp-specification-reviewers
3535
sycl/plugins/level_zero/ @intel/dpcpp-l0-pi-reviewers
3636

3737
# ESIMD CPU emulator plug-in
38-
sycl/plugins/esimd_cpu/ @intel/dpcpp-esimd-reviewers
38+
sycl/plugins/esimd_emulator/ @intel/dpcpp-esimd-reviewers
3939

4040
# CUDA plugin
4141
sycl/plugins/cuda/ @intel/llvm-reviewers-cuda

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "llvm/Transforms/Coroutines/CoroSplit.h"
6363
#include "llvm/Transforms/IPO.h"
6464
#include "llvm/Transforms/IPO/AlwaysInliner.h"
65+
#include "llvm/Transforms/IPO/DeadArgumentElimination.h"
6566
#include "llvm/Transforms/IPO/LowerTypeTests.h"
6667
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
6768
#include "llvm/Transforms/InstCombine/InstCombine.h"
@@ -926,6 +927,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
926927
}
927928
if (LangOpts.SYCLIsDevice) {
928929
MPM.addPass(SYCLMutatePrintfAddrspacePass());
930+
if (!CodeGenOpts.DisableLLVMPasses && LangOpts.EnableDAEInSpirKernels)
931+
MPM.addPass(DeadArgumentEliminationSYCLPass());
929932
}
930933

931934
// Add SPIRITTAnnotations pass to the pass manager if

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3719,6 +3719,12 @@ static void CheckSYCL2020SubGroupSizes(Sema &S, FunctionDecl *SYCLKernel,
37193719
CalcEffectiveSubGroup(S.Context, S.getLangOpts(), FD))
37203720
return;
37213721

3722+
// No need to validate __spirv routines here since they
3723+
// are mapped to the equivalent SPIRV operations.
3724+
const IdentifierInfo *II = FD->getIdentifier();
3725+
if (II && II->getName().startswith("__spirv_"))
3726+
return;
3727+
37223728
// Else we need to figure out why they don't match.
37233729
SourceLocation FDAttrLoc = GetSubGroupLoc(FD);
37243730
SourceLocation KernelAttrLoc = GetSubGroupLoc(SYCLKernel);

clang/test/CodeGenSYCL/Inputs/sycl.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
extern "C" int printf(const char* fmt, ...);
66

7+
#ifdef __SYCL_DEVICE_ONLY__
8+
__attribute__((convergent)) extern SYCL_EXTERNAL void
9+
__spirv_ControlBarrier(int, int, int) noexcept;
10+
#endif
11+
712
// Dummy runtime classes to model SYCL API.
813
inline namespace cl {
914
namespace sycl {
@@ -399,10 +404,19 @@ kernel_parallel_for(const KernelType &KernelFunc) {
399404
KernelFunc(id<Dims>());
400405
}
401406

407+
// Dummy parallel_for_work_item function to mimic calls from
408+
// parallel_for_work_group.
409+
void parallel_for_work_item() {
410+
#ifdef __SYCL_DEVICE_ONLY__
411+
__spirv_ControlBarrier(0, 0, 0);
412+
#endif
413+
}
414+
402415
template <typename KernelName, typename KernelType, int Dims>
403416
ATTR_SYCL_KERNEL void
404417
kernel_parallel_for_work_group(const KernelType &KernelFunc) {
405418
KernelFunc(group<Dims>());
419+
parallel_for_work_item();
406420
}
407421

408422
class handler {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O1 -fno-legacy-pass-manager -fdebug-pass-manager -fenable-sycl-dae -o /dev/null -x c++ < %s 2>&1 | FileCheck %s
2+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O0 -fno-legacy-pass-manager -fdebug-pass-manager -o /dev/null -x c++ < %s 2>&1 | FileCheck %s --check-prefix DISABLE
3+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O1 -fno-legacy-pass-manager -fdebug-pass-manager -fenable-sycl-dae -disable-llvm-passes -o /dev/null -x c++ < %s 2>&1 | FileCheck %s --check-prefix DISABLE
4+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O1 -flegacy-pass-manager -mllvm -debug-pass=Structure -fenable-sycl-dae -o /dev/null -x c++ < %s 2>&1 | FileCheck %s --check-prefix OLDPM
5+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O1 -flegacy-pass-manager -mllvm -debug-pass=Structure -o /dev/null -x c++ < %s 2>&1 | FileCheck %s --check-prefix DISABLE
6+
// RUN: %clang -cc1 -triple spir64-unknown-unknown -fsycl-is-device -emit-llvm-bc -O1 -flegacy-pass-manager -mllvm -debug-pass=Structure -fenable-sycl-dae -disable-llvm-passes -o /dev/null -x c++ < %s 2>&1 | FileCheck %s --check-prefix DISABLE
7+
8+
// Verify that Dead Arguments Elimination for SYCL kernels is/is not added to the PM.
9+
10+
// CHECK: Running pass: DeadArgumentEliminationSYCLPass on [module]
11+
// OLDPM: Dead Argument Elimination for SYCL kernels
12+
// DISABLE-NOT: DeadArgumentEliminationSYCLPass
13+
// DISABLE-NOT: Dead Argument Elimination for SYCL kernels
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -internal-isystem %S/Inputs -fdeclare-spirv-builtins %s -emit-llvm -o - | FileCheck %s
2+
3+
// Test that when __spirv intrinsics are invoked from kernel functions
4+
// that have a sub_group_size specified, that such invocations don't
5+
// trigger the error diagnostic that the intrinsic routines must also
6+
// marked with the same attribute.
7+
8+
#include "Inputs/sycl.hpp"
9+
10+
int main() {
11+
sycl::queue q;
12+
13+
q.submit([&](sycl::handler &cgh) {
14+
auto kernel_ = [=](sycl::group<1> item) [[intel::sub_group_size(8)]] {
15+
};
16+
17+
cgh.parallel_for_work_group<class kernel_class>(
18+
cl::sycl::range<1>(), cl::sycl::range<1>(), kernel_);
19+
});
20+
return 0;
21+
}
22+
23+
// CHECK: define dso_local spir_kernel void @{{.*}}main{{.*}}kernel_class() {{.*}} !intel_reqd_sub_group_size ![[SUBGROUPSIZE:[0-9]+]]
24+
// CHECK: tail call spir_func void @{{.*}}__spirv_ControlBarrier{{.*}}({{.*}})
25+
26+
// CHECK: declare spir_func void @{{.*}}__spirv_ControlBarrier{{.*}}({{.*}})
27+
28+
// CHECK: ![[SUBGROUPSIZE]] = !{i32 8}

devops/containers/ubuntu2004_build.Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ ENV DEBIAN_FRONTEND=noninteractive
44

55
USER root
66

7+
# Install Nvidia keys
8+
# https://forums.developer.nvidia.com/t/notice-cuda-linux-repository-key-rotation/212772
9+
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
10+
711
# Install SYCL prerequisites
812
COPY scripts/install_build_tools.sh /install.sh
913
RUN /install.sh

llvm/tools/sycl-post-link/sycl-post-link.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,17 @@ static bool removeSYCLKernelsConstRefArray(GlobalVariable *GV) {
519519
"Cannot remove initializer of llvm.used global");
520520
Initializer->destroyConstant();
521521
for (auto It = IOperands.begin(); It != IOperands.end(); It++) {
522-
assert(llvm::isSafeToDestroyConstant(*It) &&
523-
"Cannot remove an element of initializer of llvm.used global");
524522
auto Op = (*It)->getOperand(0);
525-
(*It)->destroyConstant();
526-
// Remove unused kernel declarations to avoid LLVM IR check fails.
527523
auto *F = dyn_cast<Function>(Op);
524+
if (llvm::isSafeToDestroyConstant(*It)) {
525+
(*It)->destroyConstant();
526+
} else if (F) {
527+
// The element in "llvm.used" array has other users. That is Ok for
528+
// specialization constants, but is wrong for kernels.
529+
llvm::report_fatal_error("Unexpected usage of SYCL kernel");
530+
}
531+
532+
// Remove unused kernel declarations to avoid LLVM IR check fails.
528533
if (F && F->isDeclaration())
529534
F->eraseFromParent();
530535
}

sycl/cmake/modules/PreprocessBoostMp11Headers.cmake

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,11 @@ function(preprocess_mp11_headers)
8686

8787
# 2) Add SYCL_README.txt to the output directory root
8888
set(SYCL_README_TEXT "\
89-
This directory contains boost/mp11 headers imported from\n\
90-
${MP11_HDRS_SRC_PATH} (${MP11_HDRS_SRC_ID})\n\
91-
and adapted for use in SYCL headers in a way that does not conflict with\n\
92-
potential use of boost in user code. Particularly, `BOOST_*` macros are\n\
93-
replaced with `SYCL_DETAIL_BOOST_*`, APIs are moved into the top-level
94-
`sycl::detail` namespace. For example, `sycl::detail::boost::mp11::mp_list`.\n")
89+
This directory contains boost/mp11 headers adapted for use in SYCL headers in\n\
90+
a way that does not conflict with potential use of boost in user code.\n\
91+
Particularly, `BOOST_*` macros are replaced with `SYCL_DETAIL_BOOST_*`, APIs\n\
92+
are moved into the top-level `sycl::detail` namespace. For example,\n\
93+
`sycl::detail::boost::mp11::mp_list`.\n")
9594

9695
set(SYCL_README_FILE_NAME "${MP11_HDRS_OUT}/README.txt")
9796

sycl/doc/UsersManual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ and not recommended to use in production environment.
7070
Enables (or disables) LLVM IR dead argument elimination pass to remove
7171
unused arguments for the kernel functions before translation to SPIR-V.
7272
Currently has effect only on spir64\* targets.
73-
Disabled by default.
73+
Enabled by default.
7474

7575
**`-f[no-]sycl-id-queries-fit-in-int`**
7676

0 commit comments

Comments
 (0)