Skip to content

Commit 74999cf

Browse files
committed
Merge branch 'sycl' into pietro/prop_ncpu_r_or_nd
2 parents 1d86faa + 9b9e5de commit 74999cf

File tree

424 files changed

+4663
-3670
lines changed

Some content is hidden

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

424 files changed

+4663
-3670
lines changed

.github/CODEOWNERS

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ sycl/include/sycl/detail/ur.hpp @intel/unified-runtime-reviewers
4141
sycl/source/detail/posix_ur.cpp @intel/unified-runtime-reviewers
4242
sycl/source/detail/ur.cpp @intel/unified-runtime-reviewers
4343
sycl/source/detail/windows_ur.cpp @intel/unified-runtime-reviewers
44-
sycl/test-e2e/Plugin/ @intel/unified-runtime-reviewers
44+
sycl/test-e2e/Adapters/ @intel/unified-runtime-reviewers
4545

4646
# Win Proxy Loader
47-
sycl/pi_win_proxy_loader @intel/llvm-reviewers-runtime
48-
sycl/test-e2e/Plugin/dll-detach-order.cpp @intel/llvm-reviewers-runtime
47+
sycl/ur_win_proxy_loader @intel/llvm-reviewers-runtime
48+
sycl/test-e2e/Adapters/dll-detach-order.cpp @intel/llvm-reviewers-runtime
4949

5050
# CUDA specific runtime implementations
5151
sycl/include/sycl/ext/oneapi/experimental/cuda/ @intel/llvm-reviewers-cuda
@@ -169,12 +169,12 @@ sycl/test-e2e/LLVMIntrinsicLowering/ @intel/dpcpp-spirv-reviewers
169169

170170
# Sanitizer
171171
clang/lib/Driver/SanitizerArgs.cpp @intel/dpcpp-sanitizers-review
172-
libdevice/sanitizer_utils.cpp @intel/dpcpp-sanitizers-review
173-
libdevice/include/asan_libdevice.hpp @intel/dpcpp-sanitizers-review
174-
libdevice/include/sanitizer_utils.hpp @intel/dpcpp-sanitizers-review
172+
libdevice/include/asan_rtl.hpp @intel/dpcpp-sanitizers-review
173+
libdevice/include/sanitizer_defs.hpp @intel/dpcpp-sanitizers-review
174+
libdevice/sanitizer/ @intel/dpcpp-sanitizers-review
175+
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h @intel/dpcpp-sanitizers-review
176+
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h @intel/dpcpp-sanitizers-review
177+
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h @intel/dpcpp-sanitizers-review
175178
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @intel/dpcpp-sanitizers-review
176-
sycl/test-e2e/AddressSanitizer/ @intel/dpcpp-sanitizers-review
177179
llvm/test/Instrumentation/AddressSanitizer/ @intel/dpcpp-sanitizers-review
178-
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h @intel/dpcpp-sanitizers-review
179-
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h @intel/dpcpp-sanitizers-review
180-
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h @intel/dpcpp-sanitizers-review
180+
sycl/test-e2e/AddressSanitizer/ @intel/dpcpp-sanitizers-review

.github/workflows/sycl-linux-precommit.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ jobs:
8080
image: ghcr.io/intel/llvm/ubuntu2204_build:latest
8181
image_options: -u 1001 --gpus all --cap-add SYS_ADMIN
8282
target_devices: ext_oneapi_cuda:gpu
83+
- name: AMD/HIP
84+
runner: '["Linux", "amdgpu"]'
85+
image: ghcr.io/intel/llvm/ubuntu2204_build:latest
86+
image_options: -u 1001 --device=/dev/dri --device=/dev/kfd
87+
target_devices: ext_oneapi_hip:gpu
88+
reset_intel_gpu: false
8389
- name: Intel
8490
runner: '["Linux", "gen12"]'
8591
image: ghcr.io/intel/llvm/ubuntu2204_intel_drivers:latest

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To contribute:
5858
- [The seven rules of a great Git commit message](https://cbea.ms/git-commit)
5959
are recommended read and follow.
6060
- To a reasonable extent, title tags can be used to signify the component
61-
changed, e.g.: `[PI]`, `[CUDA]`, `[Doc]`.
61+
changed, e.g.: `[UR]`, `[CUDA]`, `[Doc]`.
6262
- Create a pull request (PR) for your changes following
6363
[Creating a pull request instructions](https://help.github.com/articles/creating-a-pull-request/).
6464
- Make sure PR has a good description explaining all of the changes made,

buildbot/configure.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def do_configure(args):
6969
if sys.platform != "darwin":
7070
sycl_enabled_backends.append("level_zero")
7171

72-
# lld is needed on Windows or for the HIP plugin on AMD
72+
# lld is needed on Windows or for the HIP adapter on AMD
7373
if platform.system() == "Windows" or (args.hip and args.hip_platform == "AMD"):
7474
llvm_enable_projects += ";lld"
7575

@@ -152,8 +152,8 @@ def do_configure(args):
152152
libclc_targets_to_build += libclc_nvidia_target_names
153153
libclc_gen_remangled_variants = "ON"
154154

155-
if args.enable_plugin:
156-
sycl_enabled_backends += args.enable_plugin
155+
if args.enable_backends:
156+
sycl_enabled_backends += args.enable_backends
157157

158158
if args.disable_preview_lib:
159159
sycl_preview_lib = "OFF"
@@ -374,7 +374,9 @@ def main():
374374
parser.add_argument(
375375
"--ci-defaults", action="store_true", help="Enable default CI parameters"
376376
)
377-
parser.add_argument("--enable-plugin", action="append", help="Enable SYCL plugin")
377+
parser.add_argument(
378+
"--enable-backends", action="append", help="Enable SYCL backend"
379+
)
378380
parser.add_argument(
379381
"--disable-preview-lib",
380382
action="store_true",

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,9 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
17891789
if (SyclOptReport.HasOptReportInfo(FD)) {
17901790
llvm::OptimizationRemarkEmitter ORE(Fn);
17911791
for (auto ORI : llvm::enumerate(SyclOptReport.GetInfo(FD))) {
1792+
// Temporarily apply arg location to ensure SourceLocToDebugLoc
1793+
// picks up the expected file.
1794+
ApplyDebugLocation TempApplyLoc(*this, ORI.value().KernelArgLoc);
17921795
llvm::DiagnosticLocation DL =
17931796
SourceLocToDebugLoc(ORI.value().KernelArgLoc);
17941797
StringRef NameInDesc = ORI.value().KernelArgDescName;

clang/lib/Driver/OffloadBundler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,12 +687,12 @@ class ObjectFileHandler final : public FileHandler {
687687
if (Error Err = Symbol.printName(NameOS))
688688
return std::move(Err);
689689

690-
// If we are dealing with a bitcode file do not add special globals
691-
// llvm.used and llvm.compiler.used and __AsanDeviceGlobalMetadata to
690+
// If we are dealing with a bitcode file do not add special globals to
692691
// the list of defined symbols.
693692
if (SF->isIR() &&
694693
(Name == "llvm.used" || Name == "llvm.compiler.used" ||
695-
Name == "__AsanDeviceGlobalMetadata"))
694+
Name == "__AsanDeviceGlobalMetadata" ||
695+
Name == "__AsanKernelMetadata"))
696696
continue;
697697

698698
// Add symbol name with the target prefix to the buffer.

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,9 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
11971197

11981198
CmdArgs.push_back("-mllvm");
11991199
CmdArgs.push_back("-asan-mapping-scale=4");
1200+
1201+
addSpecialCaseListOpt(Args, CmdArgs,
1202+
"-fsanitize-ignorelist=", UserIgnorelistFiles);
12001203
}
12011204
return;
12021205
}

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -658,43 +658,44 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
658658
addLibraries(SYCLDeviceAnnotationLibs);
659659

660660
#if !defined(_WIN32)
661+
std::string SanitizeVal;
661662
size_t sanitizer_lib_idx = getSingleBuildTarget();
662663
if (Arg *A = Args.getLastArg(options::OPT_fsanitize_EQ,
663664
options::OPT_fno_sanitize_EQ)) {
664665
if (A->getOption().matches(options::OPT_fsanitize_EQ) &&
665-
A->getValues().size() == 1) {
666-
std::string SanitizeVal = A->getValue();
667-
if (SanitizeVal == "address")
668-
addSingleLibrary(SYCLDeviceAsanLibs[sanitizer_lib_idx]);
669-
}
666+
A->getValues().size() == 1)
667+
SanitizeVal = A->getValue();
670668
} else {
671669
// User can pass -fsanitize=address to device compiler via
672670
// -Xsycl-target-frontend, sanitize device library must be
673671
// linked with user's device image if so.
674-
bool IsDeviceAsanEnabled = false;
675-
auto SyclFEArg = Args.getAllArgValues(options::OPT_Xsycl_frontend);
676-
IsDeviceAsanEnabled = (std::count(SyclFEArg.begin(), SyclFEArg.end(),
677-
"-fsanitize=address") > 0);
678-
if (!IsDeviceAsanEnabled) {
679-
auto SyclFEArgEq = Args.getAllArgValues(options::OPT_Xsycl_frontend_EQ);
680-
IsDeviceAsanEnabled = (std::count(SyclFEArgEq.begin(), SyclFEArgEq.end(),
681-
"-fsanitize=address") > 0);
682-
}
683-
684-
// User can also enable asan for SYCL device via -Xarch_device option.
685-
if (!IsDeviceAsanEnabled) {
686-
auto DeviceArchVals = Args.getAllArgValues(options::OPT_Xarch_device);
687-
for (auto DArchVal : DeviceArchVals) {
688-
if (DArchVal.find("-fsanitize=address") != std::string::npos) {
689-
IsDeviceAsanEnabled = true;
690-
break;
691-
}
672+
std::vector<std::string> EnabledDeviceSanitizers;
673+
674+
// NOTE: "-fsanitize=" applies to all device targets
675+
auto SyclFEArgVals = Args.getAllArgValues(options::OPT_Xsycl_frontend);
676+
auto SyclFEEQArgVals = Args.getAllArgValues(options::OPT_Xsycl_frontend_EQ);
677+
auto ArchDeviceVals = Args.getAllArgValues(options::OPT_Xarch_device);
678+
679+
std::vector<std::string> ArgVals(
680+
SyclFEArgVals.size() + SyclFEEQArgVals.size() + ArchDeviceVals.size());
681+
ArgVals.insert(ArgVals.end(), SyclFEArgVals.begin(), SyclFEArgVals.end());
682+
ArgVals.insert(ArgVals.end(), SyclFEEQArgVals.begin(),
683+
SyclFEEQArgVals.end());
684+
ArgVals.insert(ArgVals.end(), ArchDeviceVals.begin(), ArchDeviceVals.end());
685+
686+
// Driver will report error if address sanitizer and memory sanitizer are
687+
// both enabled, so we only need to check first one here.
688+
for (const std::string &Arg : ArgVals) {
689+
if (Arg.find("-fsanitize=address") != std::string::npos) {
690+
SanitizeVal = "address";
691+
break;
692692
}
693693
}
694-
695-
if (IsDeviceAsanEnabled)
696-
addSingleLibrary(SYCLDeviceAsanLibs[sanitizer_lib_idx]);
697694
}
695+
696+
if (SanitizeVal == "address")
697+
addSingleLibrary(SYCLDeviceAsanLibs[sanitizer_lib_idx]);
698+
698699
#endif
699700

700701
if (isNativeCPU)
@@ -1617,6 +1618,23 @@ static std::vector<OptSpecifier> getUnsupportedOpts(void) {
16171618
return UnsupportedOpts;
16181619
}
16191620

1621+
// Currently supported options by SYCL NativeCPU device compilation
1622+
static inline bool SupportedByNativeCPU(const SYCLToolChain &TC,
1623+
const OptSpecifier &Opt) {
1624+
if (!TC.IsSYCLNativeCPU)
1625+
return false;
1626+
1627+
switch (Opt.getID()) {
1628+
case options::OPT_fcoverage_mapping:
1629+
case options::OPT_fno_coverage_mapping:
1630+
case options::OPT_fprofile_instr_generate:
1631+
case options::OPT_fprofile_instr_generate_EQ:
1632+
case options::OPT_fno_profile_instr_generate:
1633+
return true;
1634+
}
1635+
return false;
1636+
}
1637+
16201638
SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
16211639
const ToolChain &HostTC, const ArgList &Args)
16221640
: ToolChain(D, Triple, Args), HostTC(HostTC),
@@ -1628,6 +1646,9 @@ SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
16281646
// Diagnose unsupported options only once.
16291647
for (OptSpecifier Opt : getUnsupportedOpts()) {
16301648
if (const Arg *A = Args.getLastArg(Opt)) {
1649+
// Native CPU can support options unsupported by other targets.
1650+
if (SupportedByNativeCPU(*this, Opt))
1651+
continue;
16311652
// All sanitizer options are not currently supported, except
16321653
// AddressSanitizer
16331654
if (A->getOption().getID() == options::OPT_fsanitize_EQ &&
@@ -1668,6 +1689,9 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
16681689
bool Unsupported = false;
16691690
for (OptSpecifier UnsupportedOpt : getUnsupportedOpts()) {
16701691
if (Opt.matches(UnsupportedOpt)) {
1692+
// NativeCPU should allow most normal cpu options.
1693+
if (SupportedByNativeCPU(*this, Opt.getID()))
1694+
continue;
16711695
if (Opt.getID() == options::OPT_fsanitize_EQ &&
16721696
A->getValues().size() == 1) {
16731697
std::string SanitizeVal = A->getValue();

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3625,8 +3625,11 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
36253625
BodyStmts.insert(BodyStmts.end(), FinalizeStmts.begin(),
36263626
FinalizeStmts.end());
36273627

3628+
SourceLocation LL = NewBody ? NewBody->getBeginLoc() : SourceLocation();
3629+
SourceLocation LR = NewBody ? NewBody->getEndLoc() : SourceLocation();
3630+
36283631
return CompoundStmt::Create(SemaSYCLRef.getASTContext(), BodyStmts,
3629-
FPOptionsOverride(), {}, {});
3632+
FPOptionsOverride(), LL, LR);
36303633
}
36313634

36323635
void annotateHierarchicalParallelismAPICalls() {
@@ -6969,6 +6972,7 @@ bool SYCLIntegrationFooter::emit(raw_ostream &OS) {
69696972
Policy.adjustForCPlusPlusFwdDecl();
69706973
Policy.SuppressTypedefs = true;
69716974
Policy.SuppressUnwrittenScope = true;
6975+
Policy.PrintCanonicalTypes = true;
69726976

69736977
llvm::SmallSet<const VarDecl *, 8> Visited;
69746978
bool EmittedFirstSpecConstant = false;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -fsycl-int-footer=%t.footer.h -emit-llvm %s -o -
2+
// RUN: FileCheck -input-file=%t.footer.h %s --check-prefix=CHECK-FOOTER
3+
4+
// This test checks that integration footer is emitted correctly when a
5+
// device_global has an explicit template specialization in template arguments.
6+
7+
#include "sycl.hpp"
8+
9+
namespace sycl {
10+
template <typename T> struct X {};
11+
template <> struct X<int> {};
12+
namespace detail {
13+
struct Y {};
14+
} // namespace detail
15+
template <> struct X<detail::Y> {};
16+
} // namespace sycl
17+
18+
using namespace sycl;
19+
template <typename T, typename = X<detail::Y>> struct Arg1 { T val; };
20+
21+
using namespace sycl::ext::oneapi;
22+
template <typename properties_t>
23+
device_global<properties_t> dev_global;
24+
25+
SYCL_EXTERNAL auto foo() {
26+
(void)dev_global<Arg1<int>>;
27+
}
28+
29+
// CHECK-FOOTER: __sycl_device_global_registration::__sycl_device_global_registration() noexcept {
30+
// CHECK-FOOTER-NEXT: device_global_map::add((void *)&::dev_global<Arg1<int, sycl::X<sycl::detail::Y>>>, "_Z10dev_globalI4Arg1IiN4sycl1XINS1_6detail1YEEEEE");
31+
// CHECK-FOOTER-NEXT: }
32+
// CHECK-FOOTER-NEXT: } // namespace (unnamed)

0 commit comments

Comments
 (0)