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
99 lines
3.3 KiB
C++
99 lines
3.3 KiB
C++
// Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include <catch2/generators/catch_generators.hpp>
|
|
|
|
#include <rocRoller/KernelGraph/KernelGraph.hpp>
|
|
#include <rocRoller/KernelGraph/Utils.hpp>
|
|
|
|
#include <common/CommonGraphs.hpp>
|
|
|
|
#include "TestContext.hpp"
|
|
|
|
#include <algorithm>
|
|
#include <ranges>
|
|
|
|
namespace TopologicalCompareTest
|
|
{
|
|
using namespace rocRoller;
|
|
|
|
TEST_CASE("TopologicalCompare works.", "[kernel-graph][utils]")
|
|
{
|
|
auto context = TestContext::ForTestDevice();
|
|
auto gemm = rocRollerTest::Graphs::GEMM(DataType::Float);
|
|
|
|
gemm.setTileSize(64, 64, 8);
|
|
gemm.setMFMA(16, 16, 1, 1);
|
|
gemm.setUseLDS(false, false, false);
|
|
|
|
auto graph = gemm.getKernelGraph();
|
|
|
|
std::string constructionMethod = GENERATE("reference", "pointer");
|
|
DYNAMIC_SECTION("Construction from " << constructionMethod)
|
|
{
|
|
auto testComparator = [&](KernelGraph::TopologicalCompare&& comp) {
|
|
// Get some nodes that have a defined, non-body order with each other.
|
|
|
|
auto notContainerNode = [&](int nodeIdx) {
|
|
using namespace KernelGraph::ControlGraph;
|
|
auto node = graph.control.getNode(nodeIdx);
|
|
|
|
auto visitor = [&](auto const& node) {
|
|
using T = std::decay_t<decltype(node)>;
|
|
return !COperationWithBody<T>;
|
|
};
|
|
|
|
return std::visit(visitor, node);
|
|
};
|
|
|
|
std::vector<int> nodes;
|
|
|
|
auto definedOrderWithOtherNodes = [&](int nodeIdx) -> bool {
|
|
using namespace KernelGraph::ControlGraph;
|
|
for(auto otherIdx : nodes)
|
|
{
|
|
auto order
|
|
= graph.control.compareNodes(rocRoller::UpdateCache, otherIdx, nodeIdx);
|
|
if(order == NodeOrdering::Undefined
|
|
|| order == NodeOrdering::LeftInBodyOfRight
|
|
|| order == NodeOrdering::RightInBodyOfLeft)
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
auto nonContainerNodes = graph.control.getNodes().filter(notContainerNode);
|
|
for(auto node : nonContainerNodes)
|
|
{
|
|
if(definedOrderWithOtherNodes(node))
|
|
nodes.push_back(node);
|
|
}
|
|
|
|
std::ranges::sort(nodes, comp);
|
|
|
|
for(int idx = 0; idx + 1 < nodes.size(); ++idx)
|
|
{
|
|
CHECK(graph.control.compareNodes(
|
|
rocRoller::UpdateCache, nodes[idx], nodes[idx + 1])
|
|
== KernelGraph::ControlGraph::NodeOrdering::LeftFirst);
|
|
}
|
|
};
|
|
|
|
if(constructionMethod == "reference")
|
|
{
|
|
testComparator(KernelGraph::TopologicalCompare(graph));
|
|
}
|
|
else if(constructionMethod == "pointer")
|
|
{
|
|
testComparator(KernelGraph::TopologicalCompare(&graph));
|
|
}
|
|
else
|
|
{
|
|
FAIL();
|
|
}
|
|
}
|
|
}
|
|
}
|