9#ifndef LLVM_CLANG_DRIVER_ROCMINSTALLATIONDETECTOR_H
10#define LLVM_CLANG_DRIVER_ROCMINSTALLATIONDETECTOR_H
22 if (CodeObjectVersion < 4)
23 CodeObjectVersion = 4;
34 assert(
ABIVersion % 100 == 0 &&
"Not supported");
43 struct ConditionalLibrary {
47 bool isValid()
const {
return !On.empty() && !Off.empty(); }
49 StringRef get(
bool Enabled)
const {
51 return Enabled ? On : Off;
62 std::string SPACKReleaseStr;
64 bool isSPACK()
const {
return !SPACKReleaseStr.empty(); }
65 Candidate(std::string
Path,
bool StrictChecking =
false,
66 StringRef SPACKReleaseStr = {})
67 :
Path(
Path), StrictChecking(StrictChecking),
68 SPACKReleaseStr(SPACKReleaseStr.str()) {}
71 struct CommonBitcodeLibsPreferences {
72 CommonBitcodeLibsPreferences(
const Driver &
D,
73 const llvm::opt::ArgList &DriverArgs,
76 const bool NeedsASanRT);
90 bool HasHIPRuntime =
false;
91 bool HasDeviceLibrary =
false;
92 bool HasHIPStdParLibrary =
false;
93 bool HasRocThrustLibrary =
false;
94 bool HasRocPrimLibrary =
false;
97 const unsigned DefaultVersionMajor = 3;
98 const unsigned DefaultVersionMinor = 5;
99 const char *DefaultVersionPatch =
"0";
102 std::string DetectedVersion;
104 llvm::VersionTuple VersionMajorMinor;
106 std::string VersionPatch;
109 StringRef RocmPathArg;
111 std::vector<std::string> RocmDeviceLibPathArg;
113 StringRef HIPPathArg;
116 StringRef HIPStdParPathArg;
118 StringRef HIPRocThrustPathArg;
120 StringRef HIPRocPrimPathArg;
122 StringRef HIPVersionArg;
124 bool NoBuiltinLibs =
false;
133 llvm::StringMap<std::string> LibDeviceMap;
146 ConditionalLibrary WavefrontSize64;
147 ConditionalLibrary FiniteOnly;
148 ConditionalLibrary UnsafeMath;
149 ConditionalLibrary DenormalsAreZero;
150 ConditionalLibrary CorrectlyRoundedSqrt;
154 std::map<unsigned, std::string> ABIVersionMap;
158 bool PrintROCmSearchDirs;
161 bool allGenericLibsValid()
const {
162 return !OCML.empty() && !OCKL.empty() && !
OpenCL.empty() &&
163 WavefrontSize64.isValid() && FiniteOnly.isValid() &&
164 UnsafeMath.isValid() && DenormalsAreZero.isValid() &&
165 CorrectlyRoundedSqrt.isValid();
168 void scanLibDevicePath(llvm::StringRef
Path);
169 bool parseHIPVersionFile(llvm::StringRef
V);
177 StringRef PackageName);
181 const llvm::opt::ArgList &Args,
182 bool DetectHIPRuntime =
true,
183 bool DetectDeviceLib =
false);
189 StringRef LibDeviceFile, StringRef GPUArch,
191 const bool NeedsASanRT)
const;
207 void print(raw_ostream &OS)
const;
228 assert(!OCML.empty());
233 assert(!OCKL.empty());
246 return WavefrontSize64.get(Enabled);
250 return FiniteOnly.get(Enabled);
254 return UnsafeMath.get(Enabled);
258 return DenormalsAreZero.get(Enabled);
262 return CorrectlyRoundedSqrt.get(Enabled);
267 if (
Loc == ABIVersionMap.end())
274 auto Loc = LibDeviceMap.find(Gpu);
275 if (
Loc == LibDeviceMap.end())
281 llvm::opt::ArgStringList &CC1Args)
const;
288 return RocmDeviceLibPathArg;
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
A class to find a viable ROCM installation TODO: Generalize to handle libclc.
StringRef getCorrectlyRoundedSqrtPath(bool Enabled) const
StringRef getIncludePath() const
Get the detected path to Rocm's bin directory.
StringRef getUnsafeMathPath(bool Enabled) const
StringRef getOCMLPath() const
StringRef getHIPVersion() const
StringRef getAsanRTLPath() const
Returns empty string of Asan runtime library is not available.
StringRef getOCKLPath() const
StringRef getFiniteOnlyPath(bool Enabled) const
bool hasDeviceLibrary() const
Check whether we detected a valid ROCm device library.
StringRef getLibDeviceFile(StringRef Gpu) const
Get libdevice file for given architecture.
ArrayRef< std::string > getRocmDeviceLibPathArg() const
Get the values for –rocm-device-lib-path arguments.
StringRef getRocmPathArg() const
Get the value for –rocm-path argument.
StringRef getInstallPath() const
Get the detected Rocm install's version.
StringRef getLibPath() const
Get the detected Rocm library path.
StringRef getDenormalsAreZeroPath(bool Enabled) const
StringRef getLibDevicePath() const
Get the detected Rocm device library path.
bool checkCommonBitcodeLibs(StringRef GPUArch, StringRef LibDeviceFile, DeviceLibABIVersion ABIVer) const
Check file paths of default bitcode libraries common to AMDGPU based toolchains.
StringRef getOpenCLPath() const
bool hasHIPStdParLibrary() const
Check whether we detected a valid HIP STDPAR Acceleration library.
StringRef getHIPVersionArg() const
Get the value for –hip-version argument.
StringRef getABIVersionPath(DeviceLibABIVersion ABIVer) const
llvm::SmallVector< ToolChain::BitCodeLibraryInfo, 12 > getCommonBitcodeLibs(const llvm::opt::ArgList &DriverArgs, StringRef LibDeviceFile, StringRef GPUArch, const Action::OffloadKind DeviceOffloadingKind, const bool NeedsASanRT) const
Get file paths of default bitcode libraries common to AMDGPU based toolchains.
bool hasHIPRuntime() const
Check whether we detected a valid HIP runtime.
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
void detectDeviceLibrary()
StringRef getWavefrontSize64Path(bool Enabled) const
void print(raw_ostream &OS) const
Print information about the detected ROCm installation.
The JSON file list parser is used to communicate input to InstallAPI.
ABI version of device library.
unsigned getAsCodeObjectVersion() const
static DeviceLibABIVersion fromCodeObjectVersion(unsigned CodeObjectVersion)
DeviceLibABIVersion(unsigned V)
bool requiresLibrary()
Whether ABI version bc file is requested.