CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
130 lines
5.8 KiB
C++
130 lines
5.8 KiB
C++
/*******************************************************************************
|
|
*
|
|
* MIT License
|
|
*
|
|
* Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
*******************************************************************************/
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <Tensile/ContractionProblemPredicates.hpp>
|
|
|
|
TEST(Predicates, ArithmeticIntensity)
|
|
{
|
|
using namespace TensileLite;
|
|
|
|
ContractionProblemGemm a = ContractionProblemGemm::GEMM(
|
|
false, true, 1000, 1500, 500, 2000, 2000, 2000, 3.0, false, 1); // 88.4
|
|
ContractionProblemGemm b = ContractionProblemGemm::GEMM(
|
|
false, true, 500, 1000, 1000, 2000, 2000, 2000, 0.0, false, 5); // 125
|
|
ContractionProblemGemm c = ContractionProblemGemm::GEMM(
|
|
false, true, 2000, 100, 2000, 2000, 2000, 2000, 1.0, false, 10); // 43.5
|
|
ContractionProblemGemm d = ContractionProblemGemm::GEMM(
|
|
false, true, 2000, 2000, 450, 2000, 2000, 2000, 2.0, false, 1); // 92.04
|
|
|
|
auto pg1 = std::make_shared<Predicates::Contraction::AIGreaterThanEqual>(100);
|
|
auto pg2 = std::make_shared<Predicates::Contraction::AIGreaterThanEqual>(75);
|
|
auto pl1 = std::make_shared<Predicates::Contraction::AILessThanEqual>(100);
|
|
auto pl2 = std::make_shared<Predicates::Contraction::AILessThanEqual>(75);
|
|
|
|
EXPECT_EQ(false, (*pg1)(a));
|
|
EXPECT_EQ(true, (*pg2)(a));
|
|
EXPECT_EQ(true, (*pl1)(a));
|
|
EXPECT_EQ(false, (*pl2)(a));
|
|
|
|
EXPECT_EQ(true, (*pg1)(b));
|
|
EXPECT_EQ(true, (*pg2)(b));
|
|
EXPECT_EQ(false, (*pl1)(b));
|
|
EXPECT_EQ(false, (*pl2)(b));
|
|
|
|
EXPECT_EQ(false, (*pg1)(c));
|
|
EXPECT_EQ(false, (*pg2)(c));
|
|
EXPECT_EQ(true, (*pl1)(c));
|
|
EXPECT_EQ(true, (*pl2)(c));
|
|
|
|
EXPECT_EQ(false, (*pg1)(d));
|
|
EXPECT_EQ(true, (*pg2)(d));
|
|
EXPECT_EQ(true, (*pl1)(d));
|
|
EXPECT_EQ(false, (*pl2)(d));
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// WorkgroupMappingXCCCheck: CPU-only tests with injected cuCount (ROCM-2963).
|
|
// These use the test-only constructor so we don't need a GPU. See
|
|
// docs/solution-selection-unit-test-pattern.md.
|
|
// ----------------------------------------------------------------------------
|
|
|
|
TEST(Predicates, WorkgroupMappingXCCCheck_38CU_XCC4_Fails)
|
|
{
|
|
using namespace TensileLite;
|
|
// 38 % 4 != 0 -> predicate must reject (would have caught ROCM-2963).
|
|
auto pred = std::make_shared<Predicates::Contraction::WorkgroupMappingXCCCheck>(
|
|
std::array<int, 2>{4, -1}, 38u);
|
|
auto problem = ContractionProblemGemm::GEMM(false, false, 1024, 1024, 1024, 1024, 1024, 1024,
|
|
1.0, false, 1);
|
|
EXPECT_FALSE((*pred)(problem)) << "38 CUs with XCC=4 should fail (38 % 4 != 0)";
|
|
}
|
|
|
|
TEST(Predicates, WorkgroupMappingXCCCheck_38CU_XCC1_Passes)
|
|
{
|
|
using namespace TensileLite;
|
|
// 38 % 1 == 0 -> predicate must accept (fix for ROCM-2963).
|
|
auto pred = std::make_shared<Predicates::Contraction::WorkgroupMappingXCCCheck>(
|
|
std::array<int, 2>{1, -1}, 38u);
|
|
auto problem = ContractionProblemGemm::GEMM(false, false, 1024, 1024, 1024, 1024, 1024, 1024,
|
|
1.0, false, 1);
|
|
EXPECT_TRUE((*pred)(problem)) << "38 CUs with XCC=1 should pass (38 % 1 == 0)";
|
|
}
|
|
|
|
TEST(Predicates, WorkgroupMappingXCCCheck_80CU_XCC4_Passes)
|
|
{
|
|
using namespace TensileLite;
|
|
// 80 % 4 == 0 -> predicate must accept.
|
|
auto pred = std::make_shared<Predicates::Contraction::WorkgroupMappingXCCCheck>(
|
|
std::array<int, 2>{4, -1}, 80u);
|
|
auto problem = ContractionProblemGemm::GEMM(false, false, 1024, 1024, 1024, 1024, 1024, 1024,
|
|
1.0, false, 1);
|
|
EXPECT_TRUE((*pred)(problem)) << "80 CUs with XCC=4 should pass (80 % 4 == 0)";
|
|
}
|
|
|
|
TEST(Predicates, WorkgroupMappingXCCCheck_XCCMinus1_AlwaysPasses)
|
|
{
|
|
using namespace TensileLite;
|
|
// value[0] == -1 means no check.
|
|
auto pred = std::make_shared<Predicates::Contraction::WorkgroupMappingXCCCheck>(
|
|
std::array<int, 2>{-1, -1}, 38u);
|
|
auto problem = ContractionProblemGemm::GEMM(false, false, 4, 4, 4, 4, 4, 4, 1.0, false, 1);
|
|
EXPECT_TRUE((*pred)(problem)) << "XCC=-1 should always pass";
|
|
}
|
|
|
|
TEST(Predicates, WorkgroupMappingXCCCheck_FallbackTreatsXCCAs1)
|
|
{
|
|
using namespace TensileLite;
|
|
// When problem is cu-fallback, effective XCC is 1 so 38 % 1 == 0 -> pass.
|
|
auto pred = std::make_shared<Predicates::Contraction::WorkgroupMappingXCCCheck>(
|
|
std::array<int, 2>{4, -1}, 38u);
|
|
auto problem = ContractionProblemGemm::GEMM(false, false, 1024, 1024, 1024, 1024, 1024, 1024,
|
|
1.0, false, 1);
|
|
problem.setParams().setFallbackStatus(true);
|
|
EXPECT_TRUE((*pred)(problem)) << "With fallback status, effective XCC=1 so 38 % 1 == 0";
|
|
}
|