/******************************************************************************* * * MIT License * * Copyright (C) 2021-2025 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * *******************************************************************************/ #ifndef GEMM_CONFIG_HPP #define GEMM_CONFIG_HPP #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #include #include #pragma GCC diagnostic pop #include "gemm_driver.hpp" #include "gemm_global_mapping.hpp" #include "gemm_local_mapping.hpp" #define __ROCWMMA_GEMM_LAUNCH_BOUNDS__ __launch_bounds__(Constants::AMDGCN_WAVE_SIZE * 4u) namespace rocwmma { namespace CooperativeGemm { namespace BlockLevel { /* Block-Level cooperative GEMMs: * This GEMM configuration enables collaborative data movement * on individual blocks, or fragments. Wave collaboration depends * on locality: * - matrix_a collaborative waves in the same row * - matrix_b collaborative waves in the same col * * Class name LDSXY indicates whether X = matrix_a or Y = matrix_b is * transposed (T) or non-transposed (N) upon writing to LDS memory. * * Class name LDSRF indicates that both matrix_a and matrix_b are stored * as a register-file (RF) in LDS memory. * * Due to collaboration, data is not MFMA friendly until written to LDS. */ struct LdsNT { template using GlobalMapping = GlobalMapping::BlockLevelMapping; template using LdsMapping = LocalMapping::LdsMappingNT; template using GemmDriver = GemmDriver; }; struct LdsTN { template using GlobalMapping = GlobalMapping::BlockLevelMapping; template using LdsMapping = LocalMapping::LdsMappingTN; template using GemmDriver = GemmDriver; }; struct LdsRF { template using GlobalMapping = GlobalMapping::BlockLevelMapping; template using LdsMapping = LocalMapping::LdsMappingRF; template using GemmDriver = GemmDriver; }; } // BlockLevel namespace WaveLevel { /* Wave-Level cooperative GEMMs: * This GEMM configuration enables collaborative data movement * on a collection of blocks (BlocksX x BlocksY) as a wave tile. * Wave collaboration depends on locality: * - matrix_a collaborative waves in the same row * - matrix_b collaborative waves in the same col * * Class name LDSXY indicates whether X = matrix_a or Y = matrix_b is * transposed (T) or non-transposed (N) upon writing to LDS memory. * * Due to collaboration, data is not MFMA friendly until written to LDS. */ struct LdsNT { template using GlobalMapping = GlobalMapping::WaveLevelMapping; template using LdsMapping = LocalMapping::LdsMappingNT; template using GemmDriver = GemmDriver; }; struct LdsTN { template using GlobalMapping = GlobalMapping::WaveLevelMapping; template using LdsMapping = LocalMapping::LdsMappingTN; template using GemmDriver = GemmDriver; }; } // namespace WaveLevel namespace WorkgroupLevel { /* Workgroup-Level cooperative GEMMs: * This GEMM configuration enables collaborative data movement * on a collection of wave tiles (BlocksX x BlocksY) x (WavesX x WavesY) * as a larger macro tile. Wave collaboration is among all waves in the * workgroup. * * Class name LDSXY indicates whether X = matrix_a or Y = matrix_b is * transposed (T) or non-transposed (N) upon writing to LDS memory. * * Due to collaboration, data is not MFMA friendly until written to LDS. */ struct LdsNT { template using GlobalMapping = GlobalMapping::WorkgroupLevelMapping; template using LdsMapping = LocalMapping::LdsMappingNT; template using GemmDriver = GemmDriver; }; struct LdsTN { template using GlobalMapping = GlobalMapping::WorkgroupLevelMapping; template using LdsMapping = LocalMapping::LdsMappingTN; template using GemmDriver = GemmDriver; }; } // namespace WorkgroupLevel } // namespace CooperativeGemm template <> constexpr const char* dataTypeToString() { return "Block_LdsNT"; } template <> constexpr const char* dataTypeToString() { return "Block_LdsTN"; } template <> constexpr const char* dataTypeToString() { return "Block_LdsRF"; } template <> constexpr const char* dataTypeToString() { return "Wave_LdsNT"; } template <> constexpr const char* dataTypeToString() { return "Wave_LdsTN"; } template <> constexpr const char* dataTypeToString() { return "Workgroup_LdsNT"; } template <> constexpr const char* dataTypeToString() { return "Workgroup_LdsTN"; } } // namespace rocwmma #endif // GEMM_CONFIG_HPP