Skip to content

Commit c04fe4f

Browse files
author
Alexander Batashev
committed
Merge remote-tracking branch 'origin/sycl' into private/abatashe/image_api_test
* origin/sycl: [SYCL][NFC] Fix static code analysis concerns (intel#1283) [SYCL] Fix the test/basic_tests/buffer/subbuffer.cpp (intel#1277) [SYCL][CUDA] Implement the program kernel names query (intel#1248) [SYCL] Honor the LLVM_LIBDIR_SUFFIX variable at installation time (intel#1261) [SYCL][UX] Diagnostic for undefined device functions (intel#1026) [SYCL] Reverse reqd_work_group_size attribute (intel#1234) [SYCL] Rename project to oneAPI DPC++ Compiler (intel#1249) [SYCL][XPTI] Instrumentation of SYCL runtime with XPTI (intel#1129)
2 parents 50b081b + 93001bb commit c04fe4f

File tree

84 files changed

+5164
-1088
lines changed

Some content is hidden

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

84 files changed

+5164
-1088
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Contributing
22

33
## License
4-
Intel Project for LLVM* technology is licensed under the terms of the
4+
Intel Project for LLVM\* technology is licensed under the terms of the
55
Apache-2.0 with LLVM-exception license ([LICENSE.txt](llvm/LICENSE.TXT))
66
to ensure our ability to contribute this project to the LLVM project
77
under the same license.
@@ -70,11 +70,11 @@ commit automatically with `git commit -s`.
7070
### Development
7171

7272
- Create a personal fork of the project on GitHub
73-
- Use **sycl** branch as baseline for your changes
73+
- For the DPC++ Compiler project, use **sycl** branch as baseline for your
74+
changes. See [Get Started Guide](sycl/doc/GetStartedGuide.md).
7475
- Prepare your patch (follow
7576
[LLVM coding standards](https://llvm.org/docs/CodingStandards.html))
76-
- Build the project and run all tests (see
77-
[GetStartedWithSYCLCompiler.md](sycl/doc/GetStartedWithSYCLCompiler.md))
77+
- Build the project and run all tests
7878

7979
### Review and acceptance testing
8080

@@ -94,4 +94,8 @@ Project maintainers merge pull requests using one of the following options:
9494
- [Squash and merge] Used when there are multiple commits in the PR
9595
- Squashing is done to make sure that the project is buildable on any commit
9696
- [Create a merge commit] Used for LLVM pull-down PRs to preserve hashes of the
97-
commits pulled from the LLVM community repository
97+
commits pulled from the LLVM community repository
98+
99+
100+
*Other names and brands may be claimed as the property of others.
101+

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
# Intel Project for LLVM* technology
1+
# Intel Project for LLVM\* technology
22

33
## Introduction
44

55
Intel staging area for llvm.org contribution.
66
Home for Intel LLVM-based projects:
7-
- SYCL* Compiler and Runtimes - compiler and runtime libraries for SYCL ([https://www.khronos.org/sycl/](https://www.khronos.org/sycl/)). See **sycl** branch.
7+
- oneAPI Data Parallel C++ compiler - see **sycl** branch. More information on
8+
oneAPI and DPC++ is available at
9+
([https://www.oneapi.com/](https://www.oneapi.com/))
810

911
## License
1012
See [LICENSE.txt](sycl/LICENSE.TXT) for details.
1113

12-
1314
## Contributing
1415
See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
1516

1617
## Sub-projects Documentation
17-
- SYCL Compiler and Runtimes - See [GetStartedWithSYCLCompiler.md](sycl/doc/GetStartedWithSYCLCompiler.md)
18+
- oneAPI Data Parallel C++ compiler - See
19+
[GetStartedGuide.md](sycl/doc/GetStartedGuide.md)
1820

19-
*Other names and brands may be claimed as the property of others.
21+
## DPC++ extensions
2022

21-
## SYCL Extension Proposal Documents
23+
DPC++ is an open, cross-architecture language built upon the ISO C++ and Khronos
24+
SYCL\* standards. DPC++ extends these standards with a number of extensions,
25+
which can be found in [sycl/doc/extensions](sycl/doc/extensions) directory.
2226

23-
See [sycl/doc/extensions](sycl/doc/extensions)
27+
\*Other names and brands may be claimed as the property of others.
2428

buildbot/configure.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ def do_configure(args):
1010
llvm_dir = os.path.join(args.src_dir, "llvm")
1111
sycl_dir = os.path.join(args.src_dir, "sycl")
1212
spirv_dir = os.path.join(args.src_dir, "llvm-spirv")
13+
xpti_dir = os.path.join(args.src_dir, "xpti")
1314
ocl_header_dir = os.path.join(args.obj_dir, "OpenCL-Headers")
1415
icd_loader_lib = os.path.join(args.obj_dir, "OpenCL-ICD-Loader", "build")
1516
llvm_targets_to_build = 'X86'
16-
llvm_enable_projects = 'clang;llvm-spirv;sycl;opencl-aot'
17+
llvm_enable_projects = 'clang;llvm-spirv;sycl;opencl-aot;xpti'
1718
libclc_targets_to_build = ''
1819
sycl_build_pi_cuda = 'OFF'
1920
llvm_enable_assertions = 'ON'
@@ -44,9 +45,10 @@ def do_configure(args):
4445
"-DCMAKE_BUILD_TYPE={}".format(args.build_type),
4546
"-DLLVM_ENABLE_ASSERTIONS={}".format(llvm_enable_assertions),
4647
"-DLLVM_TARGETS_TO_BUILD={}".format(llvm_targets_to_build),
47-
"-DLLVM_EXTERNAL_PROJECTS=sycl;llvm-spirv;opencl-aot",
48+
"-DLLVM_EXTERNAL_PROJECTS=sycl;llvm-spirv;opencl-aot;xpti",
4849
"-DLLVM_EXTERNAL_SYCL_SOURCE_DIR={}".format(sycl_dir),
4950
"-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR={}".format(spirv_dir),
51+
"-DLLVM_EXTERNAL_XPTI_SOURCE_DIR={}".format(xpti_dir),
5052
"-DLLVM_ENABLE_PROJECTS={}".format(llvm_enable_projects),
5153
"-DLIBCLC_TARGETS_TO_BUILD={}".format(libclc_targets_to_build),
5254
"-DOpenCL_INCLUDE_DIR={}".format(ocl_header_dir),
@@ -57,6 +59,7 @@ def do_configure(args):
5759
"-DCMAKE_INSTALL_PREFIX={}".format(install_dir),
5860
"-DSYCL_INCLUDE_TESTS=ON", # Explicitly include all kinds of SYCL tests.
5961
"-DLLVM_ENABLE_DOXYGEN={}".format(llvm_enable_doxygen),
62+
"-DSYCL_ENABLE_XPTI_TRACING=ON", # Explicitly turn on XPTI tracing
6063
llvm_dir
6164
]
6265

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10642,7 +10642,9 @@ def err_sycl_restrict : Error<
1064210642
"|allocate storage"
1064310643
"|use inline assembly"
1064410644
"|call a dllimport function"
10645-
"|call a variadic function}0">;
10645+
"|call a variadic function"
10646+
"|call an undefined function without SYCL_EXTERNAL attribute"
10647+
"}0">;
1064610648
def err_sycl_virtual_types : Error<
1064710649
"No class with a vtable can be used in a SYCL kernel or any code included in the kernel">;
1064810650
def note_sycl_used_here : Note<"used here">;

clang/include/clang/Sema/Sema.h

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12298,11 +12298,13 @@ class Sema final {
1229812298
KernelAllocateStorage,
1229912299
KernelUseAssembly,
1230012300
KernelCallDllimportFunction,
12301-
KernelCallVariadicFunction
12302-
};
12301+
KernelCallVariadicFunction,
12302+
KernelCallUndefinedFunction
12303+
};
12304+
1230312305
bool isKnownGoodSYCLDecl(const Decl *D);
1230412306
void ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc, MangleContext &MC);
12305-
void MarkDevice(void);
12307+
void MarkDevice();
1230612308

1230712309
/// Creates a DeviceDiagBuilder that emits the diagnostic if the current
1230812310
/// context is "used as device code".
@@ -12323,10 +12325,25 @@ class Sema final {
1232312325
/// SYCLDiagIfDeviceCode(Loc, diag::err_thread_unsupported);
1232412326
DeviceDiagBuilder SYCLDiagIfDeviceCode(SourceLocation Loc, unsigned DiagID);
1232512327

12326-
/// Checks if Callee function is a device function and emits
12327-
/// diagnostics if it is known that it is a device function, adds this
12328-
/// function to the DeviceCallGraph otherwise.
12329-
void checkSYCLDeviceFunction(SourceLocation Loc, FunctionDecl *Callee);
12328+
/// Check whether we're allowed to call Callee from the current context.
12329+
///
12330+
/// - If the call is never allowed in a semantically-correct program
12331+
/// emits an error and returns false.
12332+
///
12333+
/// - If the call is allowed in semantically-correct programs, but only if
12334+
/// it's never codegen'ed, creates a deferred diagnostic to be emitted if
12335+
/// and when the caller is codegen'ed, and returns true.
12336+
///
12337+
/// - Otherwise, returns true without emitting any diagnostics.
12338+
///
12339+
/// Adds Callee to DeviceCallGraph if we don't know if its caller will be
12340+
/// codegen'ed yet.
12341+
bool checkSYCLDeviceFunction(SourceLocation Loc, FunctionDecl *Callee);
12342+
12343+
/// Emit diagnostic that can't be emitted with deferred diagnostics mechanism.
12344+
/// At this step we imply that all device functions are marked with
12345+
/// sycl_device attribute.
12346+
void finalizeSYCLDelayedAnalysis();
1233012347
};
1233112348

1233212349
template <typename AttrType>

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4124,6 +4124,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
41244124
} else if (IsSYCL) {
41254125
// Ensure the default version in SYCL mode is 1.2.1
41264126
CmdArgs.push_back("-sycl-std=1.2.1");
4127+
// The user had not pass SYCL version, thus we'll employ no-sycl-strict
4128+
// to allow address-space unqualified pointers in function params/return
4129+
// along with marking the same function with explicit SYCL_EXTERNAL
4130+
CmdArgs.push_back("-Wno-sycl-strict");
41274131
}
41284132

41294133
if (IsOpenMPDevice) {

clang/lib/Sema/Sema.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ void Sema::ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind) {
974974
if (SyclIntHeader != nullptr)
975975
SyclIntHeader->emit(getLangOpts().SYCLIntHeader);
976976
MarkDevice();
977+
finalizeSYCLDelayedAnalysis();
977978
}
978979

979980
// Finalize analysis of OpenMP-specific constructs.

clang/lib/Sema/SemaDecl.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18016,6 +18016,12 @@ Decl *Sema::getObjCDeclContext() const {
1801618016
}
1801718017

1801818018
Sema::FunctionEmissionStatus Sema::getEmissionStatus(FunctionDecl *FD) {
18019+
// Due to SYCL functions are template we check if they have appropriate
18020+
// attribute prior to checking if it is a template
18021+
if (LangOpts.SYCLIsDevice &&
18022+
(FD->hasAttr<SYCLDeviceAttr>() || FD->hasAttr<SYCLKernelAttr>()))
18023+
return FunctionEmissionStatus::Emitted;
18024+
1801918025
// Templates are emitted when they're instantiated.
1802018026
if (FD->isDependentContext())
1802118027
return FunctionEmissionStatus::TemplateDiscarded;
@@ -18080,6 +18086,23 @@ Sema::FunctionEmissionStatus Sema::getEmissionStatus(FunctionDecl *FD) {
1808018086
return FunctionEmissionStatus::Emitted;
1808118087
}
1808218088

18089+
if (getLangOpts().SYCLIsDevice) {
18090+
if (!FD->hasAttr<SYCLDeviceAttr>() && !FD->hasAttr<SYCLKernelAttr>())
18091+
return FunctionEmissionStatus::Unknown;
18092+
18093+
// Check whether this function is externally visible -- if so, it's
18094+
// known-emitted.
18095+
//
18096+
// We have to check the GVA linkage of the function's *definition* -- if we
18097+
// only have a declaration, we don't know whether or not the function will
18098+
// be emitted, because (say) the definition could include "inline".
18099+
FunctionDecl *Def = FD->getDefinition();
18100+
18101+
if (Def &&
18102+
!isDiscardableGVALinkage(getASTContext().GetGVALinkageForFunction(Def)))
18103+
return FunctionEmissionStatus::Emitted;
18104+
}
18105+
1808318106
// Otherwise, the function is known-emitted if it's in our set of
1808418107
// known-emitted functions.
1808518108
return (DeviceKnownEmittedFns.count(FD) > 0)

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,7 +2895,7 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr,
28952895
if (const auto *A = D->getAttr<SYCLIntelMaxGlobalWorkDimAttr>())
28962896
if (A->getNumber() == 0)
28972897
Result &= checkZeroDim(A, WGSize[0], WGSize[1], WGSize[2],
2898-
/*ReverseAttrs=*/ true);
2898+
/*ReverseAttrs=*/true);
28992899

29002900
if (const auto *A = D->getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
29012901
if (!(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() &&
@@ -2935,14 +2935,17 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29352935
}
29362936
}
29372937

2938-
if (!checkWorkGroupSizeValues(S, D, AL, WGSize))
2939-
return;
2940-
2938+
// For a SYCLDevice WorkGroupAttr arguments are reversed
2939+
if (S.getLangOpts().SYCLIsDevice) {
2940+
std::swap(WGSize[0], WGSize[2]);
2941+
}
29412942
WorkGroupAttr *Existing = D->getAttr<WorkGroupAttr>();
2942-
if (Existing && !(Existing->getXDim() == WGSize[0] &&
2943-
Existing->getYDim() == WGSize[1] &&
2944-
Existing->getZDim() == WGSize[2]))
2943+
if (Existing &&
2944+
!(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] &&
2945+
Existing->getZDim() == WGSize[2]))
29452946
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
2947+
if (!checkWorkGroupSizeValues(S, D, AL, WGSize))
2948+
return;
29462949

29472950
D->addAttr(::new (S.Context)
29482951
WorkGroupAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2]));

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14684,8 +14684,9 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
1468414684
MarkFunctionReferenced(ConstructLoc, Constructor);
1468514685
if (getLangOpts().CUDA && !CheckCUDACall(ConstructLoc, Constructor))
1468614686
return ExprError();
14687-
if (getLangOpts().SYCLIsDevice)
14688-
checkSYCLDeviceFunction(ConstructLoc, Constructor);
14687+
if (getLangOpts().SYCLIsDevice &&
14688+
!checkSYCLDeviceFunction(ConstructLoc, Constructor))
14689+
return ExprError();
1468914690

1469014691
return CXXConstructExpr::Create(
1469114692
Context, DeclInitType, ConstructLoc, Constructor, Elidable,

0 commit comments

Comments
 (0)