Skip to content

Commit 23223a1

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents d49e957 + e8ac5a0 commit 23223a1

File tree

103 files changed

+2225
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2225
-474
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ sycl/ @intel/llvm-reviewers-runtime
2525
sycl/ReleaseNotes.md @pvchupin @tfzhu
2626
sycl/doc/ @pvchupin @bader
2727
sycl/doc/extensions/ @intel/dpcpp-specification-reviewers
28+
sycl/doc/SPIRV @AlexeySotkin @bashbaug @mbelicki
2829

2930
# Sub-groups
3031
sycl/include/CL/sycl/detail/spirv.hpp @Pennycook @AlexeySachkov
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI Containers
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
# Every 1st and 15th day of month
6+
- cron: '0 0 1,15 * *'
7+
8+
jobs:
9+
base_image_ubuntu2004:
10+
if: github.repository == 'intel/llvm'
11+
name: Base Ubuntu 20.04 Docker image
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 1
18+
- name: Login to GitHub Container Registry
19+
uses: docker/login-action@v1
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.repository_owner }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
- name: Build and Push Container
25+
uses: docker/build-push-action@v2
26+
with:
27+
push: true
28+
tags: |
29+
ghcr.io/${{ github.repository }}/ubuntu2004_base:${{ github.sha }}
30+
ghcr.io/${{ github.repository }}/ubuntu2004_base:latest
31+
context: ${{ github.workspace }}/devops
32+
file: ${{ github.workspace }}/devops/containers/ubuntu2004_base.Dockerfile

buildbot/configure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def do_configure(args):
2929
libclc_targets_to_build = ''
3030
libclc_gen_remangled_variants = 'OFF'
3131
sycl_build_pi_cuda = 'OFF'
32-
sycl_build_pi_esimd_cpu = 'OFF'
32+
sycl_build_pi_esimd_emulator = 'OFF'
3333
sycl_build_pi_hip = 'OFF'
3434
sycl_build_pi_hip_platform = 'AMD'
3535
sycl_clang_extra_flags = ''
@@ -53,7 +53,7 @@ def do_configure(args):
5353
llvm_targets_to_build = 'ARM;AArch64'
5454

5555
if args.enable_esimd_cpu_emulation:
56-
sycl_build_pi_esimd_cpu = 'ON'
56+
sycl_build_pi_esimd_emulator = 'ON'
5757

5858
if args.cuda or args.hip:
5959
llvm_enable_projects += ';libclc'
@@ -128,7 +128,7 @@ def do_configure(args):
128128
"-DBUILD_SHARED_LIBS={}".format(llvm_build_shared_libs),
129129
"-DSYCL_ENABLE_XPTI_TRACING={}".format(sycl_enable_xpti_tracing),
130130
"-DLLVM_ENABLE_LLD={}".format(llvm_enable_lld),
131-
"-DSYCL_BUILD_PI_ESIMD_CPU={}".format(sycl_build_pi_esimd_cpu),
131+
"-DSYCL_BUILD_PI_ESIMD_EMULATOR={}".format(sycl_build_pi_esimd_emulator),
132132
"-DXPTI_ENABLE_WERROR={}".format(xpti_enable_werror),
133133
"-DSYCL_CLANG_EXTRA_FLAGS={}".format(sycl_clang_extra_flags)
134134
]

clang/lib/CodeGen/TargetInfo.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10184,9 +10184,40 @@ class SPIRABIInfo : public DefaultABIInfo {
1018410184
public:
1018510185
SPIRABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) { setCCs(); }
1018610186

10187+
ABIArgInfo classifyKernelArgumentType(QualType Ty) const;
10188+
10189+
void computeInfo(CGFunctionInfo &FI) const override;
10190+
1018710191
private:
1018810192
void setCCs();
1018910193
};
10194+
10195+
ABIArgInfo SPIRABIInfo::classifyKernelArgumentType(QualType Ty) const {
10196+
Ty = useFirstFieldIfTransparentUnion(Ty);
10197+
10198+
if (getContext().getLangOpts().SYCLIsDevice && isAggregateTypeForABI(Ty)) {
10199+
// Pass all aggregate types allowed by Sema by value.
10200+
return getNaturalAlignIndirect(Ty);
10201+
}
10202+
10203+
return DefaultABIInfo::classifyArgumentType(Ty);
10204+
}
10205+
10206+
void SPIRABIInfo::computeInfo(CGFunctionInfo &FI) const {
10207+
llvm::CallingConv::ID CC = FI.getCallingConvention();
10208+
10209+
if (!getCXXABI().classifyReturnType(FI))
10210+
FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
10211+
10212+
for (auto &Arg : FI.arguments()) {
10213+
if (CC == llvm::CallingConv::SPIR_KERNEL) {
10214+
Arg.info = classifyKernelArgumentType(Arg.type);
10215+
} else {
10216+
Arg.info = classifyArgumentType(Arg.type);
10217+
}
10218+
}
10219+
}
10220+
1019010221
} // end anonymous namespace
1019110222
namespace {
1019210223
class SPIRTargetCodeGenInfo : public TargetCodeGenInfo {
@@ -10212,7 +10243,7 @@ void SPIRABIInfo::setCCs() {
1021210243
namespace clang {
1021310244
namespace CodeGen {
1021410245
void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI) {
10215-
DefaultABIInfo SPIRABI(CGM.getTypes());
10246+
SPIRABIInfo SPIRABI(CGM.getTypes());
1021610247
SPIRABI.computeInfo(FI);
1021710248
}
1021810249
}

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,15 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
17031703

17041704
bool handleStructType(FieldDecl *FD, QualType FieldTy) final {
17051705
IsInvalid |= checkNotCopyableToKernel(FD, FieldTy);
1706+
CXXRecordDecl *RD = FieldTy->getAsCXXRecordDecl();
1707+
assert(RD && "Not a RecordDecl inside the handler for struct type");
1708+
if (RD->isLambda()) {
1709+
for (const LambdaCapture &LC : RD->captures())
1710+
if (LC.capturesThis() && LC.isImplicit()) {
1711+
SemaRef.Diag(LC.getLocation(), diag::err_implicit_this_capture);
1712+
IsInvalid = true;
1713+
}
1714+
}
17061715
return isValid();
17071716
}
17081717

@@ -3758,7 +3767,6 @@ void Sema::CheckSYCLKernelCall(FunctionDecl *KernelFunc, SourceRange CallLoc,
37583767
for (const LambdaCapture &LC : KernelObj->captures())
37593768
if (LC.capturesThis() && LC.isImplicit()) {
37603769
Diag(LC.getLocation(), diag::err_implicit_this_capture);
3761-
Diag(CallLoc.getBegin(), diag::note_used_here);
37623770
KernelFunc->setInvalidDecl();
37633771
}
37643772
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -internal-isystem %S/Inputs -disable-llvm-passes -sycl-std=2020 -emit-llvm %s -o - | FileCheck %s
2+
3+
// Tests that SYCL kernel arguments with non-trivially copyable types are
4+
// passed by-valued.
5+
6+
#include "Inputs/sycl.hpp"
7+
using namespace cl::sycl;
8+
9+
struct NontriviallyCopyable {
10+
int I;
11+
NontriviallyCopyable(int I) : I(I) {}
12+
NontriviallyCopyable(const NontriviallyCopyable &X) : I(X.I) {}
13+
};
14+
15+
void device_func(NontriviallyCopyable X) {
16+
(void)X;
17+
}
18+
19+
int main() {
20+
NontriviallyCopyable NontriviallyCopyableObject{10};
21+
22+
queue Q;
23+
Q.submit([&](handler &CGH) {
24+
CGH.single_task<class kernel_name>([=]() {
25+
device_func(NontriviallyCopyableObject);
26+
});
27+
});
28+
}
29+
30+
// CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name(%struct.NontriviallyCopyable* byval(%struct.NontriviallyCopyable)
31+
// CHECK-NOT: define {{.*}}spir_func void @{{.*}}device_func{{.*}}({{.*}}byval(%struct.NontriviallyCopyable)

clang/test/SemaSYCL/lambda_implicit_capture_this.cpp

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,95 @@
11
// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -Wno-sycl-2017-compat -verify %s
2+
//
3+
// This test checks that the compiler issues an error on attempt to capture
4+
// "this" pointer by lambdas passed to the device code (directly and indirectly)
25

3-
template <typename name, typename Func>
4-
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
5-
kernelFunc();
6-
}
6+
#include "Inputs/sycl.hpp"
7+
using namespace cl::sycl;
8+
queue q;
79

810
class Class {
911
public:
1012
Class() : member(1) {}
1113
void function();
14+
void function2();
15+
void function3();
1216
int member;
1317
};
1418

19+
void Class::function3() {
20+
auto Lambda = [=]() {
21+
int acc[1] = {5};
22+
acc[0] *= member;
23+
};
24+
}
25+
26+
void Class::function2() {
27+
auto Lambda = [=]() {
28+
int acc[1] = {5};
29+
acc[0] *= member;
30+
};
31+
function3();
32+
}
33+
1534
void Class::function() {
16-
// expected-note@+1{{used here}}
17-
kernel<class kernel_wrapper>(
18-
[=]() {
35+
auto Lambda = [=]() {
36+
int acc[1] = {5};
37+
acc[0] *= member; // expected-error 2{{implicit capture of 'this' is not allowed for kernel functions}}
38+
};
39+
q.submit([&](handler &h) {
40+
// expected-note@+1 {{in instantiation of function template specialization}}
41+
h.single_task<class Simple>([=]() {
42+
int acc[1] = {5};
43+
acc[0] *= member; // expected-error{{implicit capture of 'this' is not allowed for kernel functions}}
44+
});
45+
});
46+
q.submit([&](handler &h) {
47+
// expected-note@+1 {{in instantiation of function template specialization}}
48+
h.single_task<class CapturedOnDevice>([=]() {
49+
auto DeviceLambda = [=]() {
1950
int acc[1] = {5};
2051
acc[0] *= member; // expected-error{{implicit capture of 'this' is not allowed for kernel functions}}
21-
});
52+
};
53+
DeviceLambda();
54+
});
55+
});
56+
q.submit([&](handler &h) {
57+
// expected-note@+1 {{in instantiation of function template specialization}}
58+
h.single_task<class CapturedOnDevice1>([=]() {
59+
// FIXME: That is probably not correct source location for a diagnostic
60+
function2(); // expected-error{{implicit capture of 'this' is not allowed for kernel functions}}
61+
});
62+
});
63+
q.submit([&](handler &h) {
64+
// expected-note@+1 {{in instantiation of function template specialization}}
65+
h.single_task<class CapturedOnDevice2>([=]() {
66+
// FIXME: That is probably not correct source location for a diagnostic
67+
function3(); // expected-error{{implicit capture of 'this' is not allowed for kernel functions}}
68+
});
69+
});
70+
q.submit([&](handler &h) {
71+
// expected-note@+1 {{in instantiation of function template specialization}}
72+
h.single_task<class CapturedOnHost>([=]() {
73+
Lambda();
74+
});
75+
});
76+
q.submit([&](handler &h) {
77+
// expected-note@+1 {{in instantiation of function template specialization}}
78+
h.single_task<class CapturedOnHost1>([Lambda]() {
79+
});
80+
});
81+
auto InnerLambda = [=]() {
82+
int A = 2 + member; // expected-error {{implicit capture of 'this' is not allowed for kernel functions}}
83+
};
84+
auto ExternalLambda = [=]() {
85+
InnerLambda();
86+
};
87+
q.submit([&](handler &h) {
88+
// expected-note@+1 {{in instantiation of function template specialization}}
89+
h.single_task<class CapturedOnHost2>([=]() {
90+
ExternalLambda();
91+
});
92+
});
2293
}
2394

2495
int main(int argc, char *argv[]) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM ubuntu:20.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt update && apt install -yqq \
6+
build-essential \
7+
cmake \
8+
ninja-build \
9+
ccache \
10+
git \
11+
python3

llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,9 +1014,10 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgExpression(const DIExpression *Expr) {
10141014
SPIRVDebug::ExpressionOpCode OC =
10151015
SPIRV::DbgExpressionOpCodeMap::map(DWARFOpCode);
10161016
if (OpCountMap.find(OC) == OpCountMap.end())
1017-
report_fatal_error("unknown opcode found in DIExpression");
1017+
report_fatal_error(llvm::Twine("unknown opcode found in DIExpression"));
10181018
if (OC > SPIRVDebug::Fragment && !BM->allowExtraDIExpressions())
1019-
report_fatal_error("unsupported opcode found in DIExpression");
1019+
report_fatal_error(
1020+
llvm::Twine("unsupported opcode found in DIExpression"));
10201021

10211022
unsigned OpCount = OpCountMap[OC];
10221023
SPIRVWordVec Op(OpCount);

llvm-spirv/lib/SPIRV/Mangler/Mangler.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ class MangleVisitor : public TypeVisitor {
5757
if ((Fpos = Stream.str().find(TypeStr)) != std::string::npos) {
5858
const char *NType;
5959
if (const PointerType *P = SPIR::dynCast<PointerType>(Type)) {
60-
if ((NType =
61-
mangledPrimitiveStringfromName(P->getPointee()->toString())))
62-
ThistypeStr << NType;
60+
ThistypeStr << getPointeeMangling(P->getPointee());
6361
}
6462
#if defined(ENABLE_MANGLER_VECTOR_SUBSTITUTION)
6563
else if (const VectorType *PVec = SPIR::dynCast<VectorType>(Type)) {
@@ -110,21 +108,14 @@ class MangleVisitor : public TypeVisitor {
110108

111109
MangleError visit(const PointerType *P) override {
112110
size_t Fpos = Stream.str().size();
113-
std::string QualStr;
114111
MangleError Me = MANGLE_SUCCESS;
115-
QualStr += getMangledAttribute((P->getAddressSpace()));
116-
for (unsigned int I = ATTR_QUALIFIER_FIRST; I <= ATTR_QUALIFIER_LAST; I++) {
117-
TypeAttributeEnum Qualifier = (TypeAttributeEnum)I;
118-
if (P->hasQualifier(Qualifier)) {
119-
QualStr += getMangledAttribute(Qualifier);
120-
}
121-
}
122-
if (!mangleSubstitution(P, "P" + QualStr)) {
112+
std::string AttrMangling = getPointerAttributesMangling(P);
113+
if (!mangleSubstitution(P, "P" + AttrMangling)) {
123114
// A pointee type is substituted when it is a user type, a vector type
124115
// (but see a comment in the beginning of this file), a pointer type,
125116
// or a primitive type with qualifiers (addr. space and/or CV qualifiers).
126117
// So, stream "P", type qualifiers
127-
Stream << "P" << QualStr;
118+
Stream << "P" << AttrMangling;
128119
// and the pointee type itself.
129120
Me = P->getPointee()->accept(this);
130121
// The type qualifiers plus a pointee type is a substitutable entity
@@ -180,8 +171,12 @@ class MangleVisitor : public TypeVisitor {
180171
}
181172

182173
MangleError visit(const UserDefinedType *PTy) override {
174+
size_t Index = Stream.str().size();
183175
std::string Name = PTy->toString();
184-
Stream << Name.size() << Name;
176+
if (!mangleSubstitution(PTy, Name)) {
177+
Stream << Name.size() << Name;
178+
recordSubstitution(Stream.str().substr(Index));
179+
}
185180
return MANGLE_SUCCESS;
186181
}
187182

0 commit comments

Comments
 (0)