diff --git a/projects/aqlprofile/src/CMakeLists.txt b/projects/aqlprofile/src/CMakeLists.txt index 221a747a67..31a933cdeb 100644 --- a/projects/aqlprofile/src/CMakeLists.txt +++ b/projects/aqlprofile/src/CMakeLists.txt @@ -16,6 +16,7 @@ set ( LIB_SRC ${LIB_DIR}/core/gfx940_factory.cpp ${LIB_DIR}/core/gfx10_factory.cpp ${LIB_DIR}/core/gfx11_factory.cpp + ${LIB_DIR}/core/gfx115x_factory.cpp ${LIB_DIR}/core/gfx12_factory.cpp ${LIB_DIR}/core/vega20_reg_init.cpp ${LIB_DIR}/core/parse_ip_discovery.cpp diff --git a/projects/aqlprofile/src/core/gfx115x_factory.cpp b/projects/aqlprofile/src/core/gfx115x_factory.cpp new file mode 100644 index 0000000000..f16c888281 --- /dev/null +++ b/projects/aqlprofile/src/core/gfx115x_factory.cpp @@ -0,0 +1,74 @@ +// MIT License +// +// Copyright (c) 2017-2025 Advanced Micro Devices, Inc. +// +// 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. + +#include "core/gfx11_factory.h" +#include "def/gfx11_def.h" + +namespace aql_profile { + +// Gfx11.5 factory class +const GpuBlockInfo* Gfx115xFactory::block_table_[AQLPROFILE_BLOCKS_NUMBER] = {}; + +Gfx115xFactory::Gfx115xFactory(const AgentInfo* agent_info) + : Gfx11Factory(block_table_, sizeof(block_table_), agent_info) { + for (unsigned i = 0; i < AQLPROFILE_BLOCKS_NUMBER; ++i) { + const GpuBlockInfo* base_table_ptr = Gfx11Factory::block_table_[i]; + if (base_table_ptr == NULL) continue; + GpuBlockInfo* block_info = new GpuBlockInfo(*base_table_ptr); + block_table_[i] = block_info; + + // Overwrite block info for gfx11.5 specific changes + switch (block_info->id) { + case Gl1aCounterBlockId: + block_info->instance_count = 4; + break; + case Gl1cCounterBlockId: + block_info->instance_count = 4; + break; + case Gl2aCounterBlockId: + block_info->instance_count = 4; + break; + case Gl2cCounterBlockId: + block_info->instance_count = 4; + break; + default: + break; + } + } +} + +Gfx115xFactory::~Gfx115xFactory() { + for (unsigned i = 0; i < AQLPROFILE_BLOCKS_NUMBER; ++i) { + if (block_table_[i] != NULL) { + delete block_table_[i]; + block_table_[i] = NULL; + } + } +} + +Pm4Factory* Pm4Factory::Gfx115xCreate(const AgentInfo* agent_info) { + auto p = new Gfx115xFactory(agent_info); + if (p == NULL) throw aql_profile_exc_msg("Gfx115Factory allocation failed"); + return p; +} + +} // namespace aql_profile diff --git a/projects/aqlprofile/src/core/gfx11_factory.cpp b/projects/aqlprofile/src/core/gfx11_factory.cpp index f06c2be333..1b07b09a51 100644 --- a/projects/aqlprofile/src/core/gfx11_factory.cpp +++ b/projects/aqlprofile/src/core/gfx11_factory.cpp @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include "core/pm4_factory.h" +#include "core/gfx11_factory.h" #include "def/gfx11_def.h" #include "pm4/gfx11_cmd_builder.h" #include "pm4/pmc_builder.h" @@ -28,31 +28,7 @@ namespace aql_profile { -// Gfx11 factory class -class Gfx11Factory : public Pm4Factory { - public: - explicit Gfx11Factory(const AgentInfo* agent_info) - : Pm4Factory(BlockInfoMap(block_table_, sizeof(block_table_))) { - Init(agent_info); - } - Gfx11Factory(const GpuBlockInfo** table, const uint32_t& size, const AgentInfo* agent_info) - : Pm4Factory(BlockInfoMap(table, size)) { - Init(agent_info); - } - bool IsGFX11() const override { return true; } - - virtual int GetAccumLowID() const override { return 1; }; - virtual int GetAccumHiID() const override { return 1; }; - - protected: - // void ConstructTable(const AgentInfo* agent_info); - void Init(const AgentInfo* agent_info); - // void ConstructBuilders(const AgentInfo* agent_info); - static const GpuBlockInfo* block_table_[AQLPROFILE_BLOCKS_NUMBER]; -}; - // Gfx builders init -// void Gfx11Factory::ConstructBuilders(const AgentInfo* agent_info) { void Gfx11Factory::Init(const AgentInfo* agent_info) { Pm4Factory::cmd_builder_ = new pm4_builder::Gfx11CmdBuilder(nullptr); if (Pm4Factory::cmd_builder_ == NULL) throw aql_profile_exc_msg("CmdBuilder allocation failed"); diff --git a/projects/aqlprofile/src/core/gfx11_factory.h b/projects/aqlprofile/src/core/gfx11_factory.h new file mode 100644 index 0000000000..967da0ad1f --- /dev/null +++ b/projects/aqlprofile/src/core/gfx11_factory.h @@ -0,0 +1,62 @@ +// MIT License +// +// Copyright (c) 2017-2025 Advanced Micro Devices, Inc. +// +// 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 _GFX11_FACTORY_H_ +#define _GFX11_FACTORY_H_ +#include "core/pm4_factory.h" + +namespace aql_profile { + +// Gfx11 factory class +class Gfx11Factory : public Pm4Factory { + public: + explicit Gfx11Factory(const AgentInfo* agent_info) + : Pm4Factory(BlockInfoMap(block_table_, sizeof(block_table_))) { + Init(agent_info); + } + Gfx11Factory(const GpuBlockInfo** table, const uint32_t& size, const AgentInfo* agent_info) + : Pm4Factory(BlockInfoMap(table, size)) { + Init(agent_info); + } + bool IsGFX11() const override { return true; } + + virtual int GetAccumLowID() const override { return 1; } + virtual int GetAccumHiID() const override { return 1; } + + protected: + void Init(const AgentInfo* agent_info); + static const GpuBlockInfo* block_table_[AQLPROFILE_BLOCKS_NUMBER]; +}; + +// Gfx11.5 factory class +class Gfx115xFactory : public Gfx11Factory { + public: + explicit Gfx115xFactory(const AgentInfo* agent_info); + virtual ~Gfx115xFactory(); + + protected: + static const GpuBlockInfo* block_table_[AQLPROFILE_BLOCKS_NUMBER]; +}; + +} // namespace aql_profile + +#endif // _GFX11_FACTORY_H_ diff --git a/projects/aqlprofile/src/core/pm4_factory.h b/projects/aqlprofile/src/core/pm4_factory.h index 70deaaffce..f9317a86f2 100644 --- a/projects/aqlprofile/src/core/pm4_factory.h +++ b/projects/aqlprofile/src/core/pm4_factory.h @@ -60,15 +60,16 @@ aqlprofile_agent_handle_t RegisterAgent(const aqlprofile_agent_info_v1_t* agent_ // GPU enumeration enum gpu_id_t { - INVAL_GPU_ID, // invalid GPU id - GFX9_GPU_ID, // generic Gfx9 id - MI100_GPU_ID, // Mi100 GPU id - MI200_GPU_ID, // Mi200 GPU id - MI300_GPU_ID, // Mi300 GPU id - MI350_GPU_ID, // Mi350 GPU id - GFX10_GPU_ID, // generic Gfx10 id - GFX11_GPU_ID, // generic Gfx11 id - GFX12_GPU_ID, // generic Gfx12 id + INVAL_GPU_ID, // invalid GPU id + GFX9_GPU_ID, // generic Gfx9 id + MI100_GPU_ID, // Mi100 GPU id + MI200_GPU_ID, // Mi200 GPU id + MI300_GPU_ID, // Mi300 GPU id + MI350_GPU_ID, // Mi350 GPU id + GFX10_GPU_ID, // generic Gfx10 id + GFX11_GPU_ID, // generic Gfx11 id + GFX115X_GPU_ID, // Gfx11.5x id + GFX12_GPU_ID, // generic Gfx12 id }; // Block info map class @@ -274,6 +275,8 @@ class Pm4Factory { static Pm4Factory* Gfx10Create(const AgentInfo* agent_info); // Create GFX11 generic factory static Pm4Factory* Gfx11Create(const AgentInfo* agent_info); + // Create GFX11.5 factory + static Pm4Factory* Gfx115xCreate(const AgentInfo* agent_info); // Create GFX12 generic factory static Pm4Factory* Gfx12Create(const AgentInfo* agent_info); // Create MI100 factory @@ -323,6 +326,10 @@ inline Pm4Factory* Pm4Factory::Create(const AgentInfo* agent_info, gpu_id_t gpu_ case GFX11_GPU_ID: it->second = Gfx11Create(agent_info); break; + // Create Gfx11.5 factory + case GFX115X_GPU_ID: + it->second = Gfx115xCreate(agent_info); + break; case GFX12_GPU_ID: it->second = Gfx12Create(agent_info); break; @@ -409,7 +416,7 @@ inline gpu_id_t Pm4Factory::GetGpuId(std::string_view gfx_ip) { {"gfx908", MI100_GPU_ID}, {"gfx90a", MI200_GPU_ID}, {"gfx900", GFX9_GPU_ID}, {"gfx902", GFX9_GPU_ID}, {"gfx906", GFX9_GPU_ID}, {"gfx94", MI300_GPU_ID}, {"gfx95", MI350_GPU_ID}, {"gfx10", GFX10_GPU_ID}, {"gfx11", GFX11_GPU_ID}, - {"gfx12", GFX12_GPU_ID}, + {"gfx115", GFX115X_GPU_ID}, {"gfx12", GFX12_GPU_ID}, }; for (const auto& [name, id] : gfxip_map) { diff --git a/projects/aqlprofile/src/core/tests/CMakeLists.txt b/projects/aqlprofile/src/core/tests/CMakeLists.txt index 15f8b713a1..996fd2c3a5 100644 --- a/projects/aqlprofile/src/core/tests/CMakeLists.txt +++ b/projects/aqlprofile/src/core/tests/CMakeLists.txt @@ -217,6 +217,7 @@ SET(AQLPROFILE_V2_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../spm_data.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../gfx12_factory.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../gfx11_factory.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../gfx115x_factory.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../gfx10_factory.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../gfx940_factory.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../gfx908_factory.cpp