[Mlir-commits] [llvm] [mlir] [mlir][amdgpu] Improve Chipset version utility (PR #106169)
Lei Zhang
llvmlistbot at llvm.org
Tue Aug 27 21:14:28 PDT 2024
================
@@ -9,19 +9,41 @@
#define MLIR_DIALECT_AMDGPU_UTILS_CHIPSET_H_
#include "mlir/Support/LLVM.h"
+#include <utility>
-namespace mlir {
-namespace amdgpu {
+namespace mlir::amdgpu {
+
+/// Represents the amdgpu gfx chipset version, e.g., gfx90a, gfx942, gfx1103.
+/// Note that the leading digits form a decimal number, while the last two
+/// digits for a hexadecimal number. For example:
+/// gfx942 --> major = 9, minor = 0x42
+/// gfx90a --> major = 9, minor = 0xa
+/// gfx1103 --> major = 10, minor = 0x3
struct Chipset {
Chipset() = default;
Chipset(unsigned majorVersion, unsigned minorVersion)
: majorVersion(majorVersion), minorVersion(minorVersion){};
+
+ /// Parses the chipset version string and returns the chipset on success, and
+ /// failure otherwise.
static FailureOr<Chipset> parse(StringRef name);
- unsigned majorVersion = 0;
- unsigned minorVersion = 0;
+ friend bool operator==(const Chipset &lhs, const Chipset &rhs) {
+ return lhs.majorVersion == rhs.majorVersion &&
+ lhs.minorVersion == rhs.minorVersion;
+ }
+ friend bool operator!=(const Chipset &lhs, const Chipset &rhs) {
+ return !(lhs == rhs);
+ }
+ friend bool operator<(const Chipset &lhs, const Chipset &rhs) {
+ return std::make_pair(lhs.majorVersion, lhs.minorVersion) <
+ std::make_pair(rhs.majorVersion, rhs.minorVersion);
+ }
+
+ unsigned majorVersion = 0; // The major version (decimal).
----------------
antiagainst wrote:
I think there is also a stepping component: https://github.com/llvm/llvm-project/blob/f363e30/llvm/lib/TargetParser/TargetParser.cpp#L225. I sort of wonder the purpose of this function given we have that one--maybe we can wrap that up? It would cause a dependency on it though. But it's a separate issue I guess.
https://github.com/llvm/llvm-project/pull/106169
More information about the Mlir-commits
mailing list