Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ function(rocprofiler_sdk_pc_sampling_disabled _VAR)

if("${pc-sampling-gpu-0-gfx-info}" MATCHES "^gfx90a$"
OR "${pc-sampling-gpu-0-gfx-info}" MATCHES "^gfx94[0-9]$"
OR "${pc-sampling-gpu-0-gfx-info}" MATCHES "^gfx95[0-9]$")
OR "${pc-sampling-gpu-0-gfx-info}" MATCHES "^gfx95[0-9]$"
OR "${pc-sampling-gpu-0-gfx-info}" MATCHES "^gfx12[0-9][0-9]$")
# PC sampling is enabled on this architecture.
set(${_VAR}
FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,18 @@ save(ArchiveT& ar, rocprofiler_pc_sampling_snapshot_v0_t data)
ROCP_SDK_SAVE_DATA_BITFIELD("arb_state_stall_brmsg", arb_state_stall_brmsg);
}

template <typename ArchiveT>
void
save(ArchiveT& ar, rocprofiler_pc_sampling_memory_counters_t data)
{
ROCP_SDK_SAVE_DATA_BITFIELD("load_cnt", load_cnt);
ROCP_SDK_SAVE_DATA_BITFIELD("store_cnt", store_cnt);
ROCP_SDK_SAVE_DATA_BITFIELD("bvh_cnt", bvh_cnt);
ROCP_SDK_SAVE_DATA_BITFIELD("sample_cnt", sample_cnt);
ROCP_SDK_SAVE_DATA_BITFIELD("ds_cnt", ds_cnt);
ROCP_SDK_SAVE_DATA_BITFIELD("km_cnt", km_cnt);
}

template <typename ArchiveT>
void
save(ArchiveT& ar, rocprofiler_pc_sampling_record_stochastic_v0_t data)
Expand All @@ -1076,7 +1088,11 @@ save(ArchiveT& ar, rocprofiler_pc_sampling_record_stochastic_v0_t data)
ROCP_SDK_SAVE_DATA_BITFIELD("wave_cnt", wave_count);
ROCP_SDK_SAVE_DATA_FIELD(snapshot);

// TODO: add memory counters
// serializing memory counters only if they exist
if(data.flags.has_memory_counter)
{
ROCP_SDK_SAVE_DATA_FIELD(memory_counters);
}
}

template <typename ArchiveT>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ is_pc_sampling_method_supported(rocprofiler_pc_sampling_method_t method,
else
return ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_KERNEL;
}
else if(agent_name.find("gfx12") == 0)
{
// 1.5 version enables host-trap PC sampling on gfx12
if(pcs_ioctl_version >= PC_SAMPLING_IOCTL_COMPUTE_VERSION(1, 5))
return ROCPROFILER_STATUS_SUCCESS;
else
return ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_KERNEL;
}
}
else if(method == ROCPROFILER_PC_SAMPLING_METHOD_STOCHASTIC)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
set(ROCPROFILER_LIB_PC_SAMPLING_PARSER_SOURCES pc_record_interface.cpp)
set(ROCPROFILER_LIB_PC_SAMPLING_PARSER_HEADERS
correlation.hpp gfx9.hpp gfx11.hpp parser_types.hpp pc_record_interface.hpp rocr.h
translation.hpp gfx950.hpp)
correlation.hpp
gfx9.hpp
gfx11.hpp
parser_types.hpp
pc_record_interface.hpp
rocr.h
translation.hpp
gfx950.hpp
gfx12.hpp)

target_sources(
rocprofiler-sdk-object-library PRIVATE ${ROCPROFILER_LIB_PC_SAMPLING_PARSER_SOURCES}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ pcsample_status_t inline parse_buffer(generic_sample_t* buffer,
{
parseSample_func = _parse_buffer<GFX11, PcSamplingRecordT>;
}
else if(gfxip_major == 12)
{
parseSample_func = _parse_buffer<GFX12, PcSamplingRecordT>;
}
else
{
return PCSAMPLE_STATUS_INVALID_GFXIP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ class GFX11
ISSUE_FLAT = 31,
ISSUE_BRMSG = 31,
};

// max number of waves per SIMD
static constexpr size_t max_wave_cnt = 16;
static constexpr uint32_t gfx_ip_major = 11;
static constexpr uint32_t gfx_ip_minor = 0;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// MIT License
//
// Copyright (c) 2023-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.

#pragma once

class GFX12
{
public:
enum inst_type_issued
{
TYPE_VALU = 0,
TYPE_SCALAR,
TYPE_TEX,
TYPE_LDS,
TYPE_LDS_DIRECT,
TYPE_EXPORT,
TYPE_MESSAGE,
TYPE_BARRIER,
TYPE_BRANCH_NOT_TAKEN,
TYPE_BRANCH_TAKEN,
TYPE_JUMP,
TYPE_OTHER,
TYPE_NO_INST, // regspec call this NONE
TYPE_DUAL_VALU,
TYPE_FLAT,
TYPE_MATRIX,
TYPE_LAST
};

enum reason_not_issued
{
REASON_NO_INSTRUCTION_AVAILABLE = 0,
REASON_ALU_DEPENDENCY,
REASON_WAITCNT,
REASON_ARBITER_NOT_WIN,
REASON_SLEEP_WAIT,
REASON_BARRIER_WAIT,
REASON_OTHER_WAIT,
REASON_INTERNAL_INSTRUCTION,
REASON_LAST,
REASON_ARBITER_WIN_EX_STALL = 31,
};

enum arb_state
{
ISSUE_BRMSG = 0,
ISSUE_EXP,
ISSUE_LDS_DIRECT,
ISSUE_LDS,
ISSUE_VMEM_TEX,
ISSUE_SCALAR,
ISSUE_VALU,
ISSUE_LAST,
ISSUE_MATRIX = 31,
ISSUE_FLAT = 31,
ISSUE_MISC = 31,
};

// max number of waves per SIMD
static constexpr size_t max_wave_cnt = 16;
Comment thread
vlaindic marked this conversation as resolved.
static constexpr uint32_t gfx_ip_major = 12;
static constexpr uint32_t gfx_ip_minor = 0;
};
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,11 @@ class GFX9
ISSUE_LDS_DIRECT = 31,
ISSUE_BRMSG = 31,
};

// max number of waves per CU
static constexpr size_t max_wave_cnt = 32;
static constexpr uint32_t gfx_ip_major = 9;
// By default, we assume the GFX942 in the SDK,
// as that's the first arch supporting PC sampling.
static constexpr uint32_t gfx_ip_minor = 4;
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@
#pragma once

class GFX950 : public GFX9
{};
{
public:
// Overriding the minor ip version
static constexpr uint32_t gfx_ip_minor = 5;
};
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ PCSamplingParserContext::parse(const upcoming_samples_t& upcoming,
{
parseSample_func = _get_parse_func_for_method<GFX11>(pcs_method);
}
else if(gfxip_major == 12)
{
parseSample_func = _get_parse_func_for_method<GFX12>(pcs_method);
}
else
{
return PCSAMPLE_STATUS_INVALID_GFXIP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ set(ROCPROFILER_LIB_PC_SAMPLING_PARSER_ID_TEST_SOURCES
set(ROCPROFILER_LIB_PC_SAMPLING_PARSER_BENCH_TEST_SOURCES
${ROCPROFILER_LIB_PC_SAMPLING_PARSER_TEST_SOURCES} benchmark_test.cpp)
set(ROCPROFILER_LIB_PC_SAMPLING_PARSER_GFX9_TEST_SOURCES
${ROCPROFILER_LIB_PC_SAMPLING_PARSER_TEST_SOURCES} gfx9test.hpp gfx9test.cpp
${ROCPROFILER_LIB_PC_SAMPLING_PARSER_TEST_SOURCES} gfxtest.hpp gfx9test.cpp
gfx950test.cpp)
set(ROCPROFILER_LIB_PC_SAMPLING_PARSER_MULTIGPU_TEST_SOURCES
${ROCPROFILER_LIB_PC_SAMPLING_PARSER_TEST_SOURCES} multigpu.cpp)

set(ROCPROFILER_LIB_PC_SAMPLING_PARSER_GFX12_TEST_SOURCES
${ROCPROFILER_LIB_PC_SAMPLING_PARSER_TEST_SOURCES} gfxtest.hpp gfx12test.cpp)

add_executable(pcs_gfx9_test)

target_sources(pcs_gfx9_test
Expand Down Expand Up @@ -98,3 +101,26 @@ set_tests_properties(
${pcs_thread_test_TESTS}
PROPERTIES TIMEOUT 75 LABELS "unittests" FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")

add_executable(pcs_gfx12_test)

target_sources(pcs_gfx12_test
PRIVATE ${ROCPROFILER_LIB_PC_SAMPLING_PARSER_GFX12_TEST_SOURCES})
target_include_directories(pcs_gfx12_test PRIVATE ${PCTEST_INCLUDE_DIR})

target_link_libraries(
pcs_gfx12_test
PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library
rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest
GTest::gtest_main)

gtest_add_tests(
TARGET pcs_gfx12_test
SOURCES ${ROCPROFILER_LIB_PC_SAMPLING_PARSER_GFX12_TEST_SOURCES}
TEST_LIST pcs_gfx12_test_TESTS
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

set_tests_properties(
${pcs_gfx12_test_TESTS}
PROPERTIES TIMEOUT 45 LABELS "unittests" FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
Loading
Loading