// Copyright Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT #include #include #include "TestContext.hpp" #include #include #include #include TEST_CASE("LoadPacked", "[kernel-graph]") { using namespace rocRoller; using namespace KernelGraph; using namespace ControlGraph; auto context = TestContext::ForDefaultTarget(); auto example = rocRollerTest::Graphs::TileDoubleAdd(); example.setTileSize(16, 8); example.setSubTileSize(4, 2); auto params = example.getCommandParameters(512, 512); auto graph = example.getKernelGraph(); std::vector transforms{ std::make_shared(params), std::make_shared(params, context.get()), std::make_shared(context.get()), std::make_shared(params, context.get()), std::make_shared(context.get(), example.getCommand()), std::make_shared(params), }; for(auto const& xform : transforms) graph = graph.transform(xform); auto verifyLoadStoreOpVarType = [&graph](Operation op, VariableType variableType) { std::visit( [&](auto&& op) { using T = std::decay_t; if constexpr(CIsAnyOf) { for(auto opTag : graph.control.getElements()) { auto operation = graph.control.get(opTag).value(); CHECK(operation.varType == variableType); } } }, op); }; auto variableType = DataType::Half; auto packedVariableType = DataTypeInfo::Get(variableType).packedVariableType().value(); verifyLoadStoreOpVarType(LoadTiled{}, variableType); verifyLoadStoreOpVarType(StoreTiled{}, variableType); verifyLoadStoreOpVarType(LoadLDSTile{}, variableType); verifyLoadStoreOpVarType(StoreLDSTile{}, variableType); graph = graph.transform(std::make_shared(context.get())); // After LoadPacked, the {Load | Store}LDSTile::varType should be // the corresponding packed type. The LoadPacked analysis should not // identify the {Load | Store}Tiled operations as applicable for the // transformation in this case, and thus the varType should remain // unchanged. verifyLoadStoreOpVarType(LoadTiled{}, variableType); verifyLoadStoreOpVarType(StoreTiled{}, variableType); verifyLoadStoreOpVarType(LoadLDSTile{}, packedVariableType); verifyLoadStoreOpVarType(StoreLDSTile{}, packedVariableType); }