Skip to content

Commit 63084b5

Browse files
committed
Merge from 'sycl' to 'sycl-web' (1 commits)
CONFLICT (add/add): Merge conflict in clang/include/clang/Driver/SyclInstallationDetector.h CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/AMDGPU.cpp CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/HIPAMD.h CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/SYCL.h
2 parents 9c69339 + b37d0d4 commit 63084b5

File tree

6 files changed

+170
-173
lines changed

6 files changed

+170
-173
lines changed

clang/include/clang/Driver/SyclInstallationDetector.h

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,11 @@
99
#ifndef LLVM_CLANG_DRIVER_SYCLINSTALLATIONDETECTOR_H
1010
#define LLVM_CLANG_DRIVER_SYCLINSTALLATIONDETECTOR_H
1111

12-
#include "clang/Basic/Cuda.h"
1312
#include "clang/Driver/Driver.h"
14-
#include "clang/Driver/Options.h"
15-
#include "clang/Driver/Tool.h"
1613

1714
namespace clang {
1815
namespace driver {
1916

20-
// This is a mapping between the user provided --offload-arch value for Intel
21-
// GPU targets and the spir64_gen device name accepted by OCLOC (the Intel GPU
22-
// AOT compiler).
23-
StringRef mapIntelGPUArchName(StringRef ArchName);
24-
2517
class SYCLInstallationDetector {
2618
public:
2719
SYCLInstallationDetector(const Driver &D);
@@ -51,110 +43,6 @@ class SYCLInstallationDetector {
5143
llvm::SmallVector<llvm::SmallString<128>, 4> InstallationCandidates;
5244
};
5345

54-
55-
class Command;
56-
57-
namespace tools {
58-
namespace SYCL {
59-
60-
void constructLLVMForeachCommand(Compilation &C, const JobAction &JA,
61-
std::unique_ptr<Command> InputCommand,
62-
const InputInfoList &InputFiles,
63-
const InputInfo &Output, const Tool *T,
64-
StringRef Increment, StringRef Ext = "out",
65-
StringRef ParallelJobs = "");
66-
67-
// Provides a vector of device library names that are associated with the
68-
// given triple and AOT information.
69-
SmallVector<std::string, 8> getDeviceLibraries(const Compilation &C,
70-
const llvm::Triple &TargetTriple,
71-
bool IsSpirvAOT);
72-
73-
// Populates the SYCL device traits macros.
74-
void populateSYCLDeviceTraitsMacrosArgs(
75-
Compilation &C, const llvm::opt::ArgList &Args,
76-
const SmallVectorImpl<std::pair<const ToolChain *, StringRef>> &Targets);
77-
78-
bool shouldDoPerObjectFileLinking(const Compilation &C);
79-
// Runs llvm-spirv to convert spirv to bc, llvm-link, which links multiple LLVM
80-
// bitcode. Converts generated bc back to spirv using llvm-spirv, wraps with
81-
// offloading information. Finally compiles to object using llc
82-
class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
83-
public:
84-
Linker(const ToolChain &TC) : Tool("SYCL::Linker", "sycl-link", TC) {}
85-
86-
bool hasIntegratedCPP() const override { return false; }
87-
88-
void ConstructJob(Compilation &C, const JobAction &JA,
89-
const InputInfo &Output, const InputInfoList &Inputs,
90-
const llvm::opt::ArgList &TCArgs,
91-
const char *LinkingOutput) const override;
92-
93-
private:
94-
/// \return llvm-link output file name.
95-
const char *constructLLVMLinkCommand(Compilation &C, const JobAction &JA,
96-
const InputInfo &Output,
97-
const llvm::opt::ArgList &Args,
98-
llvm::StringRef SubArchName,
99-
llvm::StringRef OutputFilePrefix,
100-
const InputInfoList &InputFiles) const;
101-
};
102-
103-
namespace gen {
104-
105-
class LLVM_LIBRARY_VISIBILITY BackendCompiler : public Tool {
106-
public:
107-
BackendCompiler(const ToolChain &TC)
108-
: Tool("gen::BackendCompiler", "gen compiler", TC) {}
109-
110-
bool hasIntegratedCPP() const override { return false; }
111-
112-
void ConstructJob(Compilation &C, const JobAction &JA,
113-
const InputInfo &Output, const InputInfoList &Inputs,
114-
const llvm::opt::ArgList &TCArgs,
115-
const char *LinkingOutput) const override;
116-
};
117-
118-
StringRef resolveGenDevice(StringRef DeviceName);
119-
SmallString<64> getGenDeviceMacro(StringRef DeviceName);
120-
StringRef getGenGRFFlag(StringRef GRFMode);
121-
122-
// Prefix for GPU specific targets used for -fsycl-targets
123-
constexpr char IntelGPU[] = "intel_gpu_";
124-
constexpr char NvidiaGPU[] = "nvidia_gpu_";
125-
constexpr char AmdGPU[] = "amd_gpu_";
126-
127-
template <auto GPUArh> std::optional<StringRef> isGPUTarget(StringRef Target) {
128-
// Handle target specifications that resemble '(intel, nvidia, amd)_gpu_*'
129-
// here.
130-
if (Target.starts_with(GPUArh)) {
131-
return resolveGenDevice(Target);
132-
}
133-
return std::nullopt;
134-
}
135-
136-
} // end namespace gen
137-
138-
namespace x86_64 {
139-
140-
class LLVM_LIBRARY_VISIBILITY BackendCompiler : public Tool {
141-
public:
142-
BackendCompiler(const ToolChain &TC)
143-
: Tool("x86_64::BackendCompiler", "x86_64 compiler", TC) {}
144-
145-
bool hasIntegratedCPP() const override { return false; }
146-
147-
void ConstructJob(Compilation &C, const JobAction &JA,
148-
const InputInfo &Output, const InputInfoList &Inputs,
149-
const llvm::opt::ArgList &TCArgs,
150-
const char *LinkingOutput) const override;
151-
};
152-
153-
} // end namespace x86_64
154-
155-
} // end namespace SYCL
156-
} // end namespace tools
157-
15846
} // namespace driver
15947
} // namespace clang
16048

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,18 @@ RocmInstallationDetector::CommonBitcodeLibsPreferences::
8181
options::OPT_fno_fast_math, false);
8282

8383
const bool DefaultSqrt = IsKnownOffloading ? true : false;
84-
CorrectSqrt =
85-
DriverArgs.hasArg(options::OPT_cl_fp32_correctly_rounded_divide_sqrt) ||
86-
DriverArgs.hasFlag(
87-
options::OPT_fhip_fp32_correctly_rounded_divide_sqrt,
88-
options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt, DefaultSqrt);
84+
85+
if (DeviceOffloadingKind == Action::OFK_SYCL)
86+
// When using SYCL, sqrt is only correctly rounded if the flag is specified.
87+
CorrectSqrt = DriverArgs.hasArg(options::OPT_foffload_fp32_prec_sqrt);
88+
else
89+
CorrectSqrt =
90+
DriverArgs.hasArg(options::OPT_cl_fp32_correctly_rounded_divide_sqrt) ||
91+
DriverArgs.hasFlag(
92+
options::OPT_fhip_fp32_correctly_rounded_divide_sqrt,
93+
options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt,
94+
DefaultSqrt);
95+
8996
// GPU Sanitizer currently only supports ASan and is enabled through host
9097
// ASan.
9198
GPUSan = (DriverArgs.hasFlag(options::OPT_fgpu_sanitize,

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ void HIPAMDToolChain::addClangTargetOptions(
281281
: "-mlink-bitcode-file");
282282
CC1Args.push_back(DriverArgs.MakeArgString(BCFile.Path));
283283
}
284-
285284
}
286285

287286
llvm::opt::DerivedArgList *

clang/lib/Driver/ToolChains/HIPAMD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H
1111

1212
#include "AMDGPU.h"
13+
#include "SYCL.h"
1314
#include "clang/Driver/SyclInstallationDetector.h"
1415
#include "clang/Driver/Tool.h"
1516
#include "clang/Driver/ToolChain.h"

clang/lib/Driver/ToolChains/SYCL.h

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,114 @@
1515

1616
namespace clang {
1717
namespace driver {
18+
19+
// This is a mapping between the user provided --offload-arch value for Intel
20+
// GPU targets and the spir64_gen device name accepted by OCLOC (the Intel GPU
21+
// AOT compiler).
22+
StringRef mapIntelGPUArchName(StringRef ArchName);
23+
24+
class Command;
25+
26+
namespace tools {
27+
namespace SYCL {
28+
29+
void constructLLVMForeachCommand(Compilation &C, const JobAction &JA,
30+
std::unique_ptr<Command> InputCommand,
31+
const InputInfoList &InputFiles,
32+
const InputInfo &Output, const Tool *T,
33+
StringRef Increment, StringRef Ext = "out",
34+
StringRef ParallelJobs = "");
35+
36+
// Provides a vector of device library names that are associated with the
37+
// given triple and AOT information.
38+
SmallVector<std::string, 8> getDeviceLibraries(const Compilation &C,
39+
const llvm::Triple &TargetTriple,
40+
bool IsSpirvAOT);
41+
42+
// Populates the SYCL device traits macros.
43+
void populateSYCLDeviceTraitsMacrosArgs(
44+
Compilation &C, const llvm::opt::ArgList &Args,
45+
const SmallVectorImpl<std::pair<const ToolChain *, StringRef>> &Targets);
46+
47+
bool shouldDoPerObjectFileLinking(const Compilation &C);
48+
// Runs llvm-spirv to convert spirv to bc, llvm-link, which links multiple LLVM
49+
// bitcode. Converts generated bc back to spirv using llvm-spirv, wraps with
50+
// offloading information. Finally compiles to object using llc
51+
class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
52+
public:
53+
Linker(const ToolChain &TC) : Tool("SYCL::Linker", "sycl-link", TC) {}
54+
55+
bool hasIntegratedCPP() const override { return false; }
56+
57+
void ConstructJob(Compilation &C, const JobAction &JA,
58+
const InputInfo &Output, const InputInfoList &Inputs,
59+
const llvm::opt::ArgList &TCArgs,
60+
const char *LinkingOutput) const override;
61+
62+
private:
63+
/// \return llvm-link output file name.
64+
const char *constructLLVMLinkCommand(Compilation &C, const JobAction &JA,
65+
const InputInfo &Output,
66+
const llvm::opt::ArgList &Args,
67+
llvm::StringRef SubArchName,
68+
llvm::StringRef OutputFilePrefix,
69+
const InputInfoList &InputFiles) const;
70+
};
71+
72+
namespace gen {
73+
74+
class LLVM_LIBRARY_VISIBILITY BackendCompiler : public Tool {
75+
public:
76+
BackendCompiler(const ToolChain &TC)
77+
: Tool("gen::BackendCompiler", "gen compiler", TC) {}
78+
79+
bool hasIntegratedCPP() const override { return false; }
80+
81+
void ConstructJob(Compilation &C, const JobAction &JA,
82+
const InputInfo &Output, const InputInfoList &Inputs,
83+
const llvm::opt::ArgList &TCArgs,
84+
const char *LinkingOutput) const override;
85+
};
86+
87+
StringRef resolveGenDevice(StringRef DeviceName);
88+
SmallString<64> getGenDeviceMacro(StringRef DeviceName);
89+
StringRef getGenGRFFlag(StringRef GRFMode);
90+
91+
// Prefix for GPU specific targets used for -fsycl-targets
92+
constexpr char IntelGPU[] = "intel_gpu_";
93+
constexpr char NvidiaGPU[] = "nvidia_gpu_";
94+
constexpr char AmdGPU[] = "amd_gpu_";
95+
96+
template <auto GPUArh> std::optional<StringRef> isGPUTarget(StringRef Target) {
97+
// Handle target specifications that resemble '(intel, nvidia, amd)_gpu_*'
98+
// here.
99+
if (Target.starts_with(GPUArh)) {
100+
return resolveGenDevice(Target);
101+
}
102+
return std::nullopt;
103+
}
104+
105+
} // end namespace gen
106+
107+
namespace x86_64 {
108+
109+
class LLVM_LIBRARY_VISIBILITY BackendCompiler : public Tool {
110+
public:
111+
BackendCompiler(const ToolChain &TC)
112+
: Tool("x86_64::BackendCompiler", "x86_64 compiler", TC) {}
113+
114+
bool hasIntegratedCPP() const override { return false; }
115+
116+
void ConstructJob(Compilation &C, const JobAction &JA,
117+
const InputInfo &Output, const InputInfoList &Inputs,
118+
const llvm::opt::ArgList &TCArgs,
119+
const char *LinkingOutput) const override;
120+
};
121+
122+
} // end namespace x86_64
123+
} // end namespace SYCL
124+
} // end namespace tools
125+
18126
namespace toolchains {
19127

20128
class LLVM_LIBRARY_VISIBILITY SYCLToolChain : public ToolChain {

0 commit comments

Comments
 (0)