Debian Codegraph @

mlir/unittests/Dialect/AMDGPU/AMDGPUUtilsTest.cpp

raw
1 //===- AMDGPUUtilsTest.cpp - Unit tests for AMDGPU dialect utils ----------===//
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 #include "mlir/Dialect/AMDGPU/Utils/Chipset.h"
10 #include "gtest/gtest.h"
11
12 namespace mlir::amdgpu {
13 namespace {
14
15 TEST(ChipsetTest, Parsing) {
16 FailureOr<Chipset> chipset = Chipset::parse("gfx90a");
17 ASSERT_TRUE(succeeded(chipset));
18 EXPECT_EQ(chipset->majorVersion, 9u);
19 EXPECT_EQ(chipset->minorVersion, 0u);
20 EXPECT_EQ(chipset->steppingVersion, 0xau);
21
22 chipset = Chipset::parse("gfx942");
23 ASSERT_TRUE(succeeded(chipset));
24 EXPECT_EQ(chipset->majorVersion, 9u);
25 EXPECT_EQ(chipset->minorVersion, 4u);
26 EXPECT_EQ(chipset->steppingVersion, 2u);
27
28 chipset = Chipset::parse("gfx1103");
29 ASSERT_TRUE(succeeded(chipset));
30 EXPECT_EQ(chipset->majorVersion, 11u);
31 EXPECT_EQ(chipset->minorVersion, 0u);
32 EXPECT_EQ(chipset->steppingVersion, 3u);
33 }
34
35 TEST(ChipsetTest, ParsingInvalid) {
36 EXPECT_TRUE(failed(Chipset::parse("navi33")));
37 EXPECT_TRUE(failed(Chipset::parse("rdna2")));
38 EXPECT_TRUE(failed(Chipset::parse("sm_80")));
39 EXPECT_TRUE(failed(Chipset::parse("GFX942")));
40 EXPECT_TRUE(failed(Chipset::parse("Gfx942")));
41 EXPECT_TRUE(failed(Chipset::parse("gfx9")));
42 EXPECT_TRUE(failed(Chipset::parse("gfx_942")));
43 EXPECT_TRUE(failed(Chipset::parse("gfx942_")));
44 EXPECT_TRUE(failed(Chipset::parse("gfxmeow")));
45 EXPECT_TRUE(failed(Chipset::parse("gfx1fff")));
46 }
47
48 TEST(ChipsetTest, Comparison) {
49 EXPECT_EQ(Chipset(9, 4, 2), Chipset(9, 4, 2));
50 EXPECT_NE(Chipset(9, 0, 0), Chipset(10, 0, 0));
51
52 EXPECT_LT(Chipset(9, 0, 0), Chipset(10, 0, 0));
53 EXPECT_LT(Chipset(9, 0, 0), Chipset(9, 4, 2));
54 EXPECT_FALSE(Chipset(9, 4, 2) < Chipset(9, 4, 2));
55
56 EXPECT_GT(Chipset(9, 0, 0xa), Chipset(9, 0, 8));
57 EXPECT_GE(Chipset(9, 0, 0xa), Chipset(9, 0, 0xa));
58 EXPECT_FALSE(Chipset(9, 0, 0xa) >= Chipset(9, 4, 2));
59 }
60
61 } // namespace
62 } // namespace mlir::amdgpu