// Copyright Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT #include #include #include #include #include "TestContext.hpp" #include "common/CommonGraphs.hpp" #include "common/Utilities.hpp" namespace AddPrefetchTest { TEST_CASE("AddPrefetch", "[kernel-graph][graph-transforms]") { using namespace rocRoller::KernelGraph; using namespace rocRoller::KernelGraph::AddPrefetchDetail; auto context = TestContext::ForDefaultTarget(); auto typeA = rocRoller::DataType::Float; auto example = rocRollerTest::Graphs::GEMM(typeA); int prefetchInFlight = GENERATE(1, 2, 4); int prefetchLDSFactor = GENERATE(0, 1, 2); bool prefetchMixMemOps = GENERATE(false, true); example.setTileSize(256, 64, 16); example.setMFMA(32, 32, 2, 1); example.setUseLDS(true, true, false); example.setPrefetch(true, prefetchInFlight, prefetchLDSFactor, prefetchMixMemOps); auto graph = example.getKernelGraph(); auto params = example.getCommandParameters(); graph = transform(graph); graph = transform(graph, true); graph = transform(graph, params); graph = transform(graph, params, context.get()); graph = transform(graph, context.get()); graph = transform(graph, params, context.get()); graph = transform(graph, params, context.get()); graph = transform(graph); graph = transform(graph); graph = transform(graph); graph = transform(graph, context.get()); graph = transform(graph, context.get(), params->workgroupRemapXCC); graph = transform(graph, params, context.get()); graph = transform(graph); graph = transform(graph); graph = transform(graph); graph = transform(graph); graph = transform(graph, params, context.get()); SECTION("findPrefetch") { auto prefetchLoops = findPrefetch(graph); CHECK(prefetchLoops.size() == 1); auto numUnroll = (*prefetchLoops.cbegin()).second; CHECK(numUnroll == std::max(2, prefetchInFlight)); } } }