Skip to content

Commit 2606290

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 2c62077 + 2c5822e commit 2606290

Some content is hidden

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

42 files changed

+1218
-1292
lines changed

buildbot/dependency.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
ocl_cpu_rt_ver=2020.10.4.0.15
44
# https://github.com/intel/llvm/releases/download/2020-03/win-oclcpuexp-2020.10.4.0.15_rel.zip
55
ocl_cpu_rt_ver_win=2020.10.4.0.15
6-
# https://github.com/intel/compute-runtime/releases/tag/20.12.16259
7-
ocl_gpu_rt_ver=l0-20.12.16259
6+
# https://github.com/intel/compute-runtime/releases/tag/20.19.16754
7+
ocl_gpu_rt_ver=20.19.16754
88
# https://downloadcenter.intel.com/download/29557/Intel-Graphics-Windows-10-DCH-Drivers
99
ocl_gpu_rt_ver_win=ci-neo-015900
1010
intel_sycl_ver=build
@@ -20,7 +20,7 @@ fpga_ver_win=20200216_000000
2020
[DRIVER VERSIONS]
2121
cpu_driver_lin=2020.10.4.0.15
2222
cpu_driver_win=2020.10.4.0.15
23-
gpu_driver_lin=20.12.16259
23+
gpu_driver_lin=20.19.16754
2424
gpu_driver_win=ci-neo-015900
2525
fpga_driver_lin=2020.9.2.0
2626
fpga_driver_win=2020.9.2.0

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10816,7 +10816,6 @@ def err_sycl_restrict : Error<
1081610816
"}0">;
1081710817
def err_sycl_virtual_types : Error<
1081810818
"No class with a vtable can be used in a SYCL kernel or any code included in the kernel">;
10819-
def note_sycl_used_here : Note<"used here">;
1082010819
def note_sycl_recursive_function_declared_here: Note<"function implemented using recursion declared here">;
1082110820
def err_sycl_non_trivially_copy_ctor_dtor_type
1082210821
: Error<"kernel parameter has non-trivially %select{copy "

clang/include/clang/Sema/Sema.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ class SYCLIntegrationHeader {
319319
};
320320

321321
public:
322-
SYCLIntegrationHeader(DiagnosticsEngine &Diag, bool UnnamedLambdaSupport);
322+
SYCLIntegrationHeader(DiagnosticsEngine &Diag, bool UnnamedLambdaSupport,
323+
Sema &S);
323324

324325
/// Emits contents of the header into given stream.
325326
void emit(raw_ostream &Out);
@@ -424,6 +425,8 @@ class SYCLIntegrationHeader {
424425

425426
/// Whether header is generated with unnamed lambda support
426427
bool UnnamedLambdaSupport;
428+
429+
Sema &S;
427430
};
428431

429432
/// Keeps track of expected type during expression parsing. The type is tied to
@@ -12588,7 +12591,7 @@ class Sema final {
1258812591
SYCLIntegrationHeader &getSyclIntegrationHeader() {
1258912592
if (SyclIntHeader == nullptr)
1259012593
SyclIntHeader = std::make_unique<SYCLIntegrationHeader>(
12591-
getDiagnostics(), getLangOpts().SYCLUnnamedLambda);
12594+
getDiagnostics(), getLangOpts().SYCLUnnamedLambda, *this);
1259212595
return *SyclIntHeader.get();
1259312596
}
1259412597

clang/lib/CodeGen/CGSYCLRuntime.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
using namespace clang;
2121
using namespace CodeGen;
2222

23+
namespace {
24+
2325
/// Various utilities.
2426
/// TODO partially duplicates functionality from SemaSYCL.cpp, can be shared.
2527
class Util {
@@ -52,6 +54,8 @@ const char *WG_SCOPE_MD_ID = "work_group_scope";
5254
const char *WI_SCOPE_MD_ID = "work_item_scope";
5355
const char *PFWI_MD_ID = "parallel_for_work_item";
5456

57+
} // anonymous namespace
58+
5559
bool CGSYCLRuntime::actOnFunctionStart(const FunctionDecl &FD,
5660
llvm::Function &F) {
5761
SYCLScopeAttr *Scope = FD.getAttr<SYCLScopeAttr>();

clang/lib/Driver/Driver.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,12 +3549,21 @@ class OffloadingActionBuilder final {
35493549
for (auto SDA : SYCLDeviceActions)
35503550
SYCLLinkBinaryList.push_back(SDA);
35513551
if (WrapDeviceOnlyBinary) {
3552-
auto *DeviceLinkAction =
3553-
C.MakeAction<LinkJobAction>(SYCLLinkBinaryList, types::TY_Image);
3554-
// Wrap the binary when -fsycl-link is given
3555-
SYCLLinkBinary =
3556-
C.MakeAction<OffloadWrapperJobAction>(DeviceLinkAction,
3557-
types::TY_Object);
3552+
// -fsycl-link behavior does the following to the unbundled device
3553+
// binaries:
3554+
// 1) Link them together using llvm-link
3555+
// 2) Pass the linked binary through sycl-post-link
3556+
// 3) Translate final .bc file to .spv
3557+
// 4) Wrap the binary with the offload wrapper which can be used
3558+
// by any compilation link step.
3559+
auto *DeviceLinkAction = C.MakeAction<LinkJobAction>(
3560+
SYCLLinkBinaryList, types::TY_Image);
3561+
auto *PostLinkAction = C.MakeAction<SYCLPostLinkJobAction>(
3562+
DeviceLinkAction, types::TY_LLVM_BC);
3563+
auto *TranslateAction = C.MakeAction<SPIRVTranslatorJobAction>(
3564+
PostLinkAction, types::TY_Image);
3565+
SYCLLinkBinary = C.MakeAction<OffloadWrapperJobAction>(
3566+
TranslateAction, types::TY_Object);
35583567
} else {
35593568
auto *Link = C.MakeAction<LinkJobAction>(SYCLLinkBinaryList,
35603569
types::TY_Image);

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 80 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ enum KernelInvocationKind {
5454
const static std::string InitMethodName = "__init";
5555
const static std::string FinalizeMethodName = "__finalize";
5656

57+
namespace {
58+
5759
/// Various utilities.
5860
class Util {
5961
public:
@@ -91,6 +93,8 @@ class Util {
9193
ArrayRef<Util::DeclContextDesc> Scopes);
9294
};
9395

96+
} // anonymous namespace
97+
9498
// This information is from Section 4.13 of the SYCL spec
9599
// https://www.khronos.org/registry/SYCL/specs/sycl-1.2.1.pdf
96100
// This function returns false if the math lib function
@@ -206,19 +210,9 @@ static bool isZeroSizedArray(QualType Ty) {
206210
return false;
207211
}
208212

209-
static Sema::DeviceDiagBuilder
210-
emitDeferredDiagnosticAndNote(Sema &S, SourceRange Loc, unsigned DiagID,
211-
SourceRange UsedAtLoc) {
212-
Sema::DeviceDiagBuilder builder =
213-
S.SYCLDiagIfDeviceCode(Loc.getBegin(), DiagID);
214-
if (UsedAtLoc.isValid())
215-
S.SYCLDiagIfDeviceCode(UsedAtLoc.getBegin(), diag::note_sycl_used_here);
216-
return builder;
217-
}
218-
219-
static void checkSYCLVarType(Sema &S, QualType Ty, SourceRange Loc,
220-
llvm::DenseSet<QualType> Visited,
221-
SourceRange UsedAtLoc = SourceRange()) {
213+
static void checkSYCLType(Sema &S, QualType Ty, SourceRange Loc,
214+
llvm::DenseSet<QualType> Visited,
215+
SourceRange UsedAtLoc = SourceRange()) {
222216
// Not all variable types are supported inside SYCL kernels,
223217
// for example the quad type __float128 will cause errors in the
224218
// SPIR-V translation phase.
@@ -229,16 +223,21 @@ static void checkSYCLVarType(Sema &S, QualType Ty, SourceRange Loc,
229223
// different location than the variable declaration and we need to
230224
// inform the user of both, e.g. struct member usage vs declaration.
231225

226+
bool Emitting = false;
227+
232228
//--- check types ---
233229

234230
// zero length arrays
235-
if (isZeroSizedArray(Ty))
236-
emitDeferredDiagnosticAndNote(S, Loc, diag::err_typecheck_zero_array_size,
237-
UsedAtLoc);
231+
if (isZeroSizedArray(Ty)) {
232+
S.SYCLDiagIfDeviceCode(Loc.getBegin(), diag::err_typecheck_zero_array_size);
233+
Emitting = true;
234+
}
238235

239236
// variable length arrays
240-
if (Ty->isVariableArrayType())
241-
emitDeferredDiagnosticAndNote(S, Loc, diag::err_vla_unsupported, UsedAtLoc);
237+
if (Ty->isVariableArrayType()) {
238+
S.SYCLDiagIfDeviceCode(Loc.getBegin(), diag::err_vla_unsupported);
239+
Emitting = true;
240+
}
242241

243242
// Sub-reference array or pointer, then proceed with that type.
244243
while (Ty->isAnyPointerType() || Ty->isArrayType())
@@ -249,9 +248,14 @@ static void checkSYCLVarType(Sema &S, QualType Ty, SourceRange Loc,
249248
Ty->isSpecificBuiltinType(BuiltinType::UInt128) ||
250249
Ty->isSpecificBuiltinType(BuiltinType::LongDouble) ||
251250
(Ty->isSpecificBuiltinType(BuiltinType::Float128) &&
252-
!S.Context.getTargetInfo().hasFloat128Type()))
253-
emitDeferredDiagnosticAndNote(S, Loc, diag::err_type_unsupported, UsedAtLoc)
251+
!S.Context.getTargetInfo().hasFloat128Type())) {
252+
S.SYCLDiagIfDeviceCode(Loc.getBegin(), diag::err_type_unsupported)
254253
<< Ty.getUnqualifiedType().getCanonicalType();
254+
Emitting = true;
255+
}
256+
257+
if (Emitting && UsedAtLoc.isValid())
258+
S.SYCLDiagIfDeviceCode(UsedAtLoc.getBegin(), diag::note_used_here);
255259

256260
//--- now recurse ---
257261
// Pointers complicate recursion. Add this type to Visited.
@@ -260,16 +264,15 @@ static void checkSYCLVarType(Sema &S, QualType Ty, SourceRange Loc,
260264
return;
261265

262266
if (const auto *ATy = dyn_cast<AttributedType>(Ty))
263-
return checkSYCLVarType(S, ATy->getModifiedType(), Loc, Visited);
267+
return checkSYCLType(S, ATy->getModifiedType(), Loc, Visited);
264268

265269
if (const auto *RD = Ty->getAsRecordDecl()) {
266270
for (const auto &Field : RD->fields())
267-
checkSYCLVarType(S, Field->getType(), Field->getSourceRange(), Visited,
268-
Loc);
271+
checkSYCLType(S, Field->getType(), Field->getSourceRange(), Visited, Loc);
269272
} else if (const auto *FPTy = dyn_cast<FunctionProtoType>(Ty)) {
270273
for (const auto &ParamTy : FPTy->param_types())
271-
checkSYCLVarType(S, ParamTy, Loc, Visited);
272-
checkSYCLVarType(S, FPTy->getReturnType(), Loc, Visited);
274+
checkSYCLType(S, ParamTy, Loc, Visited);
275+
checkSYCLType(S, FPTy->getReturnType(), Loc, Visited);
273276
}
274277
}
275278

@@ -280,7 +283,7 @@ void Sema::checkSYCLDeviceVarDecl(VarDecl *Var) {
280283
SourceRange Loc = Var->getLocation();
281284
llvm::DenseSet<QualType> Visited;
282285

283-
checkSYCLVarType(*this, Ty, Loc, Visited);
286+
checkSYCLType(*this, Ty, Loc, Visited);
284287
}
285288

286289
class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
@@ -801,6 +804,22 @@ class SyclKernelFieldChecker
801804
bool IsInvalid = false;
802805
DiagnosticsEngine &Diag;
803806

807+
void checkAccessorType(QualType Ty, SourceRange Loc) {
808+
assert(Util::isSyclAccessorType(Ty) &&
809+
"Should only be called on SYCL accessor types.");
810+
811+
const RecordDecl *RecD = Ty->getAsRecordDecl();
812+
if (const ClassTemplateSpecializationDecl *CTSD =
813+
dyn_cast<ClassTemplateSpecializationDecl>(RecD)) {
814+
const TemplateArgumentList &TAL = CTSD->getTemplateArgs();
815+
TemplateArgument TA = TAL.get(0);
816+
const QualType TemplateArgTy = TA.getAsType();
817+
818+
llvm::DenseSet<QualType> Visited;
819+
checkSYCLType(SemaRef, TemplateArgTy, Loc, Visited);
820+
}
821+
}
822+
804823
public:
805824
SyclKernelFieldChecker(Sema &S)
806825
: SyclKernelFieldHandler(S), Diag(S.getASTContext().getDiagnostics()) {}
@@ -832,6 +851,15 @@ class SyclKernelFieldChecker
832851
}
833852
}
834853

854+
void handleSyclAccessorType(const CXXBaseSpecifier &BS,
855+
QualType FieldTy) final {
856+
checkAccessorType(FieldTy, BS.getBeginLoc());
857+
}
858+
859+
void handleSyclAccessorType(FieldDecl *FD, QualType FieldTy) final {
860+
checkAccessorType(FieldTy, FD->getLocation());
861+
}
862+
835863
// We should be able to handle this, so we made it part of the visitor, but
836864
// this is 'to be implemented'.
837865
void handleArrayType(FieldDecl *FD, QualType FieldTy) final {
@@ -1454,7 +1482,6 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc,
14541482
}
14551483

14561484
void Sema::MarkDevice(void) {
1457-
// Let's mark all called functions with SYCL Device attribute.
14581485
// Create the call graph so we can detect recursion and check the validity
14591486
// of new operator overrides. Add the kernel function itself in case
14601487
// it is recursive.
@@ -1540,7 +1567,9 @@ Sema::DeviceDiagBuilder Sema::SYCLDiagIfDeviceCode(SourceLocation Loc,
15401567
"Should only be called during SYCL compilation");
15411568
FunctionDecl *FD = dyn_cast<FunctionDecl>(getCurLexicalContext());
15421569
DeviceDiagBuilder::Kind DiagKind = [this, FD] {
1543-
if (ConstructingOpenCLKernel || !FD)
1570+
if (ConstructingOpenCLKernel)
1571+
return DeviceDiagBuilder::K_ImmediateWithCallStack;
1572+
if (!FD)
15441573
return DeviceDiagBuilder::K_Nop;
15451574
if (getEmissionStatus(FD) == Sema::FunctionEmissionStatus::Emitted)
15461575
return DeviceDiagBuilder::K_ImmediateWithCallStack;
@@ -1863,6 +1892,9 @@ static void printArguments(ASTContext &Ctx, raw_ostream &ArgOS,
18631892
ArrayRef<TemplateArgument> Args,
18641893
const PrintingPolicy &P);
18651894

1895+
static std::string getKernelNameTypeString(QualType T, ASTContext &Ctx,
1896+
const PrintingPolicy &TypePolicy);
1897+
18661898
static void printArgument(ASTContext &Ctx, raw_ostream &ArgOS,
18671899
TemplateArgument Arg, const PrintingPolicy &P) {
18681900
switch (Arg.getKind()) {
@@ -1888,8 +1920,7 @@ static void printArgument(ASTContext &Ctx, raw_ostream &ArgOS,
18881920
TypePolicy.SuppressTypedefs = true;
18891921
TypePolicy.SuppressTagKeyword = true;
18901922
QualType T = Arg.getAsType();
1891-
QualType FullyQualifiedType = TypeName::getFullyQualifiedType(T, Ctx, true);
1892-
ArgOS << FullyQualifiedType.getAsString(TypePolicy);
1923+
ArgOS << getKernelNameTypeString(T, Ctx, TypePolicy);
18931924
break;
18941925
}
18951926
default:
@@ -1903,6 +1934,10 @@ static void printArguments(ASTContext &Ctx, raw_ostream &ArgOS,
19031934
for (unsigned I = 0; I < Args.size(); I++) {
19041935
const TemplateArgument &Arg = Args[I];
19051936

1937+
// If argument is an empty pack argument, skip printing comma and argument.
1938+
if (Arg.getKind() == TemplateArgument::ArgKind::Pack && !Arg.pack_size())
1939+
continue;
1940+
19061941
if (I != 0)
19071942
ArgOS << ", ";
19081943

@@ -1918,36 +1953,36 @@ static void printTemplateArguments(ASTContext &Ctx, raw_ostream &ArgOS,
19181953
ArgOS << ">";
19191954
}
19201955

1921-
static std::string getKernelNameTypeString(QualType T) {
1956+
static std::string getKernelNameTypeString(QualType T, ASTContext &Ctx,
1957+
const PrintingPolicy &TypePolicy) {
1958+
1959+
QualType FullyQualifiedType = TypeName::getFullyQualifiedType(T, Ctx, true);
19221960

19231961
const CXXRecordDecl *RD = T->getAsCXXRecordDecl();
19241962

19251963
if (!RD)
1926-
return getCPPTypeString(T);
1964+
return eraseAnonNamespace(FullyQualifiedType.getAsString(TypePolicy));
19271965

19281966
// If kernel name type is a template specialization with enum type
19291967
// template parameters, enumerators in name type string should be
19301968
// replaced with their underlying value since the enum definition
19311969
// is not visible in integration header.
19321970
if (const auto *TSD = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
1933-
LangOptions LO;
1934-
PrintingPolicy P(LO);
1935-
P.SuppressTypedefs = true;
19361971
SmallString<64> Buf;
19371972
llvm::raw_svector_ostream ArgOS(Buf);
19381973

19391974
// Print template class name
1940-
TSD->printQualifiedName(ArgOS, P, /*WithGlobalNsPrefix*/ true);
1975+
TSD->printQualifiedName(ArgOS, TypePolicy, /*WithGlobalNsPrefix*/ true);
19411976

19421977
// Print template arguments substituting enumerators
19431978
ASTContext &Ctx = RD->getASTContext();
19441979
const TemplateArgumentList &Args = TSD->getTemplateArgs();
1945-
printTemplateArguments(Ctx, ArgOS, Args.asArray(), P);
1980+
printTemplateArguments(Ctx, ArgOS, Args.asArray(), TypePolicy);
19461981

19471982
return eraseAnonNamespace(ArgOS.str().str());
19481983
}
19491984

1950-
return getCPPTypeString(T);
1985+
return eraseAnonNamespace(FullyQualifiedType.getAsString(TypePolicy));
19511986
}
19521987

19531988
void SYCLIntegrationHeader::emit(raw_ostream &O) {
@@ -2066,9 +2101,11 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
20662101
O << "', '" << c;
20672102
O << "'> {\n";
20682103
} else {
2069-
2104+
LangOptions LO;
2105+
PrintingPolicy P(LO);
2106+
P.SuppressTypedefs = true;
20702107
O << "template <> struct KernelInfo<"
2071-
<< getKernelNameTypeString(K.NameType) << "> {\n";
2108+
<< getKernelNameTypeString(K.NameType, S.getASTContext(), P) << "> {\n";
20722109
}
20732110
O << " DLL_LOCAL\n";
20742111
O << " static constexpr const char* getName() { return \"" << K.Name
@@ -2137,8 +2174,9 @@ void SYCLIntegrationHeader::addSpecConstant(StringRef IDName, QualType IDType) {
21372174
}
21382175

21392176
SYCLIntegrationHeader::SYCLIntegrationHeader(DiagnosticsEngine &_Diag,
2140-
bool _UnnamedLambdaSupport)
2141-
: Diag(_Diag), UnnamedLambdaSupport(_UnnamedLambdaSupport) {}
2177+
bool _UnnamedLambdaSupport,
2178+
Sema &_S)
2179+
: Diag(_Diag), UnnamedLambdaSupport(_UnnamedLambdaSupport), S(_S) {}
21422180

21432181
// -----------------------------------------------------------------------------
21442182
// Utility class methods

0 commit comments

Comments
 (0)