Skip to content

Commit 5667986

Browse files
committed
Merge remote-tracking branch 'upstream/sycl' into fallback_sort
2 parents 8a03ba5 + 4684463 commit 5667986

File tree

317 files changed

+3142
-1226
lines changed

Some content is hidden

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

317 files changed

+3142
-1226
lines changed

.github/workflows/sycl-linux-run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ permissions:
151151

152152
jobs:
153153
run:
154-
if: inputs.skip_run == 'false'
154+
if: github.event_name == 'workflow_dispatch' || inputs.skip_run == 'false'
155155
name: ${{ inputs.name }}
156156
runs-on: ${{ fromJSON(inputs.runner) }}
157157
container:

clang/include/clang/Driver/ToolChain.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,10 @@ 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.
785+
virtual void AddSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
786+
llvm::opt::ArgStringList &CC1Args) const;
787+
784788
/// Add arguments to use MCU GCC toolchain includes.
785789
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
786790
llvm::opt::ArgStringList &CC1Args) const;

clang/lib/Driver/Driver.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7446,8 +7446,30 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
74467446
if (Args.hasArg(options::OPT_fsycl_link_EQ) &&
74477447
Args.hasArg(options::OPT_fintelfpga)) {
74487448
// Wrap the object when creating an FPGA AOCX or AOCR binary.
7449-
auto *BC = C.MakeAction<OffloadWrapperJobAction>(LI, types::TY_LLVM_BC);
7450-
auto *ASM = C.MakeAction<BackendJobAction>(BC, types::TY_PP_Asm);
7449+
// When the input file is an AOCR (early) archive, the unbundled host
7450+
// binary consists of a list of objects. We cannot directly wrap that
7451+
// binary to be consumed later - this has to go through each listed
7452+
// object.
7453+
bool FPGAEarly = true;
7454+
if (auto *A = C.getInputArgs().getLastArg(options::OPT_fsycl_link_EQ))
7455+
FPGAEarly = A->getValue() == StringRef("early");
7456+
7457+
Action *WrapperAction;
7458+
if ((LI->getType() == types::TY_FPGA_AOCR ||
7459+
LI->getType() == types::TY_FPGA_AOCR_EMU) &&
7460+
!FPGAEarly) {
7461+
auto *RenameAction = C.MakeAction<FileTableTformJobAction>(
7462+
LI, types::TY_Tempfilelist, types::TY_Tempfilelist);
7463+
RenameAction->addRenameColumnTform(FileTableTformJobAction::COL_ZERO,
7464+
FileTableTformJobAction::COL_CODE);
7465+
ActionList WrapperItems({RenameAction});
7466+
WrapperAction = C.MakeAction<OffloadWrapperJobAction>(
7467+
WrapperItems, types::TY_LLVM_BC);
7468+
} else
7469+
WrapperAction =
7470+
C.MakeAction<OffloadWrapperJobAction>(LI, types::TY_LLVM_BC);
7471+
auto *ASM =
7472+
C.MakeAction<BackendJobAction>(WrapperAction, types::TY_PP_Asm);
74517473
auto *OBJ = C.MakeAction<AssembleJobAction>(ASM, types::TY_Object);
74527474
OffloadAction::HostDependence HDep(
74537475
*OBJ, *C.getSingleOffloadToolChain<Action::OFK_Host>(),

clang/lib/Driver/ToolChain.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,9 @@ void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
15191519
void ToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
15201520
ArgStringList &CC1Args) const {}
15211521

1522+
void ToolChain::AddSYCLIncludeArgs(const ArgList &DriverArgs,
1523+
ArgStringList &CC1Args) const {}
1524+
15221525
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
15231526
ToolChain::getDeviceLibs(
15241527
const ArgList &DriverArgs,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
11601160
getToolChain().AddHIPIncludeArgs(Args, CmdArgs);
11611161

11621162
if (JA.isOffloading(Action::OFK_SYCL)) {
1163-
toolchains::SYCLToolChain::AddSYCLIncludeArgs(D, Args, CmdArgs);
1163+
getToolChain().AddSYCLIncludeArgs(Args, CmdArgs);
11641164
if (Inputs[0].getType() == types::TY_CUDA) {
11651165
// Include __clang_cuda_runtime_wrapper.h in .cu SYCL compilation.
11661166
getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
@@ -10216,7 +10216,7 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1021610216

1021710217
if (I.getType() == types::TY_Tempfiletable ||
1021810218
I.getType() == types::TY_Tempfilelist || IsEmbeddedIR)
10219-
// wrapper actual input files are passed via the batch job file table:
10219+
// Input files are passed via the batch job file table.
1022010220
WrapperArgs.push_back(C.getArgs().MakeArgString("-batch"));
1022110221
WrapperArgs.push_back(C.getArgs().MakeArgString(I.getFilename()));
1022210222

@@ -10283,6 +10283,11 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1028310283
CmdArgs.push_back(
1028410284
TCArgs.MakeArgString(Twine("-target=") + Triple.getTriple()));
1028510285

10286+
if (Inputs[0].getType() == types::TY_Tempfiletable ||
10287+
Inputs[0].getType() == types::TY_Tempfilelist)
10288+
// Input files are passed via the batch job file table.
10289+
CmdArgs.push_back(C.getArgs().MakeArgString("-batch"));
10290+
1028610291
// Add input.
1028710292
assert(Inputs[0].isFilename() && "Invalid input.");
1028810293
CmdArgs.push_back(TCArgs.MakeArgString(Inputs[0].getFilename()));
@@ -10320,7 +10325,7 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1032010325

1032110326
if (Inputs[I].getType() == types::TY_Tempfiletable ||
1032210327
Inputs[I].getType() == types::TY_Tempfilelist)
10323-
// wrapper actual input files are passed via the batch job file table:
10328+
// Input files are passed via the batch job file table.
1032410329
CmdArgs.push_back(C.getArgs().MakeArgString("-batch"));
1032510330

1032610331
// Add input.

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
924924
const ToolChain &HostTC, const ArgList &Args,
925925
const Action::OffloadKind OK)
926926
: NVPTXToolChain(D, Triple, HostTC.getTriple(), Args), HostTC(HostTC),
927-
OK(OK) {}
927+
SYCLInstallation(D), OK(OK) {}
928928

929929
void CudaToolChain::addClangTargetOptions(
930930
const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
@@ -941,11 +941,19 @@ void CudaToolChain::addClangTargetOptions(
941941
// If we are compiling SYCL kernels for Nvidia GPUs, we do not support Cuda
942942
// device code compatability, hence we do not set Cuda mode in that instance.
943943
if (DeviceOffloadingKind == Action::OFK_SYCL) {
944-
toolchains::SYCLToolChain::AddSYCLIncludeArgs(getDriver(), DriverArgs,
945-
CC1Args);
944+
SYCLInstallation.AddSYCLIncludeArgs(DriverArgs, CC1Args);
946945

947946
if (DriverArgs.hasArg(options::OPT_fsycl_fp32_prec_sqrt))
948947
CC1Args.push_back("-fcuda-prec-sqrt");
948+
949+
bool FastRelaxedMath = DriverArgs.hasFlag(
950+
options::OPT_ffast_math, options::OPT_fno_fast_math, false);
951+
bool UnsafeMathOpt =
952+
DriverArgs.hasFlag(options::OPT_funsafe_math_optimizations,
953+
options::OPT_fno_unsafe_math_optimizations, false);
954+
if (FastRelaxedMath || UnsafeMathOpt)
955+
CC1Args.append({"-mllvm", "--nvptx-prec-divf32=0", "-mllvm",
956+
"--nvptx-prec-sqrtf32=0"});
949957
} else {
950958
CC1Args.append(
951959
{"-fcuda-is-device", "-mllvm", "-enable-memcpyopt-without-libcalls"});
@@ -1196,8 +1204,7 @@ CudaToolChain::GetCXXStdlibType(const ArgList &Args) const {
11961204
void CudaToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
11971205
ArgStringList &CC1Args) const {
11981206
if (DriverArgs.hasArg(options::OPT_fsycl)) {
1199-
toolchains::SYCLToolChain::AddSYCLIncludeArgs(getDriver(), DriverArgs,
1200-
CC1Args);
1207+
SYCLInstallation.AddSYCLIncludeArgs(DriverArgs, CC1Args);
12011208
}
12021209
HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
12031210

clang/lib/Driver/ToolChains/Cuda.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ class LLVM_LIBRARY_VISIBILITY CudaToolChain : public NVPTXToolChain {
260260
Tool *SelectTool(const JobAction &JA) const override;
261261
const ToolChain &HostTC;
262262

263+
SYCLInstallationDetector SYCLInstallation;
264+
263265
protected:
264266
Tool *buildAssembler() const override; // ptxas
265267
Tool *buildLinker() const override; // fatbinary (ok, not really a linker)

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3190,7 +3190,8 @@ bool Generic_GCC::GCCInstallationDetector::ScanGentooGccConfig(
31903190
Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple &Triple,
31913191
const ArgList &Args)
31923192
: ToolChain(D, Triple, Args), GCCInstallation(D),
3193-
CudaInstallation(D, Triple, Args), RocmInstallation(D, Triple, Args) {
3193+
CudaInstallation(D, Triple, Args), RocmInstallation(D, Triple, Args),
3194+
SYCLInstallation(D) {
31943195
getProgramPaths().push_back(getDriver().Dir);
31953196
}
31963197

clang/lib/Driver/ToolChains/Gnu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
294294
GCCInstallationDetector GCCInstallation;
295295
LazyDetector<CudaInstallationDetector> CudaInstallation;
296296
LazyDetector<RocmInstallationDetector> RocmInstallation;
297+
SYCLInstallationDetector SYCLInstallation;
297298

298299
public:
299300
Generic_GCC(const Driver &D, const llvm::Triple &Triple,

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA,
253253
HIPAMDToolChain::HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple,
254254
const ToolChain &HostTC, const ArgList &Args,
255255
const Action::OffloadKind OK)
256-
: ROCMToolChain(D, Triple, Args), HostTC(HostTC), OK(OK) {
256+
: ROCMToolChain(D, Triple, Args), HostTC(HostTC), SYCLInstallation(D),
257+
OK(OK) {
257258
// Lookup binaries into the driver directory, this is used to
258259
// discover the clang-offload-bundler executable.
259260
getProgramPaths().push_back(getDriver().Dir);
@@ -318,8 +319,7 @@ void HIPAMDToolChain::addClangTargetOptions(
318319
CC1Args.push_back("-fembed-bitcode=marker");
319320

320321
if (DeviceOffloadingKind == Action::OFK_SYCL) {
321-
toolchains::SYCLToolChain::AddSYCLIncludeArgs(getDriver(), DriverArgs,
322-
CC1Args);
322+
SYCLInstallation.AddSYCLIncludeArgs(DriverArgs, CC1Args);
323323
}
324324

325325
auto NoLibSpirv = DriverArgs.hasArg(options::OPT_fno_sycl_libspirv) ||

0 commit comments

Comments
 (0)