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
175 lines
4.3 KiB
C++
175 lines
4.3 KiB
C++
// Copyright (c) 2026 Advanced Micro Devices, Inc.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/// @file waitcnt_counter_test.cpp
|
|
/// @brief Phase D unit tests for WaitCounters and WaitTarget.
|
|
|
|
#include "rocjitsu/vm/amdgpu/wait_counters.h"
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace {
|
|
|
|
using namespace rocjitsu::amdgpu;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// WaitCounters — increment and decrement
|
|
// ---------------------------------------------------------------------------
|
|
|
|
TEST(WaitCounterTest, IncrementVmcnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::VMCNT);
|
|
EXPECT_EQ(c.vmcnt, 1);
|
|
c.increment(WaitCounterType::VMCNT);
|
|
EXPECT_EQ(c.vmcnt, 2);
|
|
}
|
|
|
|
TEST(WaitCounterTest, DecrementVmcnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::VMCNT);
|
|
c.increment(WaitCounterType::VMCNT);
|
|
c.decrement(WaitCounterType::VMCNT);
|
|
EXPECT_EQ(c.vmcnt, 1);
|
|
}
|
|
|
|
TEST(WaitCounterTest, IncrementLgkmcnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::LGKMCNT);
|
|
EXPECT_EQ(c.lgkmcnt, 1);
|
|
}
|
|
|
|
TEST(WaitCounterTest, IncrementExpcnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::EXPCNT);
|
|
EXPECT_EQ(c.expcnt, 1);
|
|
}
|
|
|
|
TEST(WaitCounterTest, IncrementVscnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::VSCNT);
|
|
EXPECT_EQ(c.vscnt, 1);
|
|
}
|
|
|
|
TEST(WaitCounterTest, IncrementStorecnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::STORECNT);
|
|
EXPECT_EQ(c.vscnt, 1); // STORECNT aliases VSCNT
|
|
}
|
|
|
|
TEST(WaitCounterTest, IncrementLoadcnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::LOADCNT);
|
|
EXPECT_EQ(c.vmcnt, 1); // LOADCNT aliases VMCNT
|
|
}
|
|
|
|
TEST(WaitCounterTest, IncrementDscnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::DSCNT);
|
|
EXPECT_EQ(c.dscnt, 1);
|
|
EXPECT_EQ(c.lgkmcnt, 1); // DSCNT also increments LGKMCNT
|
|
}
|
|
|
|
TEST(WaitCounterTest, IncrementKmcnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::KMCNT);
|
|
EXPECT_EQ(c.kmcnt, 1);
|
|
EXPECT_EQ(c.lgkmcnt, 1); // KMCNT also increments LGKMCNT
|
|
}
|
|
|
|
TEST(WaitCounterTest, IncrementTensorcnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::TENSORCNT);
|
|
EXPECT_EQ(c.tensorcnt, 1);
|
|
}
|
|
|
|
TEST(WaitCounterTest, DecrementDscnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::DSCNT);
|
|
c.decrement(WaitCounterType::DSCNT);
|
|
EXPECT_EQ(c.dscnt, 0);
|
|
EXPECT_EQ(c.lgkmcnt, 0);
|
|
}
|
|
|
|
TEST(WaitCounterTest, DecrementKmcnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::KMCNT);
|
|
c.decrement(WaitCounterType::KMCNT);
|
|
EXPECT_EQ(c.kmcnt, 0);
|
|
EXPECT_EQ(c.lgkmcnt, 0);
|
|
}
|
|
|
|
TEST(WaitCounterTest, MixedDscntKmcnt) {
|
|
WaitCounters c;
|
|
c.increment(WaitCounterType::DSCNT);
|
|
c.increment(WaitCounterType::KMCNT);
|
|
EXPECT_EQ(c.lgkmcnt, 2); // Both contribute to LGKMCNT
|
|
EXPECT_EQ(c.dscnt, 1);
|
|
EXPECT_EQ(c.kmcnt, 1);
|
|
c.decrement(WaitCounterType::DSCNT);
|
|
EXPECT_EQ(c.lgkmcnt, 1);
|
|
}
|
|
|
|
TEST(WaitCounterTest, SaturationAtMax) {
|
|
WaitCounters c;
|
|
for (int i = 0; i < 100; ++i)
|
|
c.increment(WaitCounterType::VMCNT);
|
|
EXPECT_EQ(c.vmcnt, WaitCounters::VMCNT_MAX);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// WaitTarget — satisfaction checks
|
|
// ---------------------------------------------------------------------------
|
|
|
|
TEST(WaitTargetTest, DefaultSatisfied) {
|
|
WaitTarget target;
|
|
WaitCounters counters;
|
|
EXPECT_TRUE(target.satisfied(counters));
|
|
}
|
|
|
|
TEST(WaitTargetTest, VmcntNotSatisfied) {
|
|
WaitTarget target;
|
|
target.vmcnt = 0;
|
|
WaitCounters counters;
|
|
counters.vmcnt = 1;
|
|
EXPECT_FALSE(target.satisfied(counters));
|
|
}
|
|
|
|
TEST(WaitTargetTest, VmcntSatisfied) {
|
|
WaitTarget target;
|
|
target.vmcnt = 2;
|
|
WaitCounters counters;
|
|
counters.vmcnt = 2;
|
|
EXPECT_TRUE(target.satisfied(counters));
|
|
}
|
|
|
|
TEST(WaitTargetTest, DscntNotSatisfied) {
|
|
WaitTarget target;
|
|
target.dscnt = 0;
|
|
WaitCounters counters;
|
|
counters.dscnt = 1;
|
|
counters.lgkmcnt = 1;
|
|
EXPECT_FALSE(target.satisfied(counters));
|
|
}
|
|
|
|
TEST(WaitTargetTest, TensorcntNotSatisfied) {
|
|
WaitTarget target;
|
|
target.tensorcnt = 0;
|
|
WaitCounters counters;
|
|
counters.tensorcnt = 1;
|
|
EXPECT_FALSE(target.satisfied(counters));
|
|
}
|
|
|
|
TEST(WaitTargetTest, MultipleCounters) {
|
|
WaitTarget target;
|
|
target.vmcnt = 0;
|
|
target.lgkmcnt = 0;
|
|
WaitCounters counters;
|
|
counters.vmcnt = 1;
|
|
counters.lgkmcnt = 0;
|
|
EXPECT_FALSE(target.satisfied(counters)); // vmcnt > 0
|
|
counters.vmcnt = 0;
|
|
EXPECT_TRUE(target.satisfied(counters));
|
|
}
|
|
|
|
} // namespace
|