Go to the documentation of this file.
9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ROCM_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ROCM_H
16 #include "llvm/ADT/SmallString.h"
17 #include "llvm/ADT/StringMap.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Option/ArgList.h"
20 #include "llvm/Support/VersionTuple.h"
30 if (CodeObjectVersion < 4)
31 CodeObjectVersion = 4;
40 assert(
ABIVersion % 100 == 0 &&
"Not supported");
49 struct ConditionalLibrary {
53 bool isValid()
const {
return !On.empty() && !Off.empty(); }
55 StringRef get(
bool Enabled)
const {
57 return Enabled ? On : Off;
70 bool isSPACK()
const {
return !SPACKReleaseStr.empty(); }
71 Candidate(
std::string Path,
bool StrictChecking =
false,
72 StringRef SPACKReleaseStr = {})
73 : Path(Path), StrictChecking(StrictChecking),
74 SPACKReleaseStr(SPACKReleaseStr.str()) {}
78 bool HasHIPRuntime =
false;
79 bool HasDeviceLibrary =
false;
82 const unsigned DefaultVersionMajor = 3;
83 const unsigned DefaultVersionMinor = 5;
84 const char *DefaultVersionPatch =
"0";
89 llvm::VersionTuple VersionMajorMinor;
94 StringRef RocmPathArg;
96 std::vector<std::string> RocmDeviceLibPathArg;
100 StringRef HIPVersionArg;
102 bool NoBuiltinLibs =
false;
111 llvm::StringMap<std::string> LibDeviceMap;
125 ConditionalLibrary WavefrontSize64;
126 ConditionalLibrary FiniteOnly;
127 ConditionalLibrary UnsafeMath;
128 ConditionalLibrary DenormalsAreZero;
129 ConditionalLibrary CorrectlyRoundedSqrt;
133 std::map<unsigned, std::string> ABIVersionMap;
137 bool PrintROCmSearchDirs;
140 bool allGenericLibsValid()
const {
141 return !OCML.empty() && !OCKL.empty() && !
OpenCL.empty() && !
HIP.empty() &&
142 WavefrontSize64.isValid() && FiniteOnly.isValid() &&
143 UnsafeMath.isValid() && DenormalsAreZero.isValid() &&
144 CorrectlyRoundedSqrt.isValid();
147 void scanLibDevicePath(llvm::StringRef Path);
148 bool parseHIPVersionFile(llvm::StringRef
V);
156 StringRef PackageName);
160 const llvm::opt::ArgList &Args,
161 bool DetectHIPRuntime =
true,
162 bool DetectDeviceLib =
false);
168 StringRef LibDeviceFile,
bool Wave64,
bool DAZ,
169 bool FiniteOnly,
bool UnsafeMathOpt,
170 bool FastRelaxedMath,
bool CorrectSqrt,
184 void print(raw_ostream &OS)
const;
205 assert(!OCML.empty());
210 assert(!OCKL.empty());
220 assert(!
HIP.empty());
228 return WavefrontSize64.get(Enabled);
232 return FiniteOnly.get(Enabled);
236 return UnsafeMath.get(Enabled);
240 return DenormalsAreZero.get(Enabled);
244 return CorrectlyRoundedSqrt.get(Enabled);
248 auto Loc = ABIVersionMap.find(ABIVer.
ABIVersion);
249 if (Loc == ABIVersionMap.end())
256 auto Loc = LibDeviceMap.find(Gpu);
257 if (Loc == LibDeviceMap.end())
263 llvm::opt::ArgStringList &CC1Args)
const;
270 return RocmDeviceLibPathArg;
285 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ROCM_H
StringRef getLibPath() const
Get the detected Rocm library path.
StringRef getInstallPath() const
Get the detected Rocm install's version.
bool hasHIPRuntime() const
Check whether we detected a valid HIP runtime.
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
StringRef getDenormalsAreZeroPath(bool Enabled) const
StringRef getAsanRTLPath() const
Returns empty string of Asan runtime library is not available.
ArrayRef< std::string > getRocmDeviceLibPathArg() const
Get the values for –rocm-device-lib-path arguments.
StringRef getLibDevicePath() const
Get the detected Rocm device library path.
void detectDeviceLibrary()
static DeviceLibABIVersion fromCodeObjectVersion(unsigned CodeObjectVersion)
StringRef getABIVersionPath(DeviceLibABIVersion ABIVer) const
RocmInstallationDetector(const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime=true, bool DetectDeviceLib=false)
bool checkCommonBitcodeLibs(StringRef GPUArch, StringRef LibDeviceFile, DeviceLibABIVersion ABIVer) const
Check file paths of default bitcode libraries common to AMDGPU based toolchains.
ABI version of device library.
StringRef getIncludePath() const
Get the detected path to Rocm's bin directory.
StringRef getOCKLPath() const
StringRef getCorrectlyRoundedSqrtPath(bool Enabled) const
StringRef getWavefrontSize64Path(bool Enabled) const
StringRef getOpenCLPath() const
StringRef getHIPVersion() const
StringRef getLibDeviceFile(StringRef Gpu) const
Get libdevice file for given architecture.
bool hasDeviceLibrary() const
Check whether we detected a valid ROCm device library.
void print(raw_ostream &OS) const
Print information about the detected ROCm installation.
DeviceLibABIVersion(unsigned V)
StringRef getHIPPath() const
StringRef getHIPVersionArg() const
Get the value for –hip-version argument.
StringRef getFiniteOnlyPath(bool Enabled) const
StringRef getOCMLPath() const
A class to find a viable ROCM installation TODO: Generalize to handle libclc.
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
StringRef getUnsafeMathPath(bool Enabled) const
bool requiresLibrary()
Whether ABI version bc file is requested.
StringRef getRocmPathArg() const
Get the value for –rocm-path argument.
llvm::SmallVector< std::string, 12 > getCommonBitcodeLibs(const llvm::opt::ArgList &DriverArgs, StringRef LibDeviceFile, bool Wave64, bool DAZ, bool FiniteOnly, bool UnsafeMathOpt, bool FastRelaxedMath, bool CorrectSqrt, DeviceLibABIVersion ABIVer, bool isOpenMP) const
Get file paths of default bitcode libraries common to AMDGPU based toolchains.