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
167 lines
6.0 KiB
C++
167 lines
6.0 KiB
C++
// Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include <rocRoller/KernelOptions_detail.hpp>
|
|
#include <rocRoller/Scheduling/Observers/FunctionalUnit/WMMAObserver.hpp>
|
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include <catch2/generators/catch_generators.hpp>
|
|
#include <catch2/matchers/catch_matchers_string.hpp>
|
|
|
|
#include "TestContext.hpp"
|
|
|
|
using namespace rocRoller;
|
|
|
|
namespace WMMAObserverUnitTests
|
|
{
|
|
class WMMAObserverUnitTest : public TestContext
|
|
{
|
|
public:
|
|
WMMAObserverUnitTest(GPUArchitectureGFX gfx)
|
|
: TestContext(TestContext::ForTarget({gfx})){};
|
|
WMMAObserverUnitTest(GPUArchitectureTarget target, KernelOptions kernelOptions)
|
|
: TestContext(TestContext::ForTarget(target, kernelOptions)){};
|
|
};
|
|
|
|
TEST_CASE("Unit test observer regarding WMMA hazards on GFX1200/1201", "[observer]")
|
|
{
|
|
auto target = GENERATE(GPUArchitectureGFX::GFX1200, GPUArchitectureGFX::GFX1201);
|
|
WMMAObserverUnitTest t{target};
|
|
std::string opCode{"v_wmma_f32_16x16x16_f16"};
|
|
auto ctx = t.get();
|
|
|
|
const auto v0
|
|
= Register::Value::Placeholder(ctx, Register::Type::Vector, DataType::Float, 8);
|
|
const auto v1
|
|
= Register::Value::Placeholder(ctx, Register::Type::Vector, DataType::Half, 4);
|
|
const auto v2
|
|
= Register::Value::Placeholder(ctx, Register::Type::Vector, DataType::Half, 4);
|
|
v0->allocateNow();
|
|
v1->allocateNow();
|
|
v2->allocateNow();
|
|
|
|
auto wmmaInst = Instruction(opCode, {v0}, {v1, v2, v0}, {}, "");
|
|
auto valuInst = Instruction("v_add_f32", {v1}, {v1, v2}, {}, "");
|
|
|
|
const auto info = ctx->targetArchitecture().GetInstructionInfo(wmmaInst.getOpCode());
|
|
const auto latency = info.getLatency();
|
|
|
|
SECTION("Use observer object directly")
|
|
{
|
|
Scheduling::WMMAObserver observer(ctx);
|
|
|
|
CHECK(0 == observer.peek(wmmaInst).stallCycles);
|
|
CHECK(0 == observer.peek(valuInst).stallCycles);
|
|
|
|
observer.observe(wmmaInst);
|
|
|
|
CHECK(latency == observer.peek(wmmaInst).stallCycles);
|
|
CHECK(0 == observer.peek(valuInst).stallCycles);
|
|
|
|
observer.observe(valuInst);
|
|
|
|
CHECK(latency - 1 == observer.peek(wmmaInst).stallCycles);
|
|
CHECK(0 == observer.peek(valuInst).stallCycles);
|
|
|
|
observer.observe(wmmaInst);
|
|
|
|
CHECK(latency == observer.peek(wmmaInst).stallCycles);
|
|
CHECK(0 == observer.peek(valuInst).stallCycles);
|
|
}
|
|
|
|
SECTION("Use observer object through context")
|
|
{
|
|
CHECK(0 == ctx->peek(wmmaInst).stallCycles);
|
|
CHECK(0 == ctx->peek(valuInst).stallCycles);
|
|
|
|
ctx->schedule(wmmaInst);
|
|
|
|
CHECK(latency == ctx->peek(wmmaInst).stallCycles);
|
|
CHECK(0 == ctx->peek(valuInst).stallCycles);
|
|
|
|
ctx->schedule(valuInst);
|
|
|
|
CHECK(latency - 1 == ctx->peek(wmmaInst).stallCycles);
|
|
CHECK(0 == ctx->peek(valuInst).stallCycles);
|
|
|
|
ctx->schedule(wmmaInst);
|
|
|
|
CHECK(latency == ctx->peek(wmmaInst).stallCycles);
|
|
CHECK(0 == ctx->peek(valuInst).stallCycles);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("Unit test observer regarding WMMA hazards on GFX1250", "[observer]")
|
|
{
|
|
auto target = GENERATE(GPUArchTargetGFX1250Rev0, GPUArchTargetGFX1250Rev1);
|
|
auto coexecutionEnabled = GENERATE(true, false);
|
|
KernelOptions kernelOptions{};
|
|
kernelOptions->coexecutionEnabled = coexecutionEnabled;
|
|
std::string opCode{"v_wmma_f32_16x16x32_f16"};
|
|
WMMAObserverUnitTest t{target, kernelOptions};
|
|
auto ctx = t.get();
|
|
|
|
const auto FC = Register::AllocationOptions::FullyContiguous();
|
|
const auto v0
|
|
= Register::Value::Placeholder(ctx, Register::Type::Vector, DataType::Float, 8, FC);
|
|
const auto v1
|
|
= Register::Value::Placeholder(ctx, Register::Type::Vector, DataType::Half, 4, FC);
|
|
const auto v2
|
|
= Register::Value::Placeholder(ctx, Register::Type::Vector, DataType::Half, 4, FC);
|
|
v0->allocateNow();
|
|
v1->allocateNow();
|
|
v2->allocateNow();
|
|
|
|
auto wmmaInst = Instruction(opCode, {v0}, {v1, v2, v0}, {}, "");
|
|
auto valuInst = Instruction("v_add_f32", {v1}, {v1, v2}, {}, "");
|
|
|
|
const auto info = ctx->targetArchitecture().GetInstructionInfo(wmmaInst.getOpCode());
|
|
const auto latency = info.getLatency();
|
|
const auto warLatency = latency - (coexecutionEnabled ? 4 : 0);
|
|
|
|
SECTION("Use observer object directly")
|
|
{
|
|
Scheduling::WMMAObserver observer(ctx);
|
|
|
|
CHECK(0 == observer.peek(wmmaInst).stallCycles);
|
|
CHECK(0 == observer.peek(valuInst).stallCycles);
|
|
|
|
observer.observe(wmmaInst);
|
|
|
|
CHECK(latency == observer.peek(wmmaInst).stallCycles);
|
|
CHECK(0 == observer.peek(valuInst).stallCycles);
|
|
|
|
observer.observe(valuInst);
|
|
|
|
CHECK(latency - 1 == observer.peek(wmmaInst).stallCycles);
|
|
CHECK(0 == observer.peek(valuInst).stallCycles);
|
|
|
|
observer.observe(wmmaInst);
|
|
|
|
CHECK(latency == observer.peek(wmmaInst).stallCycles);
|
|
CHECK(0 == observer.peek(valuInst).stallCycles);
|
|
}
|
|
|
|
SECTION("Use observer object through context")
|
|
{
|
|
CHECK(0 == ctx->peek(wmmaInst).stallCycles);
|
|
CHECK(0 == ctx->peek(valuInst).stallCycles);
|
|
|
|
ctx->schedule(wmmaInst);
|
|
|
|
CHECK(latency == ctx->peek(wmmaInst).stallCycles);
|
|
CHECK(0 == ctx->peek(valuInst).stallCycles);
|
|
|
|
ctx->schedule(valuInst);
|
|
|
|
CHECK(warLatency - 1 == ctx->peek(wmmaInst).stallCycles);
|
|
CHECK(0 == ctx->peek(valuInst).stallCycles);
|
|
|
|
ctx->schedule(wmmaInst);
|
|
|
|
CHECK(latency == ctx->peek(wmmaInst).stallCycles);
|
|
CHECK(0 == ctx->peek(valuInst).stallCycles);
|
|
}
|
|
}
|
|
}
|