Skip to content

Commit 7596ad8

Browse files
committed
Merge branch 'sycl' into skip-integration-header-ff-kernels
2 parents bc9d7bb + 3dee3c7 commit 7596ad8

File tree

304 files changed

+3863
-1686
lines changed

Some content is hidden

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

304 files changed

+3863
-1686
lines changed

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ jobs:
5757

5858
# Upload the results to GitHub's code scanning dashboard.
5959
- name: "Upload to code-scanning"
60-
uses: github/codeql-action/upload-sarif@e2b3eafc8d227b0241d48be5f425d47c2d750a13 # v3.26.10
60+
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
6161
with:
6262
sarif_file: results.sarif

.github/workflows/sycl-macos-build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ permissions: read-all
2424
jobs:
2525
build:
2626
name: Build
27-
runs-on: macos-12
27+
runs-on: macos-13
2828
env:
2929
CCACHE_DIR: $GITHUB_WORKSPACE/build_cache_${{ inputs.build_cache_suffix }}
3030
CCACHE_MAXSIZE: ${{ inputs.build_cache_size }}

.github/workflows/sycl-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ jobs:
198198
echo "TAG=$(date +'%Y-%m-%d')-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
199199
fi
200200
- name: Upload binaries
201-
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
201+
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8
202202
with:
203203
files: |
204204
sycl_linux.tar.gz

clang/include/clang/Driver/Driver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,9 @@ class Driver {
586586
/// @name Helper Methods
587587
/// @{
588588

589-
/// MakeSYCLDeviceTriple - Returns the SYCL device triple for the
589+
/// getSYCLDeviceTriple - Returns the SYCL device triple for the
590590
/// specified subarch
591-
llvm::Triple MakeSYCLDeviceTriple(StringRef TargetArch = "spir64") const;
591+
llvm::Triple getSYCLDeviceTriple(StringRef TargetArch = "spir64") const;
592592

593593
/// PrintActions - Print the list of actions.
594594
void PrintActions(const Compilation &C) const;

clang/include/clang/Driver/ToolChain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ class ToolChain {
781781
virtual void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
782782
llvm::opt::ArgStringList &CC1Args) const;
783783

784-
/// Add arguments to use SYCL specific includes.
784+
/// Add arguments to use system-specific SYCL includes.
785785
virtual void AddSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
786786
llvm::opt::ArgStringList &CC1Args) const;
787787

clang/lib/Driver/Compilation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static bool ActionFailed(const Action *A,
344344

345345
// CUDA/HIP/SYCL can have the same input source code compiled multiple times
346346
// so do not compile again if there are already failures. It is OK to abort
347-
// the CUDA pipeline on errors.
347+
// the CUDA/HIP/SYCL pipeline on errors.
348348
if (A->isOffloading(Action::OFK_Cuda) || A->isOffloading(Action::OFK_HIP) ||
349349
A->isOffloading(Action::OFK_SYCL))
350350
return true;

clang/lib/Driver/Driver.cpp

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ static bool isValidSYCLTriple(llvm::Triple T) {
834834
}
835835

836836
static const char *getDefaultSYCLArch(Compilation &C) {
837+
// If -fsycl is supplied we will assume SPIR-V
837838
if (C.getDefaultToolChain().getTriple().getArch() == llvm::Triple::x86)
838839
return "spir";
839840
return "spir64";
@@ -847,7 +848,7 @@ static bool addSYCLDefaultTriple(Compilation &C,
847848
if (C.getInputArgs().hasArg(options::OPT_fsycl_force_target_EQ))
848849
return false;
849850
llvm::Triple DefaultTriple =
850-
C.getDriver().MakeSYCLDeviceTriple(getDefaultSYCLArch(C));
851+
C.getDriver().getSYCLDeviceTriple(getDefaultSYCLArch(C));
851852
for (const auto &SYCLTriple : SYCLTriples) {
852853
if (SYCLTriple == DefaultTriple)
853854
return false;
@@ -1079,22 +1080,21 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
10791080
// We need to generate a SYCL toolchain if the user specified -fsycl.
10801081
// If -fsycl is supplied without any of these we will assume SPIR-V.
10811082
// Use of -fsycl-device-only overrides -fsycl.
1082-
bool HasValidSYCLRuntime =
1083-
C.getInputArgs().hasFlag(options::OPT_fsycl, options::OPT_fno_sycl,
1084-
false) ||
1085-
C.getInputArgs().hasArg(options::OPT_fsycl_device_only);
1083+
bool IsSYCL = C.getInputArgs().hasFlag(options::OPT_fsycl,
1084+
options::OPT_fno_sycl, false) ||
1085+
C.getInputArgs().hasArg(options::OPT_fsycl_device_only);
10861086

10871087
Arg *SYCLfpga = C.getInputArgs().getLastArg(options::OPT_fintelfpga);
10881088

10891089
// Make -fintelfpga flag imply -fsycl.
1090-
if (SYCLfpga && !HasValidSYCLRuntime)
1091-
HasValidSYCLRuntime = true;
1090+
if (SYCLfpga && !IsSYCL)
1091+
IsSYCL = true;
10921092

10931093
// A mechanism for retrieving SYCL-specific options, erroring out
10941094
// if SYCL offloading wasn't enabled prior to that
10951095
auto getArgRequiringSYCLRuntime = [&](OptSpecifier OptId) -> Arg * {
10961096
Arg *SYCLArg = C.getInputArgs().getLastArg(OptId);
1097-
if (SYCLArg && !HasValidSYCLRuntime) {
1097+
if (SYCLArg && !IsSYCL) {
10981098
Diag(clang::diag::err_drv_expecting_fsycl_with_sycl_opt)
10991099
// Dropping the '=' symbol, which would otherwise pollute
11001100
// the diagnostics for the most of options
@@ -1123,7 +1123,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
11231123
<< "-fsycl-host-compiler";
11241124

11251125
auto argSYCLIncompatible = [&](OptSpecifier OptId) {
1126-
if (!HasValidSYCLRuntime)
1126+
if (!IsSYCL)
11271127
return;
11281128
if (Arg *IncompatArg = C.getInputArgs().getLastArg(OptId))
11291129
Diag(clang::diag::err_drv_argument_not_allowed_with)
@@ -1182,7 +1182,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
11821182
getArgRequiringSYCLRuntime(options::OPT_fsycl_force_target_EQ);
11831183
if (SYCLForceTarget) {
11841184
StringRef Val(SYCLForceTarget->getValue());
1185-
llvm::Triple TT(MakeSYCLDeviceTriple(Val));
1185+
llvm::Triple TT(getSYCLDeviceTriple(Val));
11861186
if (!isValidSYCLTriple(TT))
11871187
Diag(clang::diag::err_drv_invalid_sycl_target) << Val;
11881188
}
@@ -1240,7 +1240,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
12401240
continue;
12411241
}
12421242

1243-
llvm::Triple DeviceTriple(MakeSYCLDeviceTriple(UserTargetName));
1243+
llvm::Triple DeviceTriple(getSYCLDeviceTriple(UserTargetName));
12441244
if (!isValidSYCLTriple(DeviceTriple)) {
12451245
Diag(clang::diag::err_drv_invalid_sycl_target) << Val;
12461246
continue;
@@ -1271,7 +1271,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
12711271
}
12721272

12731273
// Make sure we don't have a duplicate triple.
1274-
std::string NormalizedName = MakeSYCLDeviceTriple(Val).normalize();
1274+
std::string NormalizedName = getSYCLDeviceTriple(Val).normalize();
12751275
auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
12761276
if (Duplicate != FoundNormalizedTriples.end()) {
12771277
Diag(clang::diag::warn_drv_sycl_offload_target_duplicate)
@@ -1303,9 +1303,8 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
13031303
// Create a toolchain for each valid triple.
13041304
// We do not support SYCL offloading if any of the inputs is a
13051305
// .cu (for CUDA type) or .hip (for HIP type) file.
1306-
else if (HasValidSYCLRuntime &&
1307-
C.getInputArgs().hasArg(options::OPT_offload_arch_EQ) && !IsHIP &&
1308-
!IsCuda) {
1306+
else if (IsSYCL && C.getInputArgs().hasArg(options::OPT_offload_arch_EQ) &&
1307+
!IsHIP && !IsCuda) {
13091308
// SYCL offloading to AOT Targets with '--offload-arch'
13101309
// is currently enabled only with '--offload-new-driver' option.
13111310
// Emit a diagnostic if '--offload-arch' is invoked without
@@ -1352,7 +1351,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
13521351
getProcessorFromTargetID(*AMDTriple, Arch)))) {
13531352
DerivedArchs[AMDTriple->getTriple()].insert(Arch);
13541353
} else if (IsSYCLSupportedIntelCPUArch(StringToOffloadArchSYCL(Arch))) {
1355-
DerivedArchs[MakeSYCLDeviceTriple("spir64_x86_64").getTriple()].insert(
1354+
DerivedArchs[getSYCLDeviceTriple("spir64_x86_64").getTriple()].insert(
13561355
Arch);
13571356
} else if (IsSYCLSupportedIntelGPUArch(StringToOffloadArchSYCL(Arch))) {
13581357
StringRef IntelGPUArch;
@@ -1363,7 +1362,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
13631362
// offloading to Intel GPUs and the corresponding '-device' value passed
13641363
// to OCLOC.
13651364
IntelGPUArch = mapIntelGPUArchName(Arch).data();
1366-
DerivedArchs[MakeSYCLDeviceTriple("spir64_gen").getTriple()].insert(
1365+
DerivedArchs[getSYCLDeviceTriple("spir64_gen").getTriple()].insert(
13671366
IntelGPUArch);
13681367
} else {
13691368
Diag(clang::diag::err_drv_invalid_sycl_target) << Arch;
@@ -1381,7 +1380,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
13811380
SYCLTriples.insert(TripleAndArchs.first());
13821381

13831382
for (const auto &Val : SYCLTriples) {
1384-
llvm::Triple SYCLTargetTriple(MakeSYCLDeviceTriple(Val.getKey()));
1383+
llvm::Triple SYCLTargetTriple(getSYCLDeviceTriple(Val.getKey()));
13851384
std::string NormalizedName = SYCLTargetTriple.normalize();
13861385

13871386
// Make sure we don't have a duplicate triple.
@@ -1403,12 +1402,12 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
14031402
} else {
14041403
// If -fsycl is supplied without -fsycl-targets we will assume SPIR-V.
14051404
// For -fsycl-device-only, we also setup the implied triple as needed.
1406-
if (HasValidSYCLRuntime) {
1405+
if (IsSYCL) {
14071406
StringRef SYCLTargetArch = getDefaultSYCLArch(C);
14081407
if (SYCLfpga)
14091408
// Triple for -fintelfpga is spir64_fpga.
14101409
SYCLTargetArch = "spir64_fpga";
1411-
UniqueSYCLTriplesVec.push_back(MakeSYCLDeviceTriple(SYCLTargetArch));
1410+
UniqueSYCLTriplesVec.push_back(getSYCLDeviceTriple(SYCLTargetArch));
14121411
addSYCLDefaultTriple(C, UniqueSYCLTriplesVec);
14131412
}
14141413
}
@@ -2529,7 +2528,7 @@ void Driver::PrintHelp(bool ShowHidden) const {
25292528
VisibilityMask);
25302529
}
25312530

2532-
llvm::Triple Driver::MakeSYCLDeviceTriple(StringRef TargetArch) const {
2531+
llvm::Triple Driver::getSYCLDeviceTriple(StringRef TargetArch) const {
25332532
SmallVector<StringRef, 5> SYCLAlias = {
25342533
"spir", "spir64", "spir64_fpga", "spir64_x86_64",
25352534
"spir64_gen", "spirv32", "spirv64", "nvptx64"};
@@ -2557,13 +2556,13 @@ void Driver::PrintSYCLToolHelp(const Compilation &C) const {
25572556
StringRef AV(A->getValue());
25582557
llvm::Triple T;
25592558
if (AV == "gen" || AV == "all")
2560-
HelpArgs.push_back(std::make_tuple(MakeSYCLDeviceTriple("spir64_gen"),
2559+
HelpArgs.push_back(std::make_tuple(getSYCLDeviceTriple("spir64_gen"),
25612560
"ocloc", "--help", ""));
25622561
if (AV == "fpga" || AV == "all")
2563-
HelpArgs.push_back(std::make_tuple(MakeSYCLDeviceTriple("spir64_fpga"),
2562+
HelpArgs.push_back(std::make_tuple(getSYCLDeviceTriple("spir64_fpga"),
25642563
"aoc", "-help", "-sycl"));
25652564
if (AV == "x86_64" || AV == "all")
2566-
HelpArgs.push_back(std::make_tuple(MakeSYCLDeviceTriple("spir64_x86_64"),
2565+
HelpArgs.push_back(std::make_tuple(getSYCLDeviceTriple("spir64_x86_64"),
25672566
"opencl-aot", "--help", ""));
25682567
if (HelpArgs.empty()) {
25692568
C.getDriver().Diag(diag::err_drv_unsupported_option_argument)
@@ -3614,7 +3613,7 @@ static bool hasSYCLDefaultSection(Compilation &C, const StringRef &File) {
36143613
if (!(IsArchive || isObjectFile(File.str())))
36153614
return false;
36163615

3617-
llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(getDefaultSYCLArch(C)));
3616+
llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(getDefaultSYCLArch(C)));
36183617
// Checking uses -check-section option with the input file, no output
36193618
// file and the target triple being looked for.
36203619
const char *Targets =
@@ -3821,7 +3820,7 @@ bool Driver::checkForSYCLDefaultDevice(Compilation &C,
38213820
// or if -fsycl-targets isn't passed (that implies default device)
38223821
if (const Arg *A = Args.getLastArg(options::OPT_fsycl_targets_EQ)) {
38233822
for (const char *Val : A->getValues()) {
3824-
llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(Val));
3823+
llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(Val));
38253824
if ((TT.isSPIROrSPIRV()) && TT.getSubArch() == llvm::Triple::NoSubArch)
38263825
// Default triple found
38273826
return false;
@@ -6303,7 +6302,7 @@ class OffloadingActionBuilder final {
63036302
// There are a few different variants for FPGA, if we see one, just
63046303
// use the default FPGA triple to reduce possible match confusion.
63056304
if (Arch.compare(0, 4, "fpga") == 0)
6306-
Arch = C.getDriver().MakeSYCLDeviceTriple("spir64_fpga").str();
6305+
Arch = C.getDriver().getSYCLDeviceTriple("spir64_fpga").str();
63076306

63086307
if (std::find(UniqueSections.begin(), UniqueSections.end(), Arch) ==
63096308
UniqueSections.end())
@@ -6460,8 +6459,9 @@ class OffloadingActionBuilder final {
64606459
// Unrecognized, we have already diagnosed this earlier; skip.
64616460
continue;
64626461
// Add the proper -device value to the list.
6463-
GpuArchList.emplace_back(C.getDriver().MakeSYCLDeviceTriple(
6464-
"spir64_gen"), ValidDevice->data());
6462+
GpuArchList.emplace_back(
6463+
C.getDriver().getSYCLDeviceTriple("spir64_gen"),
6464+
ValidDevice->data());
64656465
UserTargetName = "spir64_gen";
64666466
} else if (auto ValidDevice =
64676467
gen::isGPUTarget<gen::NvidiaGPU>(Val)) {
@@ -6470,7 +6470,7 @@ class OffloadingActionBuilder final {
64706470
continue;
64716471
// Add the proper -device value to the list.
64726472
GpuArchList.emplace_back(
6473-
C.getDriver().MakeSYCLDeviceTriple("nvptx64-nvidia-cuda"),
6473+
C.getDriver().getSYCLDeviceTriple("nvptx64-nvidia-cuda"),
64746474
ValidDevice->data());
64756475
UserTargetName = "nvptx64-nvidia-cuda";
64766476
} else if (auto ValidDevice = gen::isGPUTarget<gen::AmdGPU>(Val)) {
@@ -6479,7 +6479,7 @@ class OffloadingActionBuilder final {
64796479
continue;
64806480
// Add the proper -device value to the list.
64816481
GpuArchList.emplace_back(
6482-
C.getDriver().MakeSYCLDeviceTriple("amdgcn-amd-amdhsa"),
6482+
C.getDriver().getSYCLDeviceTriple("amdgcn-amd-amdhsa"),
64836483
ValidDevice->data());
64846484
UserTargetName = "amdgcn-amd-amdhsa";
64856485
} else if (Val == "native_cpu") {
@@ -6490,7 +6490,7 @@ class OffloadingActionBuilder final {
64906490
continue;
64916491
}
64926492

6493-
llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(Val));
6493+
llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(Val));
64946494
std::string NormalizedName = TT.normalize();
64956495

64966496
// Make sure we don't have a duplicate triple.
@@ -6503,7 +6503,7 @@ class OffloadingActionBuilder final {
65036503
FoundNormalizedTriples[NormalizedName] = Val;
65046504

65056505
SYCLTripleList.push_back(
6506-
C.getDriver().MakeSYCLDeviceTriple(UserTargetName));
6506+
C.getDriver().getSYCLDeviceTriple(UserTargetName));
65076507
if (TT.getSubArch() == llvm::Triple::SPIRSubArch_fpga)
65086508
SYCLfpgaTriple = true;
65096509
// For user specified spir64_gen, add an empty device value as a
@@ -6567,7 +6567,7 @@ class OffloadingActionBuilder final {
65676567
// -fsycl -fintelfpga implies spir64_fpga
65686568
const char *SYCLTargetArch =
65696569
SYCLfpga ? "spir64_fpga" : getDefaultSYCLArch(C);
6570-
llvm::Triple TT = C.getDriver().MakeSYCLDeviceTriple(SYCLTargetArch);
6570+
llvm::Triple TT = C.getDriver().getSYCLDeviceTriple(SYCLTargetArch);
65716571
auto TCIt = llvm::find_if(
65726572
ToolChains, [&](auto &TC) { return TT == TC->getTriple(); });
65736573
assert(TCIt != ToolChains.end() &&
@@ -8372,14 +8372,14 @@ Action *Driver::ConstructPhaseAction(
83728372
return C.MakeAction<BackendJobAction>(Input, Output);
83738373
}
83748374
if (Args.hasArg(options::OPT_emit_llvm) ||
8375-
((TargetDeviceOffloadKind == Action::OFK_SYCL &&
8376-
C.getDriver().getUseNewOffloadingDriver()) ||
8377-
(((Input->getOffloadingToolChain() &&
8378-
Input->getOffloadingToolChain()->getTriple().isAMDGPU()) ||
8379-
TargetDeviceOffloadKind == Action::OFK_HIP) &&
8380-
(Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
8381-
false) ||
8382-
TargetDeviceOffloadKind == Action::OFK_OpenMP)))) {
8375+
(TargetDeviceOffloadKind == Action::OFK_SYCL &&
8376+
C.getDriver().getUseNewOffloadingDriver()) ||
8377+
(((Input->getOffloadingToolChain() &&
8378+
Input->getOffloadingToolChain()->getTriple().isAMDGPU()) ||
8379+
TargetDeviceOffloadKind == Action::OFK_HIP) &&
8380+
(Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
8381+
false) ||
8382+
TargetDeviceOffloadKind == Action::OFK_OpenMP))) {
83838383
types::ID Output =
83848384
Args.hasArg(options::OPT_S) &&
83858385
(TargetDeviceOffloadKind == Action::OFK_None ||

clang/lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ llvm::opt::DerivedArgList *ToolChain::TranslateOffloadTargetArgs(
16601660
A->getOption().matches(options::OPT_Xsycl_frontend);
16611661
if (A->getOption().matches(options::OPT_Xsycl_frontend_EQ)) {
16621662
// Passing device args: -Xsycl-target-frontend=<triple> -opt=val.
1663-
if (getDriver().MakeSYCLDeviceTriple(A->getValue(0)) == getTriple())
1663+
if (getDriver().getSYCLDeviceTriple(A->getValue(0)) == getTriple())
16641664
Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
16651665
else
16661666
continue;

0 commit comments

Comments
 (0)