MLIR 24.0.0git
Chipset.h
Go to the documentation of this file.
1//===- Chipset.h - AMDGPU Chipset version struct ----------*- 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#ifndef MLIR_DIALECT_AMDGPU_UTILS_CHIPSET_H_
9#define MLIR_DIALECT_AMDGPU_UTILS_CHIPSET_H_
10
11#include "mlir/Support/LLVM.h"
12#include "llvm/Support/Compiler.h"
13#include <tuple>
14
15namespace mlir::amdgpu {
16/// Represents the amdgpu gfx chipset version, e.g., gfx90a, gfx942, gfx1103.
17/// Note that the leading digits form a decimal number, while the last two
18/// digits form a hexadecimal number. For example:
19/// gfx942 --> major = 9, minor = 0x4, stepping = 0x2
20/// gfx90a --> major = 9, minor = 0x0, stepping = 0xa
21/// gfx1103 --> major = 11, minor = 0x0, stepping = 0x3
22///
23/// \deprecated Use `mlir::ROCDL::TargetInfo` instead, and rely on target
24/// features rather than about version numbers. Will be removed after one
25/// release.
26struct Chipset {
27 unsigned majorVersion = 0; // The major version (decimal).
28 unsigned minorVersion = 0; // The minor version (hexadecimal).
29 unsigned steppingVersion = 0; // The stepping version (hexadecimal).
30
31 constexpr Chipset() = default;
32 constexpr Chipset(unsigned major, unsigned minor, unsigned stepping)
33 : majorVersion(major), minorVersion(minor), steppingVersion(stepping) {};
34
35 /// Parses the chipset version string and returns the chipset on success, and
36 /// failure otherwise.
37 ///
38 /// \deprecated Use `ROCDL::TargetInfo::get`.
39 LLVM_DEPRECATED_WITH_FIXIT("Chipset struct deprecated",
40 "use ROCDL::TargetInfo::get instead")
41 static FailureOr<Chipset> parse(StringRef name);
42
43 std::tuple<unsigned, unsigned, unsigned> asTuple() const {
45 }
46
47#define DEFINE_COMP_OPERATOR(OPERATOR) \
48 friend bool operator OPERATOR(const Chipset &lhs, const Chipset &rhs) { \
49 return lhs.asTuple() OPERATOR rhs.asTuple(); \
50 }
57#undef DEFINE_COMP_OPERATOR
58};
59
60/// \deprecated Test `llvm::AMDGPU::FEAT_OCP_FP8_CONVERSION_INSTS` on a
61/// `ROCDL::TargetInfo` instead. This misses gfx11.7, which does have the OCP
62/// fp8 conversions.
64 "Chipset is deperecated",
65 "test FEAT_OCP_FP8_CONVERSION_INSTS on a ROCDL::TargetInfo")
66inline bool hasOcpFp8(const Chipset &chipset) {
67 return (chipset.majorVersion == 9 && chipset.minorVersion >= 5) ||
68 chipset.majorVersion >= 12;
69}
70} // namespace mlir::amdgpu
71
72#endif
#define DEFINE_COMP_OPERATOR(OPERATOR)
Definition Chipset.h:47
LLVM_DEPRECATED_WITH_FIXIT("Chipset is deperecated", "test FEAT_OCP_FP8_CONVERSION_INSTS on a ROCDL::TargetInfo") inline bool hasOcpFp8(const Chipset &chipset)
Definition Chipset.h:63
Represents the amdgpu gfx chipset version, e.g., gfx90a, gfx942, gfx1103.
Definition Chipset.h:26
constexpr Chipset(unsigned major, unsigned minor, unsigned stepping)
Definition Chipset.h:32
unsigned majorVersion
Definition Chipset.h:27
std::tuple< unsigned, unsigned, unsigned > asTuple() const
Definition Chipset.h:43
unsigned minorVersion
Definition Chipset.h:28
LLVM_DEPRECATED_WITH_FIXIT("Chipset struct deprecated", "use ROCDL::TargetInfo::get instead") static FailureOr< Chipset > parse(StringRef name)
Parses the chipset version string and returns the chipset on success, and failure otherwise.
unsigned steppingVersion
Definition Chipset.h:29
constexpr Chipset()=default