clang 22.0.0git
CudaInstallationDetector.h
Go to the documentation of this file.
1//===-- CudaInstallationDetector.h - Cuda Instalation Detector --*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_DRIVER_CUDAINSTALLATIONDETECTOR_H
10#define LLVM_CLANG_DRIVER_CUDAINSTALLATIONDETECTOR_H
11
12#include "clang/Basic/Cuda.h"
13#include "clang/Driver/Driver.h"
14#include <bitset>
15
16namespace clang {
17namespace driver {
18
19/// A class to find a viable CUDA installation
21private:
22 const Driver &D;
23 bool IsValid = false;
25 std::string InstallPath;
26 std::string BinPath;
27 std::string LibDevicePath;
28 std::string IncludePath;
29 llvm::StringMap<std::string> LibDeviceMap;
30
31 // CUDA architectures for which we have raised an error in
32 // CheckCudaVersionSupportsArch.
33 mutable std::bitset<(int)OffloadArch::LAST> ArchsWithBadVersion;
34
35public:
36 CudaInstallationDetector(const Driver &D, const llvm::Triple &HostTriple,
37 const llvm::opt::ArgList &Args);
38
39 void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
40 llvm::opt::ArgStringList &CC1Args) const;
41
42 /// Emit an error if Version does not support the given Arch.
43 ///
44 /// If either Version or Arch is unknown, does not emit an error. Emits at
45 /// most one error per Arch.
47
48 /// Check whether we detected a valid Cuda install.
49 bool isValid() const { return IsValid; }
50 /// Print information about the detected CUDA installation.
51 void print(raw_ostream &OS) const;
52
53 /// Get the detected Cuda install's version.
56 : Version;
57 }
58 /// Get the detected Cuda installation path.
59 StringRef getInstallPath() const { return InstallPath; }
60 /// Get the detected path to Cuda's bin directory.
61 StringRef getBinPath() const { return BinPath; }
62 /// Get the detected Cuda Include path.
63 StringRef getIncludePath() const { return IncludePath; }
64 /// Get the detected Cuda device library path.
65 StringRef getLibDevicePath() const { return LibDevicePath; }
66 /// Get libdevice file for given architecture
67 std::string getLibDeviceFile(StringRef Gpu) const {
68 return LibDeviceMap.lookup(Gpu);
69 }
70 void WarnIfUnsupportedVersion() const;
71};
72
73} // namespace driver
74} // namespace clang
75
76#endif // LLVM_CLANG_DRIVER_CUDAINSTALLATIONDETECTOR_H
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Definition Cuda.cpp:295
CudaInstallationDetector(const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args)
Definition Cuda.cpp:139
StringRef getLibDevicePath() const
Get the detected Cuda device library path.
CudaVersion version() const
Get the detected Cuda install's version.
StringRef getInstallPath() const
Get the detected Cuda installation path.
std::string getLibDeviceFile(StringRef Gpu) const
Get libdevice file for given architecture.
StringRef getBinPath() const
Get the detected path to Cuda's bin directory.
void CheckCudaVersionSupportsArch(OffloadArch Arch) const
Emit an error if Version does not support the given Arch.
Definition Cuda.cpp:320
void print(raw_ostream &OS) const
Print information about the detected CUDA installation.
Definition Cuda.cpp:337
StringRef getIncludePath() const
Get the detected Cuda Include path.
bool isValid() const
Check whether we detected a valid Cuda install.
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition Driver.h:99
The JSON file list parser is used to communicate input to InstallAPI.
CudaVersion
Definition Cuda.h:22
@ PARTIALLY_SUPPORTED
Definition Cuda.h:52