MLIR 22.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 <tuple>
13
14namespace mlir::amdgpu {
15
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 for a hexadecimal number. For example:
19/// gfx942 --> major = 9, minor = 0x4, stepping = 0x2
20/// gfx90a --> major = 9, minor = 0x0, stepping = 0xa
21/// gfx1103 --> major = 10, minor = 0x0, stepping = 0x3
22struct Chipset {
23 unsigned majorVersion = 0; // The major version (decimal).
24 unsigned minorVersion = 0; // The minor version (hexadecimal).
25 unsigned steppingVersion = 0; // The stepping version (hexadecimal).
26
27 constexpr Chipset() = default;
28 constexpr Chipset(unsigned major, unsigned minor, unsigned stepping)
29 : majorVersion(major), minorVersion(minor), steppingVersion(stepping) {};
30
31 /// Parses the chipset version string and returns the chipset on success, and
32 /// failure otherwise.
33 static FailureOr<Chipset> parse(StringRef name);
34
35 std::tuple<unsigned, unsigned, unsigned> asTuple() const {
37 }
38
39#define DEFINE_COMP_OPERATOR(OPERATOR) \
40 friend bool operator OPERATOR(const Chipset &lhs, const Chipset &rhs) { \
41 return lhs.asTuple() OPERATOR rhs.asTuple(); \
42 }
49#undef DEFINE_COMP_OPERATOR
50};
51
52inline bool hasOcpFp8(const Chipset &chipset) {
53 return (chipset.majorVersion == 9 && chipset.minorVersion >= 5) ||
54 chipset.majorVersion >= 12;
55}
56
57} // namespace mlir::amdgpu
58
59#endif
#define DEFINE_COMP_OPERATOR(OPERATOR)
Definition Chipset.h:39
bool hasOcpFp8(const Chipset &chipset)
Definition Chipset.h:52
Represents the amdgpu gfx chipset version, e.g., gfx90a, gfx942, gfx1103.
Definition Chipset.h:22
constexpr Chipset(unsigned major, unsigned minor, unsigned stepping)
Definition Chipset.h:28
unsigned majorVersion
Definition Chipset.h:23
std::tuple< unsigned, unsigned, unsigned > asTuple() const
Definition Chipset.h:35
unsigned minorVersion
Definition Chipset.h:24
static FailureOr< Chipset > parse(StringRef name)
Parses the chipset version string and returns the chipset on success, and failure otherwise.
Definition Chipset.cpp:14
unsigned steppingVersion
Definition Chipset.h:25
constexpr Chipset()=default