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 CorrectlyRoundedSqrt;
153 std::map<unsigned, std::string> ABIVersionMap;
157 bool PrintROCmSearchDirs;
160 bool allGenericLibsValid()
const {
161 return !OCML.empty() && !OCKL.empty() && !OpenCL.empty() &&
162 WavefrontSize64.isValid() && FiniteOnly.isValid() &&
163 UnsafeMath.isValid() && CorrectlyRoundedSqrt.isValid();
166 void scanLibDevicePath(llvm::StringRef Path);
167 bool parseHIPVersionFile(llvm::StringRef
V);
175 StringRef PackageName);
179 const llvm::opt::ArgList &Args,
180 bool DetectHIPRuntime =
true,
181 bool DetectDeviceLib =
false);
187 StringRef LibDeviceFile, StringRef GPUArch,
189 const bool NeedsASanRT)
const;
205 void print(raw_ostream &OS)
const;
226 assert(!OCML.empty());
231 assert(!OCKL.empty());
236 assert(!OpenCL.empty());
244 return WavefrontSize64.get(Enabled);
248 return FiniteOnly.get(Enabled);
252 return UnsafeMath.get(Enabled);
256 return CorrectlyRoundedSqrt.get(Enabled);
260 auto Loc = ABIVersionMap.find(ABIVer.
ABIVersion);
261 if (Loc == ABIVersionMap.end())
268 auto Loc = LibDeviceMap.find(Gpu);
269 if (Loc == LibDeviceMap.end())
275 llvm::opt::ArgStringList &CC1Args)
const;
282 return RocmDeviceLibPathArg;
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
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.
RocmInstallationDetector(const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime=true, bool DetectDeviceLib=false)
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 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.