Skip to content

Commit d41ed54

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web' (#1)
2 parents cd4d1a9 + dba1c20 commit d41ed54

File tree

79 files changed

+4291
-810
lines changed

Some content is hidden

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

79 files changed

+4291
-810
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,6 +3414,9 @@ class OffloadingActionBuilder final {
34143414
++TC;
34153415
continue;
34163416
}
3417+
if (LI.empty())
3418+
// Current list is empty, nothing to process.
3419+
continue;
34173420

34183421
// Perform a check for device kernels. This is done for FPGA when an
34193422
// aocx or aocr based file is found.

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3853,8 +3853,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
38533853
CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
38543854

38553855
bool IsMSVC = AuxT.isWindowsMSVCEnvironment();
3856-
if (types::isCXX(Input.getType()))
3857-
CmdArgs.push_back(IsMSVC ? "-std=c++14" : "-std=c++11");
38583856
if (IsMSVC) {
38593857
CmdArgs.push_back("-fms-extensions");
38603858
CmdArgs.push_back("-fms-compatibility");

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4613,10 +4613,11 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
46134613
return true;
46144614
}
46154615

4616+
const TargetInfo &TI = Context.getTargetInfo();
46164617
// TODO: diagnose uses of these conventions on the wrong target.
46174618
switch (Attrs.getKind()) {
46184619
case ParsedAttr::AT_CDecl:
4619-
CC = CC_C;
4620+
CC = TI.getDefaultCallingConv();
46204621
break;
46214622
case ParsedAttr::AT_FastCall:
46224623
CC = CC_X86FastCall;
@@ -4681,7 +4682,6 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
46814682
}
46824683

46834684
TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
4684-
const TargetInfo &TI = Context.getTargetInfo();
46854685
// CUDA functions may have host and/or device attributes which indicate
46864686
// their targeted execution environment, therefore the calling convention
46874687
// of functions in CUDA should be checked against the target deduced based

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,8 @@ static target getAccessTarget(const ClassTemplateSpecializationDecl *AccTy) {
989989
// Fields of kernel object must be initialized with SYCL kernel arguments so
990990
// in the following function we extract types of kernel object fields and add it
991991
// to the array with kernel parameters descriptors.
992-
static void buildArgTys(ASTContext &Context, CXXRecordDecl *KernelObj,
992+
// Returns true if all arguments are successfully built.
993+
static bool buildArgTys(ASTContext &Context, CXXRecordDecl *KernelObj,
993994
SmallVectorImpl<ParamDesc> &ParamDescs) {
994995
const LambdaCapture *Cpt = KernelObj->captures_begin();
995996
auto CreateAndAddPrmDsc = [&](const FieldDecl *Fld, const QualType &ArgType) {
@@ -1040,6 +1041,7 @@ static void buildArgTys(ASTContext &Context, CXXRecordDecl *KernelObj,
10401041
}
10411042
};
10421043

1044+
bool AllArgsAreValid = true;
10431045
// Run through kernel object fields and create corresponding kernel
10441046
// parameters descriptors. There are a several possible cases:
10451047
// - Kernel object field is a SYCL special object (SYCL accessor or SYCL
@@ -1054,17 +1056,22 @@ static void buildArgTys(ASTContext &Context, CXXRecordDecl *KernelObj,
10541056
QualType ArgTy = Fld->getType();
10551057
if (Util::isSyclAccessorType(ArgTy) || Util::isSyclSamplerType(ArgTy)) {
10561058
createSpecialSYCLObjParamDesc(Fld, ArgTy);
1057-
} else if (ArgTy->isStructureOrClassType()) {
1059+
} else if (!ArgTy->isStandardLayoutType()) {
10581060
// SYCL v1.2.1 s4.8.10 p5:
10591061
// C++ non-standard layout values must not be passed as arguments to a
10601062
// kernel that is compiled for a device.
1061-
if (!ArgTy->isStandardLayoutType()) {
1062-
const DeclaratorDecl *V =
1063-
Cpt ? cast<DeclaratorDecl>(Cpt->getCapturedVar())
1064-
: cast<DeclaratorDecl>(Fld);
1065-
KernelObj->getASTContext().getDiagnostics().Report(
1066-
V->getLocation(), diag::err_sycl_non_std_layout_type);
1067-
}
1063+
const auto &DiagLocation =
1064+
Cpt ? Cpt->getLocation() : cast<DeclaratorDecl>(Fld)->getLocation();
1065+
1066+
Context.getDiagnostics().Report(DiagLocation,
1067+
diag::err_sycl_non_std_layout_type);
1068+
1069+
// Set the flag and continue processing so we can emit error for each
1070+
// invalid argument.
1071+
AllArgsAreValid = false;
1072+
} else if (ArgTy->isStructureOrClassType()) {
1073+
assert(ArgTy->isStandardLayoutType());
1074+
10681075
CreateAndAddPrmDsc(Fld, ArgTy);
10691076

10701077
// Create descriptors for each accessor field in the class or struct
@@ -1077,22 +1084,27 @@ static void buildArgTys(ASTContext &Context, CXXRecordDecl *KernelObj,
10771084
PointeeTy = Context.getQualifiedType(PointeeTy.getUnqualifiedType(),
10781085
Quals);
10791086
QualType ModTy = Context.getPointerType(PointeeTy);
1080-
1087+
10811088
CreateAndAddPrmDsc(Fld, ModTy);
10821089
} else if (ArgTy->isScalarType()) {
10831090
CreateAndAddPrmDsc(Fld, ArgTy);
10841091
} else {
10851092
llvm_unreachable("Unsupported kernel parameter type");
10861093
}
1094+
1095+
// Update capture iterator as we process arguments
1096+
if (Cpt && Cpt != KernelObj->captures_end())
1097+
++Cpt;
10871098
}
1099+
1100+
return AllArgsAreValid;
10881101
}
10891102

10901103
/// Adds necessary data describing given kernel to the integration header.
10911104
/// \param H the integration header object
10921105
/// \param Name kernel name
10931106
/// \param NameType type representing kernel name (first template argument
1094-
/// of
1095-
/// single_task, parallel_for, etc)
1107+
/// of single_task, parallel_for, etc)
10961108
/// \param KernelObjTy kernel object type
10971109
static void populateIntHeader(SYCLIntegrationHeader &H, const StringRef Name,
10981110
QualType NameType, CXXRecordDecl *KernelObjTy) {
@@ -1238,15 +1250,24 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc,
12381250

12391251
// Build list of kernel arguments
12401252
llvm::SmallVector<ParamDesc, 16> ParamDescs;
1241-
buildArgTys(getASTContext(), LE, ParamDescs);
1253+
if (!buildArgTys(getASTContext(), LE, ParamDescs))
1254+
return;
12421255

12431256
// Extract name from kernel caller parameters and mangle it.
12441257
const TemplateArgumentList *TemplateArgs =
12451258
KernelCallerFunc->getTemplateSpecializationArgs();
12461259
assert(TemplateArgs && "No template argument info");
12471260
QualType KernelNameType = TypeName::getFullyQualifiedType(
12481261
TemplateArgs->get(0).getAsType(), getASTContext(), true);
1249-
std::string Name = constructKernelName(KernelNameType, MC);
1262+
1263+
std::string Name;
1264+
// TODO SYCLIntegrationHeader also computes a unique stable name. It should
1265+
// probably lose this responsibility and only use the name provided here.
1266+
if (getLangOpts().SYCLUnnamedLambda)
1267+
Name = PredefinedExpr::ComputeName(
1268+
getASTContext(), PredefinedExpr::UniqueStableNameExpr, KernelNameType);
1269+
else
1270+
Name = constructKernelName(KernelNameType, MC);
12501271

12511272
// TODO Maybe don't emit integration header inside the Sema?
12521273
populateIntHeader(getSyclIntegrationHeader(), Name, KernelNameType, LE);

clang/test/CodeGenSYCL/fpga_pipes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
class SomePipe;
77
void foo() {
88
using Pipe = cl::sycl::pipe<SomePipe, int>;
9-
// CHECK: %WPipe = alloca %opencl.pipe_wo_t
9+
// CHECK: %{{.*}} = alloca %opencl.pipe_wo_t
1010
Pipe::write(42);
11-
// CHECK: %RPipe = alloca %opencl.pipe_ro_t
11+
// CHECK: %{{.*}} = alloca %opencl.pipe_ro_t
1212
int a = Pipe::read();
1313
}
1414

clang/test/Driver/sycl-offload-intelfpga.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,22 @@
8888
// RUN: llc -filetype=obj -o %t-aocx.o %t-aocx.bc
8989
// RUN: llvm-ar crv %t_aocx.a %t.o %t-aocx.o
9090
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fintelfpga %t_aocx.a -ccc-print-phases 2>&1 \
91-
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX-PHASES,CHK-FPGA-AOCX-PHASES-DEFAULT %s
91+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX-PHASES %s
9292
// RUN: %clang_cl -fsycl -fintelfpga %t_aocx.a -ccc-print-phases 2>&1 \
93-
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX-PHASES,CHK-FPGA-AOCX-PHASES-CL %s
93+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX-PHASES %s
9494
// CHK-FPGA-AOCX-PHASES: 0: input, "{{.*}}", object, (host-sycl)
9595
// CHK-FPGA-AOCX-PHASES: 1: linker, {0}, image, (host-sycl)
96-
// CHK-FPGA-AOCX-PHASES: 2: linker, {}, spirv, (device-sycl)
97-
// CHK-FPGA-AOCX-PHASES: 3: backend-compiler, {2}, fpga-aocx, (device-sycl)
98-
// CHK-FPGA-AOCX-PHASES: 4: clang-offload-wrapper, {3}, object, (device-sycl)
99-
// CHK-FPGA-AOCX-PHASES-DEFAULT: 5: offload, "host-sycl (x86_64-unknown-linux-gnu)" {1}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice)" {4}, image
100-
// CHK-FPGA-AOCX-PHASES-CL: 5: offload, "host-sycl (x86_64-pc-windows-msvc)" {1}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice-coff)" {4}, image
10196

10297
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fintelfpga %t_aocx.a -### 2>&1 \
103-
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX %s
98+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX,CHK-FPGA-AOCX-LIN %s
99+
// RUN: %clang_cl -fsycl -fintelfpga %t_aocx.a -### 2>&1 \
100+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX,CHK-FPGA-AOCX-WIN %s
104101
// CHK-FPGA-AOCX: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocx-intel-unknown-sycldevice" "-inputs=[[LIBINPUT:.+\.a]]" "-outputs=[[BUNDLEOUT:.+\.aocx]]" "-unbundle"
105-
// CHK-FPGA-AOCX: clang-offload-wrapper{{.*}} "-o=[[WRAPOUT:.+\.bc]]" "-host=x86_64-unknown-linux-gnu" "-target=spir64_fpga" "-kind=sycl" "[[BUNDLEOUT]]"
106-
// CHK-FPGA-AOCX: llc{{.*}} "-filetype=obj" "-o" "[[LLCOUT:.+\.o]]" "[[WRAPOUT]]"
107-
// CHK-FPGA-AOCX: ld{{.*}} "[[LIBINPUT]]" "[[LLCOUT]]"
102+
// CHK-FPGA-AOCX: clang-offload-wrapper{{.*}} "-o=[[WRAPOUT:.+\.bc]]" {{.*}} "-target=spir64_fpga" "-kind=sycl" "[[BUNDLEOUT]]"
103+
// CHK-FPGA-AOCX-LIN: llc{{.*}} "-filetype=obj" "-o" "[[LLCOUT:.+\.o]]" "[[WRAPOUT]]"
104+
// CHK-FPGA-AOCX-WIN: llc{{.*}} "-filetype=obj" "-o" "[[LLCOUT2:.+\.obj]]" "[[WRAPOUT]]"
105+
// CHK-FPGA-AOCX-LIN: ld{{.*}} "[[LIBINPUT]]" "[[LLCOUT]]"
106+
// CHK-FPGA-AOCX-WIN: link{{.*}} "[[LIBINPUT]]" "[[LLCOUT2]]"
108107

109108
/// -fintelfpga -fsycl-link from source
110109
// RUN: touch %t.cpp

clang/test/Driver/sycl-offload.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,5 +793,12 @@
793793
// RUN: | FileCheck -check-prefix=DUP-OPT %s
794794
// DUP-OPT-NOT: aoc{{.*}} "-DBLAH" {{.*}} "-DBLAH"
795795

796+
/// passing of only a library should not create a device link
797+
// RUN: %clang -ccc-print-phases -fsycl -lsomelib 2>&1 \
798+
// RUN: | FileCheck -check-prefix=LIB-NODEVICE %s
799+
// LIB-NODEVICE: 0: input, "somelib", object, (host-sycl)
800+
// LIB-NODEVICE: 1: linker, {0}, image, (host-sycl)
801+
// LIB-NODEVICE-NOT: linker, {{.*}}, spirv, (device-sycl)
802+
796803
// TODO: SYCL specific fail - analyze and enable
797804
// XFAIL: windows-msvc

clang/test/Driver/sycl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
// RUN: %clang -### --sycl -fno-sycl-use-bitcode -c %s 2>&1 | FileCheck %s --check-prefix=NO-BITCODE
55
// RUN: %clang -### -target spir64-unknown-linux-sycldevice -c -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=TARGET
66
// RUN: %clang -### --sycl -c -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=COMBINED
7+
// RUN: %clangxx -### -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
8+
// RUN: %clang_cl -### -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
79

8-
// DEFAULT: "-triple" "spir64-unknown-{{.*}}-sycldevice"{{.*}} "-fsycl-is-device"{{.*}} "-emit-llvm-bc"
10+
// DEFAULT: "-triple" "spir64-unknown-{{.*}}-sycldevice{{.*}}" "-fsycl-is-device"{{.*}} "-emit-llvm-bc"
911
// DEFAULT: "-internal-isystem" "{{.*lib.*clang.*include}}"
1012
// DEFAULT-NOT: "{{.*}}llvm-spirv"{{.*}} "-spirv-max-version=1.1"{{.*}} "-spirv-ext=+all"
13+
// DEFAULT-NOT: "-std=c++11"
14+
// DEFAULT-NOT: "-std=c++14"
1115
// NO-BITCODE: "-triple" "spir64-unknown-{{.*}}-sycldevice"{{.*}} "-fsycl-is-device"{{.*}} "-emit-llvm-bc"
1216
// NO-BITCODE: "{{.*}}llvm-spirv"{{.*}} "-spirv-max-version=1.1"{{.*}} "-spirv-ext=+all"
1317
// TARGET: "-triple" "spir64-unknown-linux-sycldevice"{{.*}} "-fsycl-is-device"{{.*}} "-emit-llvm-bc"

clang/test/SemaSYCL/mangle-unnamed-kernel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ int main() {
88
return 0;
99
}
1010

11-
// CHECK: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_
12-
// CHECK: _ZTSZZ4mainENK3$_1clERN2cl4sycl7handlerEEUlvE_
11+
// CHECK: _ZTSZZ4mainENKUlRN2cl4sycl7handlerEE6->12clES2_EUlvE6->54{{.*}}
12+
// CHECK: _ZTSZZ4mainENKUlRN2cl4sycl7handlerEE7->12clES2_EUlvE7->54{{.*}}

clang/test/SemaSYCL/non-std-layout-param.cpp

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,61 @@ __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
2020

2121

2222
void test() {
23-
// expected-error@+1 {{kernel parameter has non-standard layout class/struct type}}
2423
C C0;
2524
C0.Y=0;
26-
kernel_single_task<class MyKernel>([=] { (void)C0.Y; });
25+
kernel_single_task<class MyKernel>([=] {
26+
// expected-error@+1 {{kernel parameter has non-standard layout class/struct type}}
27+
(void)C0.Y;
28+
});
29+
}
30+
31+
void test_capture_explicit_ref() {
32+
int p = 0;
33+
double q = 0;
34+
float s = 0;
35+
kernel_single_task<class kernel_capture_single_ref>([
36+
// expected-error@+1 {{kernel parameter has non-standard layout class/struct type}}
37+
&p,
38+
q,
39+
// expected-error@+1 {{kernel parameter has non-standard layout class/struct type}}
40+
&s] {
41+
(void) q;
42+
(void) p;
43+
(void) s;
44+
});
2745
}
2846

47+
void test_capture_implicit_refs() {
48+
int p = 0;
49+
double q = 0;
50+
kernel_single_task<class kernel_capture_refs>([&] {
51+
// expected-error@+1 {{kernel parameter has non-standard layout class/struct type}}
52+
(void) p;
53+
// expected-error@+1 {{kernel parameter has non-standard layout class/struct type}}
54+
(void) q;
55+
});
56+
}
57+
58+
struct Kernel {
59+
void operator()() {
60+
(void) c1;
61+
(void) c2;
62+
(void) p;
63+
(void) q;
64+
}
65+
66+
int p;
67+
// expected-error@+1 {{kernel parameter has non-standard layout class/struct type}}
68+
C c1;
69+
70+
int q;
71+
72+
// expected-error@+1 {{kernel parameter has non-standard layout class/struct type}}
73+
C c2;
74+
};
75+
76+
void test_struct_field() {
77+
Kernel k{};
78+
79+
kernel_single_task<class kernel_object>(k);
80+
}

clang/test/SemaSYCL/sycl-cconv.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
// RUN: %clang_cc1 -triple spir64-unknown-windows-sycldevice -aux-triple x86_64-pc-windows-msvc -fsycl-is-device -fsyntax-only -verify %s
22

3-
//expected-warning@+1 {{'__cdecl' calling convention is not supported for this target}}
3+
// expected-no-warning@+1
44
__inline __cdecl int printf(char const* const _Format, ...) { return 0; }
5+
// expected-no-warning@+1
6+
__inline __cdecl __attribute__((sycl_device)) int foo() { return 0; }
7+
// expected-no-warning@+1
8+
__inline __cdecl int moo() { return 0; }
59

610
void bar() {
711
printf("hello\n"); // expected-no-error
812
}
913

1014
template <typename name, typename Func>
11-
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
15+
// expected-no-warning@+1
16+
__cdecl __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
17+
// expected-error@+1{{SYCL kernel cannot call a variadic function}}
18+
printf("cannot call from here\n");
19+
// expected-no-error@+1
20+
moo();
1221
kernelFunc();
1322
}
1423

sycl/doc/SYCLPluginInterface.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,17 @@ These APIs match semantics of the corresponding OpenCL APIs exactly.
120120
For example:
121121

122122
```
123-
pi_program piclProgramCreateWithSource(
123+
pi_result piclProgramCreateWithSource(
124124
pi_context context,
125125
pi_uint32 count,
126126
const char ** strings,
127127
const size_t * lengths,
128-
pi_result * errcode);
128+
pi_program * ret_program);
129129
```
130130

131131
### PI Extension mechanism
132132

133133
TBD This section describes a mechanism for SYCL or other runtimes to detect
134134
availability of and obtain interfaces beyond those defined by the PI dispatch.
135135

136-
TBD Add API to query PI version supported by plugin at runtime.
136+
TBD Add API to query PI version supported by plugin at runtime.

0 commit comments

Comments
 (0)