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);
89 bool HasHIPRuntime =
false;
90 bool HasDeviceLibrary =
false;
91 bool HasHIPStdParLibrary =
false;
92 bool HasRocThrustLibrary =
false;
93 bool HasRocPrimLibrary =
false;
96 const unsigned DefaultVersionMajor = 3;
97 const unsigned DefaultVersionMinor = 5;
98 const char *DefaultVersionPatch =
"0";
101 std::string DetectedVersion;
103 llvm::VersionTuple VersionMajorMinor;
105 std::string VersionPatch;
108 StringRef RocmPathArg;
110 std::vector<std::string> RocmDeviceLibPathArg;
112 StringRef HIPPathArg;
115 StringRef HIPStdParPathArg;
117 StringRef HIPRocThrustPathArg;
119 StringRef HIPRocPrimPathArg;
121 StringRef HIPVersionArg;
123 bool NoBuiltinLibs =
false;
132 llvm::StringMap<std::string> LibDeviceMap;
145 ConditionalLibrary WavefrontSize64;
146 ConditionalLibrary FiniteOnly;
147 ConditionalLibrary UnsafeMath;
151 std::map<unsigned, std::string> ABIVersionMap;
155 bool PrintROCmSearchDirs;
158 bool allGenericLibsValid()
const {
159 return !OCML.empty() && !OCKL.empty() && !OpenCL.empty() &&
160 WavefrontSize64.isValid();
163 void scanLibDevicePath(llvm::StringRef Path);
164 bool parseHIPVersionFile(llvm::StringRef
V);
172 StringRef PackageName);
176 const llvm::opt::ArgList &Args,
177 bool DetectHIPRuntime =
true);
183 StringRef LibDeviceFile, StringRef GPUArch,
185 const bool NeedsASanRT)
const;
201 void print(raw_ostream &OS)
const;
222 assert(!OCML.empty());
227 assert(!OCKL.empty());
232 assert(!OpenCL.empty());
240 return WavefrontSize64.get(Enabled);
244 return FiniteOnly.isValid() ? FiniteOnly.get(Enabled) :
"";
248 return UnsafeMath.isValid() ? UnsafeMath.get(Enabled) :
"";
252 auto Loc = ABIVersionMap.find(ABIVer.
ABIVersion);
253 if (Loc == ABIVersionMap.end())
260 auto Loc = LibDeviceMap.find(Gpu);
261 if (Loc == LibDeviceMap.end())
267 llvm::opt::ArgStringList &CC1Args)
const;
274 return RocmDeviceLibPathArg;
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
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)
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.