Skip to content

Commit eb1470e

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web' (intel#29)
2 parents bc2d824 + d3dc212 commit eb1470e

File tree

122 files changed

+5827
-3052
lines changed

Some content is hidden

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

122 files changed

+5827
-3052
lines changed

.github/CODEOWNERS

+4-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ clang/tools/clang-offload-extract/ @sndmitriev @mlychkov @AlexeySachkov
101101
# Explicit SIMD
102102
SYCLLowerIR/ @kbobrovs @DenisBakhvalov
103103
esimd/ @kbobrovs @DenisBakhvalov
104-
sycl/include/CL/sycl/INTEL/esimd.hpp @kbobrovs @DenisBakhvalov
104+
sycl/include/sycl/ext/intel/experimental/esimd.hpp @kbobrovs @DenisBakhvalov
105105
sycl/doc/extensions/ExplicitSIMD/ @kbobrovs
106106

107107
# ITT annotations
108-
llvm/lib/Transforms/Instrumentation/SPIRITTAnnotations.cpp @MrSidims
109-
llvm/include/llvm/Transforms/Instrumentation/SPIRITTAnnotations.h @MrSidims
108+
llvm/lib/Transforms/Instrumentation/SPIRITTAnnotations.cpp @MrSidims @vzakhari
109+
llvm/include/llvm/Transforms/Instrumentation/SPIRITTAnnotations.h @MrSidims @vzakhari
110+
llvm/test/Transforms/SPIRITTAnnotations/* @MrSidims @vzakhari

buildbot/configure.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def do_configure(args):
3030
llvm_enable_doxygen = 'OFF'
3131
llvm_enable_sphinx = 'OFF'
3232
llvm_build_shared_libs = 'OFF'
33+
llvm_enable_lld = 'OFF'
3334

3435
sycl_enable_xpti_tracing = 'ON'
3536

@@ -56,6 +57,9 @@ def do_configure(args):
5657
if args.shared_libs:
5758
llvm_build_shared_libs = 'ON'
5859

60+
if args.use_lld:
61+
llvm_enable_lld = 'ON'
62+
5963
install_dir = os.path.join(abs_obj_dir, "install")
6064

6165
cmake_cmd = [
@@ -81,7 +85,8 @@ def do_configure(args):
8185
"-DLLVM_ENABLE_DOXYGEN={}".format(llvm_enable_doxygen),
8286
"-DLLVM_ENABLE_SPHINX={}".format(llvm_enable_sphinx),
8387
"-DBUILD_SHARED_LIBS={}".format(llvm_build_shared_libs),
84-
"-DSYCL_ENABLE_XPTI_TRACING={}".format(sycl_enable_xpti_tracing)
88+
"-DSYCL_ENABLE_XPTI_TRACING={}".format(sycl_enable_xpti_tracing),
89+
"-DLLVM_ENABLE_LLD={}".format(llvm_enable_lld)
8590
]
8691

8792
if args.l0_headers and args.l0_loader:
@@ -151,6 +156,7 @@ def main():
151156
parser.add_argument("--use-libcxx", action="store_true", help="build sycl runtime with libcxx")
152157
parser.add_argument("--libcxx-include", metavar="LIBCXX_INCLUDE_PATH", help="libcxx include path")
153158
parser.add_argument("--libcxx-library", metavar="LIBCXX_LIBRARY_PATH", help="libcxx library path")
159+
parser.add_argument("--use-lld", action="store_true", help="Use LLD linker for build")
154160
args = parser.parse_args()
155161

156162
print("args:{}".format(args))

buildbot/dependency.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ocl_cpu_rt_ver=2021.11.3.0.09
44
# https://github.com/intel/llvm/releases/download/2021-WW11/win-oclcpuexp-2021.11.3.0.09_rel.zip
55
ocl_cpu_rt_ver_win=2021.11.3.0.09
66
# Same GPU driver supports Level Zero and OpenCL
7-
# https://github.com/intel/compute-runtime/releases/tag/21.17.19709
8-
ocl_gpu_rt_ver=21.17.19709
7+
# https://github.com/intel/compute-runtime/releases/tag/21.19.19792
8+
ocl_gpu_rt_ver=21.19.19792
99
# Same GPU driver supports Level Zero and OpenCL
1010
# https://downloadmirror.intel.com/30381/a08/igfx_win10_100.9466.zip
1111
ocl_gpu_rt_ver_win=27.20.100.9466
@@ -30,7 +30,7 @@ ocloc_ver_win=27.20.100.9168
3030
[DRIVER VERSIONS]
3131
cpu_driver_lin=2021.11.3.0.09
3232
cpu_driver_win=2021.11.3.0.09
33-
gpu_driver_lin=21.17.19709
33+
gpu_driver_lin=21.19.19792
3434
gpu_driver_win=27.20.100.9466
3535
fpga_driver_lin=2021.11.3.0.09
3636
fpga_driver_win=2021.11.3.0.09

clang/include/clang/Basic/DiagnosticSemaKinds.td

+2
Original file line numberDiff line numberDiff line change
@@ -11417,6 +11417,8 @@ def err_sycl_mismatch_group_size
1141711417
"have a sub group size that matches the size specified for the "
1141811418
"kernel">;
1141911419
def note_sycl_kernel_declared_here : Note<"kernel declared here">;
11420+
def err_sycl_expected_finalize_method : Error<
11421+
"expected a 'finalize' method for the 'stream' class">;
1142011422
def ext_sycl_2020_attr_spelling : ExtWarn<
1142111423
"use of attribute %0 is a SYCL 2020 extension">,
1142211424
InGroup<Sycl2017Compat>;

clang/include/clang/Sema/Sema.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ class SYCLIntegrationHeader {
316316
kind_sampler,
317317
kind_pointer,
318318
kind_specialization_constants_buffer,
319-
kind_last = kind_specialization_constants_buffer
319+
kind_stream,
320+
kind_last = kind_stream
320321
};
321322

322323
public:

clang/lib/Driver/ToolChains/Clang.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -4703,7 +4703,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
47034703
if (AuxT.isWindowsMSVCEnvironment()) {
47044704
CmdArgs.push_back("-D_MT");
47054705
CmdArgs.push_back("-D_DLL");
4706-
CmdArgs.push_back("--dependent-lib=msvcrt");
47074706
}
47084707
}
47094708
}

clang/lib/Sema/SemaSYCL.cpp

+34-101
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ static constexpr llvm::StringLiteral InitESIMDMethodName = "__init_esimd";
6161
static constexpr llvm::StringLiteral InitSpecConstantsBuffer =
6262
"__init_specialization_constants_buffer";
6363
static constexpr llvm::StringLiteral FinalizeMethodName = "__finalize";
64+
static constexpr llvm::StringLiteral LibstdcxxFailedAssertion =
65+
"__failed_assertion";
6466
constexpr unsigned MaxKernelArgsSize = 2048;
6567

6668
namespace {
@@ -320,6 +322,21 @@ static bool isSYCLKernelBodyFunction(FunctionDecl *FD) {
320322
return FD->getOverloadedOperator() == OO_Call;
321323
}
322324

325+
static bool isSYCLUndefinedAllowed(const FunctionDecl *Callee,
326+
const SourceManager &SrcMgr) {
327+
if (!Callee)
328+
return false;
329+
330+
// libstdc++-11 introduced an undefined function "void __failed_assertion()"
331+
// which may lead to SemaSYCL check failure. However, this undefined function
332+
// is used to trigger some compilation error when the check fails at compile
333+
// time and will be ignored when the check succeeds. We allow calls to this
334+
// function to support some important std functions in SYCL device.
335+
return (Callee->getName() == LibstdcxxFailedAssertion) &&
336+
Callee->getNumParams() == 0 && Callee->getReturnType()->isVoidType() &&
337+
SrcMgr.isInSystemHeader(Callee->getLocation());
338+
}
339+
323340
// Helper function to report conflicting function attributes.
324341
// F - the function, A1 - function attribute, A2 - the attribute it conflicts
325342
// with.
@@ -1032,23 +1049,6 @@ class KernelObjVisitor {
10321049
VisitRecordFields(Owner, Handlers...);
10331050
}
10341051

1035-
// FIXME: Can this be refactored/handled some other way?
1036-
template <typename ParentTy, typename... HandlerTys>
1037-
void visitStreamRecord(const CXXRecordDecl *Owner, ParentTy &Parent,
1038-
CXXRecordDecl *Wrapper, QualType RecordTy,
1039-
HandlerTys &... Handlers) {
1040-
(void)std::initializer_list<int>{
1041-
(Handlers.enterStream(Owner, Parent, RecordTy), 0)...};
1042-
for (const auto &Field : Wrapper->fields()) {
1043-
QualType FieldTy = Field->getType();
1044-
// Required to initialize accessors inside streams.
1045-
if (Util::isSyclAccessorType(FieldTy))
1046-
KF_FOR_EACH(handleSyclAccessorType, Field, FieldTy);
1047-
}
1048-
(void)std::initializer_list<int>{
1049-
(Handlers.leaveStream(Owner, Parent, RecordTy), 0)...};
1050-
}
1051-
10521052
template <typename... HandlerTys>
10531053
void visitArrayElementImpl(const CXXRecordDecl *Owner, FieldDecl *ArrayField,
10541054
QualType ElementTy, uint64_t Index,
@@ -1123,12 +1123,9 @@ class KernelObjVisitor {
11231123
KF_FOR_EACH(handleSyclHalfType, Field, FieldTy);
11241124
else if (Util::isSyclSpecConstantType(FieldTy))
11251125
KF_FOR_EACH(handleSyclSpecConstantType, Field, FieldTy);
1126-
else if (Util::isSyclStreamType(FieldTy)) {
1127-
CXXRecordDecl *RD = FieldTy->getAsCXXRecordDecl();
1128-
// Handle accessors in stream class.
1126+
else if (Util::isSyclStreamType(FieldTy))
11291127
KF_FOR_EACH(handleSyclStreamType, Field, FieldTy);
1130-
visitStreamRecord(Owner, Field, RD, FieldTy, Handlers...);
1131-
} else if (FieldTy->isStructureOrClassType()) {
1128+
else if (FieldTy->isStructureOrClassType()) {
11321129
if (KF_FOR_EACH(handleStructType, Field, FieldTy)) {
11331130
CXXRecordDecl *RD = FieldTy->getAsCXXRecordDecl();
11341131
visitRecord(Owner, Field, RD, FieldTy, Handlers...);
@@ -1242,12 +1239,6 @@ class SyclKernelFieldHandlerBase {
12421239
virtual bool leaveStruct(const CXXRecordDecl *, FieldDecl *, QualType) {
12431240
return true;
12441241
}
1245-
virtual bool enterStream(const CXXRecordDecl *, FieldDecl *, QualType) {
1246-
return true;
1247-
}
1248-
virtual bool leaveStream(const CXXRecordDecl *, FieldDecl *, QualType) {
1249-
return true;
1250-
}
12511242
virtual bool enterStruct(const CXXRecordDecl *, const CXXBaseSpecifier &,
12521243
QualType) {
12531244
return true;
@@ -1695,18 +1686,6 @@ class SyclKernelDecompMarker : public SyclKernelFieldHandler {
16951686
return true;
16961687
}
16971688

1698-
// Stream is always decomposed (and whether it gets decomposed is handled in
1699-
// handleSyclStreamType), but we need a CollectionStack entry to capture the
1700-
// accessors that get handled.
1701-
bool enterStream(const CXXRecordDecl *, FieldDecl *, QualType) final {
1702-
CollectionStack.push_back(false);
1703-
return true;
1704-
}
1705-
bool leaveStream(const CXXRecordDecl *, FieldDecl *, QualType Ty) final {
1706-
CollectionStack.pop_back();
1707-
return true;
1708-
}
1709-
17101689
bool enterStruct(const CXXRecordDecl *, FieldDecl *, QualType) final {
17111690
CollectionStack.push_back(false);
17121691
return true;
@@ -1954,14 +1933,6 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler {
19541933
SemaRef.addSyclDeviceDecl(KernelDecl);
19551934
}
19561935

1957-
bool enterStream(const CXXRecordDecl *RD, FieldDecl *FD, QualType Ty) final {
1958-
return enterStruct(RD, FD, Ty);
1959-
}
1960-
1961-
bool leaveStream(const CXXRecordDecl *RD, FieldDecl *FD, QualType Ty) final {
1962-
return leaveStruct(RD, FD, Ty);
1963-
}
1964-
19651936
bool enterStruct(const CXXRecordDecl *, FieldDecl *, QualType) final {
19661937
++StructDepth;
19671938
return true;
@@ -2097,8 +2068,7 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler {
20972068
}
20982069

20992070
bool handleSyclStreamType(FieldDecl *FD, QualType FieldTy) final {
2100-
addParam(FD, FieldTy);
2101-
return true;
2071+
return handleSpecialType(FD, FieldTy);
21022072
}
21032073

21042074
bool handleSyclStreamType(const CXXRecordDecl *, const CXXBaseSpecifier &,
@@ -2417,15 +2387,6 @@ class SyclOptReportCreator : public SyclKernelFieldHandler {
24172387
}
24182388

24192389
bool handleSyclStreamType(FieldDecl *FD, QualType FieldTy) final {
2420-
// For the current implementation of stream class, the Visitor 'handles'
2421-
// stream argument and then visits each accessor field in stream. Therefore
2422-
// handleSpecialType in this case only adds a single argument for stream.
2423-
// The arguments corresponding to accessors in stream are handled in
2424-
// handleSyclAccessorType. The opt-report therefore does not diffrentiate
2425-
// between the accessors in streams and accessors captured by SYCL kernel.
2426-
// Once stream API is modified to use __init(), the visitor will no longer
2427-
// visit the stream object and opt-report output for stream class will be
2428-
// similar to that of other special types.
24292390
return handleSpecialType(
24302391
FD, FieldTy, KernelArgDescription(KernelArgDescription::Stream));
24312392
}
@@ -2803,6 +2764,13 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
28032764

28042765
const auto *RecordDecl = Ty->getAsCXXRecordDecl();
28052766
createSpecialMethodCall(RecordDecl, getInitMethodName(), BodyStmts);
2767+
CXXMethodDecl *FinalizeMethod =
2768+
getMethodByName(RecordDecl, FinalizeMethodName);
2769+
// A finalize-method is expected for stream class.
2770+
if (!FinalizeMethod && Util::isSyclStreamType(Ty))
2771+
SemaRef.Diag(FD->getLocation(), diag::err_sycl_expected_finalize_method);
2772+
else
2773+
createSpecialMethodCall(RecordDecl, FinalizeMethodName, FinalizeStmts);
28062774

28072775
removeFieldMemberExpr(FD, Ty);
28082776

@@ -2896,9 +2864,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
28962864
}
28972865

28982866
bool handleSyclStreamType(FieldDecl *FD, QualType Ty) final {
2899-
// Streams just get copied as a new init.
2900-
addSimpleFieldInit(FD, Ty);
2901-
return true;
2867+
return handleSpecialType(FD, Ty);
29022868
}
29032869

29042870
bool handleSyclStreamType(const CXXRecordDecl *, const CXXBaseSpecifier &BS,
@@ -2975,31 +2941,6 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
29752941
handleSpecialType(KernelHandlerArg->getType());
29762942
}
29772943

2978-
bool enterStream(const CXXRecordDecl *RD, FieldDecl *FD, QualType Ty) final {
2979-
++StructDepth;
2980-
// Add a dummy init expression to catch the accessor initializers.
2981-
const auto *StreamDecl = Ty->getAsCXXRecordDecl();
2982-
CollectionInitExprs.push_back(createInitListExpr(StreamDecl));
2983-
2984-
addFieldMemberExpr(FD, Ty);
2985-
return true;
2986-
}
2987-
2988-
bool leaveStream(const CXXRecordDecl *RD, FieldDecl *FD, QualType Ty) final {
2989-
--StructDepth;
2990-
// Stream requires that its 'init' calls happen after its accessors init
2991-
// calls, so add them here instead.
2992-
const auto *StreamDecl = Ty->getAsCXXRecordDecl();
2993-
2994-
createSpecialMethodCall(StreamDecl, getInitMethodName(), BodyStmts);
2995-
createSpecialMethodCall(StreamDecl, FinalizeMethodName, FinalizeStmts);
2996-
2997-
removeFieldMemberExpr(FD, Ty);
2998-
2999-
CollectionInitExprs.pop_back();
3000-
return true;
3001-
}
3002-
30032944
bool enterStruct(const CXXRecordDecl *RD, FieldDecl *FD, QualType Ty) final {
30042945
++StructDepth;
30052946
addCollectionInitListExpr(Ty->getAsCXXRecordDecl());
@@ -3312,7 +3253,7 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
33123253
}
33133254

33143255
bool handleSyclStreamType(FieldDecl *FD, QualType FieldTy) final {
3315-
addParam(FD, FieldTy, SYCLIntegrationHeader::kind_std_layout);
3256+
addParam(FD, FieldTy, SYCLIntegrationHeader::kind_stream);
33163257
return true;
33173258
}
33183259

@@ -3344,18 +3285,6 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
33443285
SYCLIntegrationHeader::kind_specialization_constants_buffer, 0);
33453286
}
33463287

3347-
bool enterStream(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
3348-
++StructDepth;
3349-
CurOffset += offsetOf(FD, Ty);
3350-
return true;
3351-
}
3352-
3353-
bool leaveStream(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
3354-
--StructDepth;
3355-
CurOffset -= offsetOf(FD, Ty);
3356-
return true;
3357-
}
3358-
33593288
bool enterStruct(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
33603289
++StructDepth;
33613290
CurOffset += offsetOf(FD, Ty);
@@ -4123,7 +4052,10 @@ void Sema::finalizeSYCLDelayedAnalysis(const FunctionDecl *Caller,
41234052
return;
41244053

41254054
// Diagnose if this is an undefined function and it is not a builtin.
4126-
if (!Callee->isDefined() && !Callee->getBuiltinID()) {
4055+
// Currently, there is an exception of "__failed_assertion" in libstdc++-11,
4056+
// this undefined function is used to trigger a compiling error.
4057+
if (!Callee->isDefined() && !Callee->getBuiltinID() &&
4058+
!isSYCLUndefinedAllowed(Callee, getSourceManager())) {
41274059
Diag(Loc, diag::err_sycl_restrict) << Sema::KernelCallUndefinedFunction;
41284060
Diag(Callee->getLocation(), diag::note_previous_decl) << Callee;
41294061
Diag(Caller->getLocation(), diag::note_called_by) << Caller;
@@ -4161,6 +4093,7 @@ static const char *paramKind2Str(KernelParamKind K) {
41614093
CASE(accessor);
41624094
CASE(std_layout);
41634095
CASE(sampler);
4096+
CASE(stream);
41644097
CASE(specialization_constants_buffer);
41654098
CASE(pointer);
41664099
}

clang/test/CodeGenSYCL/Inputs/sycl.hpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ class accessor {
181181
void __init(__attribute__((opencl_global)) dataT *Ptr, range<dimensions> AccessRange,
182182
range<dimensions> MemRange, id<dimensions> Offset) {}
183183
void __init_esimd(__attribute__((opencl_global)) dataT *Ptr) {}
184+
friend class stream;
184185
};
185186

186187
template <int dimensions, access::mode accessmode, access::target accesstarget>
@@ -411,10 +412,22 @@ class stream {
411412
public:
412413
stream(unsigned long BufferSize, unsigned long MaxStatementSize,
413414
handler &CGH) {}
415+
#ifdef __SYCL_DEVICE_ONLY__
416+
// Default constructor for objects later initialized with __init member.
417+
stream() = default;
418+
#endif
414419

415-
void __init() {}
420+
void __init(__attribute((opencl_global)) char *Ptr, range<1> AccessRange,
421+
range<1> MemRange, id<1> Offset, int _FlushBufferSize) {
422+
Acc.__init(Ptr, AccessRange, MemRange, Offset);
423+
FlushBufferSize = _FlushBufferSize;
424+
}
416425

417426
void __finalize() {}
427+
428+
private:
429+
cl::sycl::accessor<char, 1, cl::sycl::access::mode::read_write> Acc;
430+
int FlushBufferSize;
418431
};
419432

420433
template <typename T>

0 commit comments

Comments
 (0)