[SDK][rocprofv3] MI300 Stochastic PC sampling (#92)

* MI300 Stochastic PC sampling SDK API implementation

* ROCProfV3: Stochastic PC sampling Support (#94)

* ROCProfV3: MI300 Stochastic PC sampling initial draft

* ROCProfV3: Initial Stochastic PC sampling Tests (#95)

ROCProfV3: Initial Stochastic PC sampling tests

* Update rocprofiler_pc_sampling_record_stochastic_v0_t

- update doxygen docs for members
- replace rocprofiler_correlation_id_t with rocprofiler_async_correlation_id_t

* Relax the check in JSON tests

* drain PC sampling buffer during finalize_rocprofv3

* Increase timeout for "Test Install Build" step

- 10 minutes -> 20 minutes
- "Test Installed Packages" has 20 minutes so "Test Install Build" should also

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
This commit is contained in:
Indic, Vladimir
2025-03-21 20:40:45 +01:00
committed by GitHub
parent c06feccf2a
commit 49ce79a5b5
98 changed files with 5266 additions and 1031 deletions
@@ -1,7 +1,7 @@
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
stochastic_records.h translation.hpp)
translation.hpp)
target_sources(
rocprofiler-sdk-object-library PRIVATE ${ROCPROFILER_LIB_PC_SAMPLING_PARSER_SOURCES}
@@ -241,6 +241,8 @@ add_upcoming_samples(const device_handle device,
auto& pc_sample = samples[p];
pc_sample = copySample<GFXIP, PcSamplingRecordT>((const void*) (buffer + p));
// skip invalid samples
if(pc_sample.size == 0) continue;
// Convert PC -> (loaded code object id containing PC, offset within code object)
if(!cache_addr_range.inrange(snap->pc))
@@ -32,7 +32,7 @@ public:
TYPE_TEX,
TYPE_LDS,
TYPE_LDS_DIRECT,
TYPE_EXP,
TYPE_EXPORT,
TYPE_MESSAGE,
TYPE_BARRIER,
TYPE_BRANCH_NOT_TAKEN,
@@ -47,15 +47,15 @@ public:
enum reason_not_issued
{
REASON_NOT_AVAILABLE = 0,
REASON_ALU,
REASON_NO_INSTRUCTION_AVAILABLE = 0,
REASON_ALU_DEPENDENCY,
REASON_WAITCNT,
REASON_ARBITER,
REASON_SLEEP,
REASON_BARRIER,
REASON_ARBITER_NOT_WIN,
REASON_SLEEP_WAIT,
REASON_BARRIER_WAIT,
REASON_OTHER_WAIT,
REASON_INTERNAL = 31,
REASON_EX_STALL = 31,
REASON_INTERNAL_INSTRUCTION = 31,
REASON_ARBITER_WIN_EX_STALL = 31,
};
enum arb_state
@@ -25,6 +25,7 @@
class GFX9
{
public:
// matches values specified in perf_snapshot_data register
enum inst_type_issued
{
TYPE_VALU = 0,
@@ -33,7 +34,7 @@ public:
TYPE_TEX,
TYPE_LDS,
TYPE_FLAT,
TYPE_EXP,
TYPE_EXPORT,
TYPE_MESSAGE,
TYPE_BARRIER,
TYPE_BRANCH_NOT_TAKEN,
@@ -46,30 +47,32 @@ public:
TYPE_LDS_DIRECT = 31
};
// matces values specified in perf_snapshot_data register
enum reason_not_issued
{
REASON_NOT_AVAILABLE = 0,
REASON_ALU,
REASON_NO_INSTRUCTION_AVAILABLE = 0,
REASON_ALU_DEPENDENCY,
REASON_WAITCNT,
REASON_INTERNAL,
REASON_BARRIER,
REASON_ARBITER,
REASON_EX_STALL,
REASON_INTERNAL_INSTRUCTION,
REASON_BARRIER_WAIT,
REASON_ARBITER_NOT_WIN,
REASON_ARBITER_WIN_EX_STALL,
REASON_OTHER_WAIT,
REASON_LAST,
REASON_SLEEP = 31
REASON_SLEEP_WAIT = 31
};
// matches the order of arb_state bits in perf_snapshot_data register
enum arb_state
{
ISSUE_VALU = 0,
ISSUE_MATRIX,
ISSUE_SCALAR,
ISSUE_VMEM_TEX,
ISSUE_LDS,
ISSUE_FLAT,
ISSUE_MISC = 0,
ISSUE_EXP,
ISSUE_MISC,
ISSUE_FLAT,
ISSUE_LDS,
ISSUE_VMEM_TEX,
ISSUE_SCALAR,
ISSUE_MATRIX,
ISSUE_VALU,
ISSUE_LAST,
ISSUE_LDS_DIRECT = 31,
ISSUE_BRMSG = 31,
@@ -22,6 +22,8 @@
#include "lib/rocprofiler-sdk/pc_sampling/parser/pc_record_interface.hpp"
#include "lib/common/utility.hpp"
template <>
uint64_t
PCSamplingParserContext::alloc<rocprofiler_pc_sampling_record_host_trap_v0_t>(
@@ -127,6 +129,43 @@ PCSamplingParserContext::shouldFlipRocrBuffer(const dispatch_pkt_id_t& pkt) cons
return corr_map->checkDispatch(pkt);
}
template <typename PcSamplingRecordKindT>
inline void
emplace_records_in_buffer(rocprofiler::buffer::instance* buff,
const PcSamplingRecordKindT* samples,
size_t num_samples,
rocprofiler_pc_sampling_record_kind_t record_kind)
{
for(size_t i = 0; i < num_samples; i++)
buff->emplace(ROCPROFILER_BUFFER_CATEGORY_PC_SAMPLING, record_kind, samples[i]);
}
template <>
inline void
emplace_records_in_buffer<rocprofiler_pc_sampling_record_stochastic_v0_t>(
rocprofiler::buffer::instance* buff,
const rocprofiler_pc_sampling_record_stochastic_v0_t* samples,
size_t num_samples,
rocprofiler_pc_sampling_record_kind_t record_kind)
{
for(size_t i = 0; i < num_samples; i++)
{
if(samples[i].size == 0)
{
// `size == 0` internally means invalid sample, so generate it.
auto invalid_sample = rocprofiler::common::init_public_api_struct(
rocprofiler_pc_sampling_record_invalid_t{});
buff->emplace(ROCPROFILER_BUFFER_CATEGORY_PC_SAMPLING,
ROCPROFILER_PC_SAMPLING_RECORD_INVALID_SAMPLE,
invalid_sample);
}
else
{
buff->emplace(ROCPROFILER_BUFFER_CATEGORY_PC_SAMPLING, record_kind, samples[i]);
}
}
}
template <typename PcSamplingRecordKindT>
void
PCSamplingParserContext::generate_upcoming_pc_record(
@@ -141,8 +180,7 @@ PCSamplingParserContext::generate_upcoming_pc_record(
if(!buff)
throw std::runtime_error(fmt::format("Buffer with id: {} does not exists", buff_id.handle));
for(size_t i = 0; i < num_samples; i++)
buff->emplace(ROCPROFILER_BUFFER_CATEGORY_PC_SAMPLING, record_kind, samples[i]);
emplace_records_in_buffer(buff, samples, num_samples, record_kind);
}
template <>
@@ -25,9 +25,9 @@
#include "lib/rocprofiler-sdk/buffer.hpp"
#include "lib/rocprofiler-sdk/pc_sampling/parser/correlation.hpp"
#include "lib/rocprofiler-sdk/pc_sampling/parser/parser_types.hpp"
#include "lib/rocprofiler-sdk/pc_sampling/parser/stochastic_records.h"
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/pc_sampling.h>
#include <rocprofiler-sdk/cxx/hash.hpp>
#include <rocprofiler-sdk/cxx/operators.hpp>
@@ -30,75 +30,113 @@
#include <rocprofiler-sdk/cxx/operators.hpp>
#include <gtest/gtest.h>
#include <cassert>
#include <cstddef>
#define GFXIP_MAJOR 9
#define TYPECHECK(x) \
snapshots.push_back(rocprofiler_pc_sampling_snapshot_v1_t{.dual_issue_valu = 0, \
.inst_type = ::PCSAMPLE::x, \
.reason_not_issued = 0, \
.arb_state_issue = 0, \
.arb_state_stall = 0});
#define UNROLL_TYPECHECK() \
TYPECHECK(TYPE_VALU); \
TYPECHECK(TYPE_MATRIX); \
TYPECHECK(TYPE_SCALAR); \
TYPECHECK(TYPE_TEX); \
TYPECHECK(TYPE_LDS); \
TYPECHECK(TYPE_FLAT); \
TYPECHECK(TYPE_EXP); \
TYPECHECK(TYPE_MESSAGE); \
TYPECHECK(TYPE_BARRIER); \
TYPECHECK(TYPE_BRANCH_NOT_TAKEN); \
TYPECHECK(TYPE_BRANCH_TAKEN); \
TYPECHECK(TYPE_JUMP); \
TYPECHECK(TYPE_OTHER); \
TYPECHECK(TYPE_NO_INST);
#define RECORD_INST_TYPE(x) \
{ \
PcSamplingRecordT sample{}; \
sample.inst_type = ROCPROFILER_PC_SAMPLING_INSTRUCTION##_##x; \
snapshots.push_back(sample); \
}
#define REASONCHECK(x) \
snapshots.push_back(rocprofiler_pc_sampling_snapshot_v1_t{.dual_issue_valu = 0, \
.inst_type = 0, \
.reason_not_issued = ::PCSAMPLE::x, \
.arb_state_issue = 0, \
.arb_state_stall = 0});
#define UNROLL_REASONCHECK(x) \
REASONCHECK(REASON_NOT_AVAILABLE); \
REASONCHECK(REASON_ALU); \
REASONCHECK(REASON_WAITCNT); \
REASONCHECK(REASON_INTERNAL); \
REASONCHECK(REASON_BARRIER); \
REASONCHECK(REASON_ARBITER); \
REASONCHECK(REASON_EX_STALL); \
REASONCHECK(REASON_OTHER_WAIT);
#define GENERATE_RECORDS_INST_TYPE() \
RECORD_INST_TYPE(TYPE_VALU); \
RECORD_INST_TYPE(TYPE_MATRIX); \
RECORD_INST_TYPE(TYPE_SCALAR); \
RECORD_INST_TYPE(TYPE_TEX); \
RECORD_INST_TYPE(TYPE_LDS); \
RECORD_INST_TYPE(TYPE_FLAT); \
RECORD_INST_TYPE(TYPE_EXPORT); \
RECORD_INST_TYPE(TYPE_MESSAGE); \
RECORD_INST_TYPE(TYPE_BARRIER); \
RECORD_INST_TYPE(TYPE_BRANCH_NOT_TAKEN); \
RECORD_INST_TYPE(TYPE_BRANCH_TAKEN); \
RECORD_INST_TYPE(TYPE_JUMP); \
RECORD_INST_TYPE(TYPE_OTHER); \
RECORD_INST_TYPE(TYPE_NO_INST);
#define ARBCHECK1(x, y) \
snapshots.push_back( \
rocprofiler_pc_sampling_snapshot_v1_t{.dual_issue_valu = 0, \
.inst_type = 0, \
.reason_not_issued = 0, \
.arb_state_issue = 1 << ::PCSAMPLE::x, \
.arb_state_stall = 1 << ::PCSAMPLE::y});
#define ARBCHECK2(x) \
ARBCHECK1(x, ISSUE_VALU); \
ARBCHECK1(x, ISSUE_MATRIX); \
ARBCHECK1(x, ISSUE_SCALAR); \
ARBCHECK1(x, ISSUE_VMEM_TEX); \
ARBCHECK1(x, ISSUE_LDS); \
ARBCHECK1(x, ISSUE_FLAT); \
ARBCHECK1(x, ISSUE_EXP); \
ARBCHECK1(x, ISSUE_MISC);
#define RECORD_NOT_ISSUED_REASON(x) \
{ \
PcSamplingRecordT sample{}; \
sample.snapshot.reason_not_issued = ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED##_##x; \
snapshots.push_back(sample); \
}
#define UNROLL_ARBCHECK() \
ARBCHECK2(ISSUE_VALU); \
ARBCHECK2(ISSUE_MATRIX); \
ARBCHECK2(ISSUE_SCALAR); \
ARBCHECK2(ISSUE_VMEM_TEX); \
ARBCHECK2(ISSUE_LDS); \
ARBCHECK2(ISSUE_FLAT); \
ARBCHECK2(ISSUE_EXP); \
ARBCHECK2(ISSUE_MISC);
#define GENERATE_RECORDS_NOT_ISSUED_REASON(x) \
RECORD_NOT_ISSUED_REASON(REASON_NO_INSTRUCTION_AVAILABLE); \
RECORD_NOT_ISSUED_REASON(REASON_ALU_DEPENDENCY); \
RECORD_NOT_ISSUED_REASON(REASON_WAITCNT); \
RECORD_NOT_ISSUED_REASON(REASON_INTERNAL_INSTRUCTION); \
RECORD_NOT_ISSUED_REASON(REASON_BARRIER_WAIT); \
RECORD_NOT_ISSUED_REASON(REASON_ARBITER_NOT_WIN); \
RECORD_NOT_ISSUED_REASON(REASON_ARBITER_WIN_EX_STALL); \
RECORD_NOT_ISSUED_REASON(REASON_OTHER_WAIT);
#define RECORD_ARBSTATE_ISSUE_STALL(x, y) \
{ \
PcSamplingRecordT sample{}; \
sample.snapshot.arb_state##_##x = 1; \
sample.snapshot.arb_state##_##y = 1; \
snapshots.push_back(sample); \
}
// Respecting the order of elements in GFX9:arb_state that match the order of arb_state bits
// in perf_snapshot_data register
#define RECORD_ARBSTATE_ISSUE(x) \
RECORD_ARBSTATE_ISSUE_STALL(x, stall_misc); \
RECORD_ARBSTATE_ISSUE_STALL(x, stall_exp); \
RECORD_ARBSTATE_ISSUE_STALL(x, stall_flat); \
RECORD_ARBSTATE_ISSUE_STALL(x, stall_lds); \
RECORD_ARBSTATE_ISSUE_STALL(x, stall_vmem_tex); \
RECORD_ARBSTATE_ISSUE_STALL(x, stall_scalar); \
RECORD_ARBSTATE_ISSUE_STALL(x, stall_matrix); \
RECORD_ARBSTATE_ISSUE_STALL(x, stall_valu);
// Respecting the order of elements in GFX9:arb_state that match the order of arb_state bits
// in perf_snapshot_data register
#define GENERATE_RECORDS_ARBSTATE_ISSUE() \
RECORD_ARBSTATE_ISSUE(issue_misc); \
RECORD_ARBSTATE_ISSUE(issue_exp); \
RECORD_ARBSTATE_ISSUE(issue_flat); \
RECORD_ARBSTATE_ISSUE(issue_lds); \
RECORD_ARBSTATE_ISSUE(issue_vmem_tex); \
RECORD_ARBSTATE_ISSUE(issue_scalar); \
RECORD_ARBSTATE_ISSUE(issue_matrix); \
RECORD_ARBSTATE_ISSUE(issue_valu);
#define NON_GFX9_ARBSTATE_IS_ZERO(x, y) \
EXPECT_EQ(x.snapshot.arb_state_issue_lds_direct, 0); \
EXPECT_EQ(y.snapshot.arb_state_issue_lds_direct, 0); \
EXPECT_EQ(x.snapshot.arb_state_issue_brmsg, 0); \
EXPECT_EQ(y.snapshot.arb_state_issue_brmsg, 0); \
\
EXPECT_EQ(x.snapshot.arb_state_stall_lds_direct, 0); \
EXPECT_EQ(y.snapshot.arb_state_stall_lds_direct, 0); \
EXPECT_EQ(x.snapshot.arb_state_stall_brmsg, 0); \
EXPECT_EQ(y.snapshot.arb_state_stall_brmsg, 0);
#define MATCH_ARBSTATE(x, y) \
EXPECT_EQ(x.snapshot.arb_state_issue_valu, y.snapshot.arb_state_issue_valu); \
EXPECT_EQ(x.snapshot.arb_state_issue_matrix, y.snapshot.arb_state_issue_matrix); \
EXPECT_EQ(x.snapshot.arb_state_issue_lds, y.snapshot.arb_state_issue_lds); \
EXPECT_EQ(x.snapshot.arb_state_issue_scalar, y.snapshot.arb_state_issue_scalar); \
EXPECT_EQ(x.snapshot.arb_state_issue_vmem_tex, y.snapshot.arb_state_issue_vmem_tex); \
EXPECT_EQ(x.snapshot.arb_state_issue_flat, y.snapshot.arb_state_issue_flat); \
EXPECT_EQ(x.snapshot.arb_state_issue_exp, y.snapshot.arb_state_issue_exp); \
EXPECT_EQ(x.snapshot.arb_state_issue_misc, y.snapshot.arb_state_issue_misc); \
\
EXPECT_EQ(x.snapshot.arb_state_stall_valu, y.snapshot.arb_state_stall_valu); \
EXPECT_EQ(x.snapshot.arb_state_stall_matrix, y.snapshot.arb_state_stall_matrix); \
EXPECT_EQ(x.snapshot.arb_state_stall_lds, y.snapshot.arb_state_stall_lds); \
EXPECT_EQ(x.snapshot.arb_state_stall_scalar, y.snapshot.arb_state_stall_scalar); \
EXPECT_EQ(x.snapshot.arb_state_stall_vmem_tex, y.snapshot.arb_state_stall_vmem_tex); \
EXPECT_EQ(x.snapshot.arb_state_stall_flat, y.snapshot.arb_state_stall_flat); \
EXPECT_EQ(x.snapshot.arb_state_stall_exp, y.snapshot.arb_state_stall_exp); \
EXPECT_EQ(x.snapshot.arb_state_stall_misc, y.snapshot.arb_state_stall_misc); \
\
NON_GFX9_ARBSTATE_IS_ZERO(x, y)
template <typename PcSamplingRecordT>
class WaveSnapTest
@@ -134,10 +172,11 @@ public:
snap.correlation_id = dispatch->getMockId().raw;
snap.perf_snapshot_data = (inst_type << 3) | (reason << 7);
snap.perf_snapshot_data |= 0x1; // sample is valid
snap.perf_snapshot_data |= (arb_issue << 10) | (arb_stall << 18);
snap.perf_snapshot_data1 = wave_cnt;
assert(dispatch.get());
EXPECT_NE(dispatch.get(), nullptr);
dispatch->submit(packet_union_t{.snap = snap});
};
@@ -156,180 +195,213 @@ public:
this->buffer->genUpcomingSamples(max_wave_number);
for(size_t i = 0; i < max_wave_number; i++)
this->genPCSample(
i, GFX9::TYPE_LDS, GFX9::REASON_ALU, GFX9::ISSUE_VALU, GFX9::ISSUE_VALU);
i, GFX9::TYPE_LDS, GFX9::REASON_ALU_DEPENDENCY, GFX9::ISSUE_VALU, GFX9::ISSUE_VALU);
}
void CheckBuffers() override
{
auto parsed = this->buffer->get_parsed_buffer(9); // GFXIP==9
assert(parsed.size() == 1);
assert(parsed[0].size() == max_wave_number);
EXPECT_EQ(parsed.size(), 1);
EXPECT_EQ(parsed[0].size(), max_wave_number);
for(size_t i = 0; i < max_wave_number; i++)
assert(parsed[0][i].wave_count == i);
EXPECT_EQ(parsed[0][i].wave_count, i);
}
const size_t max_wave_number = 64;
std::vector<PcSamplingRecordT> snapshots;
};
// class InstTypeTest : public WaveSnapTest
// {
// public:
// void FillBuffers() override
// {
// // Loop over inst_type_issued
// UNROLL_TYPECHECK();
// buffer->genUpcomingSamples(GFX9::TYPE_LAST);
// for(int i = 0; i < GFX9::TYPE_LAST; i++)
// genPCSample(i, i, GFX9::REASON_ALU, GFX9::ISSUE_MATRIX, GFX9::ISSUE_MATRIX);
// }
template <typename PcSamplingRecordT>
class InstTypeTest : public WaveSnapTest<PcSamplingRecordT>
{
public:
void FillBuffers() override
{
// Loop over inst_type_issued
GENERATE_RECORDS_INST_TYPE();
this->buffer->genUpcomingSamples(GFX9::TYPE_LAST);
for(int i = 0; i < GFX9::TYPE_LAST; i++)
this->genPCSample(
i, i, GFX9::REASON_ALU_DEPENDENCY, GFX9::ISSUE_MATRIX, GFX9::ISSUE_MATRIX);
}
// void CheckBuffers() override
// {
// auto parsed = buffer->get_parsed_buffer(9); // GFXIP==9
// assert(parsed.size() == 1);
// assert(parsed[0].size() == GFX9::TYPE_LAST);
// assert(snapshots.size() == GFX9::TYPE_LAST);
void CheckBuffers() override
{
auto parsed = this->buffer->get_parsed_buffer(9); // GFXIP==9
EXPECT_EQ(parsed.size(), 1);
EXPECT_EQ(parsed[0].size(), GFX9::TYPE_LAST);
EXPECT_EQ(snapshots.size(), GFX9::TYPE_LAST);
// for(size_t i = 0; i < GFX9::TYPE_LAST; i++)
// assert(snapshots[i].inst_type == parsed[0][i].snapshot.inst_type);
// }
for(size_t i = 0; i < GFX9::TYPE_LAST; i++)
EXPECT_EQ(snapshots[i].inst_type, parsed[0][i].inst_type);
}
// std::vector<rocprofiler_pc_sampling_snapshot_v1_t> snapshots;
// };
std::vector<PcSamplingRecordT> snapshots;
};
// class StallReasonTest : public WaveSnapTest
// {
// public:
// void FillBuffers() override
// {
// // Loop over reason_not_issued
// UNROLL_REASONCHECK();
// buffer->genUpcomingSamples(GFX9::REASON_LAST);
// for(int i = 0; i < GFX9::REASON_LAST; i++)
// genPCSample(i, GFX9::TYPE_MATRIX, i, GFX9::ISSUE_MATRIX, GFX9::ISSUE_MATRIX);
// }
template <typename PcSamplingRecordT>
class StallReasonTest : public WaveSnapTest<PcSamplingRecordT>
{
public:
void FillBuffers() override
{
// Loop over reason_not_issued
GENERATE_RECORDS_NOT_ISSUED_REASON();
this->buffer->genUpcomingSamples(GFX9::REASON_LAST);
for(int i = 0; i < GFX9::REASON_LAST; i++)
this->genPCSample(i, GFX9::TYPE_MATRIX, i, GFX9::ISSUE_MATRIX, GFX9::ISSUE_MATRIX);
}
// void CheckBuffers() override
// {
// auto parsed = buffer->get_parsed_buffer(9); // GFXIP==9
// assert(parsed.size() == 1);
// assert(parsed[0].size() == GFX9::REASON_LAST);
// assert(snapshots.size() == GFX9::REASON_LAST);
void CheckBuffers() override
{
auto parsed = this->buffer->get_parsed_buffer(9); // GFXIP==9
EXPECT_EQ(parsed.size(), 1);
EXPECT_EQ(parsed[0].size(), GFX9::REASON_LAST);
EXPECT_EQ(snapshots.size(), GFX9::REASON_LAST);
// for(size_t i = 0; i < GFX9::REASON_LAST; i++)
// assert(snapshots[i].reason_not_issued == parsed[0][i].snapshot.reason_not_issued);
// }
for(size_t i = 0; i < GFX9::REASON_LAST; i++)
EXPECT_EQ(snapshots[i].snapshot.reason_not_issued,
parsed[0][i].snapshot.reason_not_issued);
}
// std::vector<rocprofiler_pc_sampling_snapshot_v1_t> snapshots;
// };
std::vector<PcSamplingRecordT> snapshots;
};
// class ArbStateTest : public WaveSnapTest
// {
// public:
// void FillBuffers() override
// {
// // Loop over arb_state_issue
// UNROLL_ARBCHECK();
// buffer->genUpcomingSamples(GFX9::ISSUE_LAST * GFX9::ISSUE_LAST);
// for(int i = 0; i < GFX9::ISSUE_LAST; i++)
// for(int j = 0; j < GFX9::ISSUE_LAST; j++)
// genPCSample(i, GFX9::TYPE_MATRIX, GFX9::REASON_ALU, 1 << i, 1 << j);
// }
template <typename PcSamplingRecordT>
class ArbStateTest : public WaveSnapTest<PcSamplingRecordT>
{
public:
void FillBuffers() override
{
// Loop over arb_state_issue
GENERATE_RECORDS_ARBSTATE_ISSUE();
this->buffer->genUpcomingSamples(GFX9::ISSUE_LAST * GFX9::ISSUE_LAST);
// To match the order of instantiating snapshots inside `GENERATE_RECORDS_ARBSTATE_ISSUE`
// we loop over GFX9::
for(int i = 0; i < GFX9::ISSUE_LAST; i++)
for(int j = 0; j < GFX9::ISSUE_LAST; j++)
this->genPCSample(
i, GFX9::TYPE_MATRIX, GFX9::REASON_ALU_DEPENDENCY, 1 << i, 1 << j);
}
// void CheckBuffers() override
// {
// auto parsed = buffer->get_parsed_buffer(9); // GFXIP==9
// assert(parsed.size() == 1);
// assert(parsed[0].size() == GFX9::ISSUE_LAST * GFX9::ISSUE_LAST);
// assert(snapshots.size() == GFX9::ISSUE_LAST * GFX9::ISSUE_LAST);
void CheckBuffers() override
{
auto parsed = this->buffer->get_parsed_buffer(9); // GFXIP==9
EXPECT_EQ(parsed.size(), 1);
EXPECT_EQ(parsed[0].size(), GFX9::ISSUE_LAST * GFX9::ISSUE_LAST);
EXPECT_EQ(snapshots.size(), GFX9::ISSUE_LAST * GFX9::ISSUE_LAST);
// for(size_t i = 0; i < GFX9::ISSUE_LAST * GFX9::ISSUE_LAST; i++)
// {
// auto& snap = snapshots[i];
// assert(snap.arb_state_issue == parsed[0][i].snapshot.arb_state_issue);
// assert(snap.arb_state_stall == parsed[0][i].snapshot.arb_state_stall);
// }
// }
for(size_t i = 0; i < GFX9::ISSUE_LAST * GFX9::ISSUE_LAST; i++)
{
auto& snap = snapshots[i];
MATCH_ARBSTATE(snap, parsed[0][i])
}
}
// std::vector<rocprofiler_pc_sampling_snapshot_v1_t> snapshots;
// };
std::vector<PcSamplingRecordT> snapshots;
};
// class WaveIssueAndErrorTest : public WaveSnapTest
// {
// void FillBuffers() override
// {
// buffer->genUpcomingSamples(16);
// for(int valid = 0; valid <= 1; valid++)
// for(int issued = 0; issued <= 1; issued++)
// for(int dual = 0; dual <= 1; dual++)
// for(int error = 0; error <= 1; error++)
// genPCSample(valid, issued, dual, error);
// }
template <typename PcSamplingRecordT, typename PcSamplingRecordInvalidT>
class WaveIssueAndErrorTest : public WaveSnapTest<PcSamplingRecordT>
{
struct pc_sampling_test_record_t
{
bool valid;
union
{
PcSamplingRecordT valid_record;
PcSamplingRecordInvalidT invalid_record;
};
};
// void CheckBuffers() override
// {
// const int num_combinations = 16;
// auto parsed = buffer->get_parsed_buffer(9); // GFXIP==9
// assert(parsed.size() == 1);
// assert(parsed[0].size() == num_combinations);
// assert(compare.size() == num_combinations);
void FillBuffers() override
{
this->buffer->genUpcomingSamples(16);
for(int valid = 0; valid <= 1; valid++)
for(int issued = 0; issued <= 1; issued++)
for(int dual = 0; dual <= 1; dual++)
for(int error = 0; error <= 1; error++)
genPCSample(valid, issued, dual, error);
}
// for(size_t i = 0; i < num_combinations; i++)
// {
// assert(compare[i].flags.valid == parsed[0][i].flags.valid);
// assert(compare[i].wave_issued == parsed[0][i].wave_issued);
// assert(compare[i].snapshot.dual_issue_valu == parsed[0][i].snapshot.dual_issue_valu);
// }
// }
void CheckBuffers() override
{
const int num_combinations = 16;
auto parsed = this->buffer->get_parsed_buffer(9); // GFXIP==9
EXPECT_EQ(parsed.size(), 1);
EXPECT_EQ(parsed[0].size(), num_combinations);
EXPECT_EQ(compare.size(), num_combinations);
// union trap_snapshot_v1
// {
// struct
// {
// uint32_t valid : 1;
// uint32_t issued : 1;
// uint32_t dual : 1;
// uint32_t reserved : 23;
// uint32_t error : 1;
// uint32_t reserved2 : 5;
// };
// uint32_t raw;
// };
for(size_t i = 0; i < num_combinations; i++)
{
if(compare[i].valid)
{
EXPECT_EQ(compare[i].valid_record.wave_issued, parsed[0][i].wave_issued);
EXPECT_EQ(compare[i].valid_record.snapshot.dual_issue_valu,
parsed[0][i].snapshot.dual_issue_valu);
}
else
{
// Internally (inside the parser) invalid samples are represented with
// PcSamplingRecordT of size 0. Eventually, those records are replaced with the
// PcSamplingRecordInvalidT prior to putting inside the SDK buffer.
EXPECT_EQ(parsed[0][i].size, 0);
}
}
}
// void genPCSample(bool valid, bool issued, bool dual, bool error)
// {
// rocprofiler_pc_sampling_record_t sample;
// ::memset(&sample, 0, sizeof(sample));
// // TODO: Since code objects are not mocked, use pc.code_object_offset
// // as the absolute physical address of the mocked PC.
// sample.pc.code_object_offset = dispatch->unique_id;
union trap_snapshot_v1
{
struct
{
uint32_t valid : 1;
uint32_t issued : 1;
uint32_t dual : 1;
uint32_t reserved : 23;
uint32_t error : 1;
uint32_t reserved2 : 5;
};
uint32_t raw;
};
// sample.correlation_id.internal = dispatch->getMockId().raw;
void genPCSample(bool valid, bool issued, bool dual, bool error)
{
pc_sampling_test_record_t record{};
record.valid = valid && !error;
if(record.valid)
{
// Fill in the data for the valid record.
auto& sample = record.valid_record;
// sample.flags.valid = valid && !error;
// sample.wave_issued = issued;
// sample.snapshot.dual_issue_valu = dual;
// TODO: Since code objects are not mocked, use pc.code_object_offset
// as the absolute physical address of the mocked PC.
sample.pc.code_object_offset = this->dispatch->unique_id;
// assert(dispatch.get());
sample.correlation_id.internal = this->dispatch->getMockId().raw;
// compare.push_back(sample);
sample.wave_issued = issued;
sample.snapshot.dual_issue_valu = dual;
// trap_snapshot_v1 snap;
// snap.valid = valid;
// snap.issued = issued;
// snap.dual = dual;
// snap.error = error;
EXPECT_NE(this->dispatch.get(), nullptr);
}
// perf_sample_snapshot_v1 pss;
// pss.perf_snapshot_data = snap.raw;
// pss.correlation_id = dispatch->getMockId().raw;
// dispatch->submit(std::move(pss));
// };
compare.push_back(record);
// std::vector<rocprofiler_pc_sampling_record_t> compare;
// };
trap_snapshot_v1 snap;
snap.valid = valid;
snap.issued = issued;
snap.dual = dual;
snap.error = error;
perf_sample_snapshot_v1 pss;
pss.perf_snapshot_data = snap.raw;
pss.correlation_id = this->dispatch->getMockId().raw;
this->dispatch->submit(std::move(pss));
};
std::vector<pc_sampling_test_record_t> compare;
};
template <typename PcSamplingRecordT>
class HwIdTest : public WaveSnapTest<PcSamplingRecordT>
@@ -405,23 +477,23 @@ class HwIdTest : public WaveSnapTest<PcSamplingRecordT>
void CheckBuffers() override
{
auto parsed = this->buffer->get_parsed_buffer(9); // GFXIP==9
assert(parsed.size() == 1);
assert(parsed[0].size() == 3);
assert(compare.size() == 3);
EXPECT_EQ(parsed.size(), 1);
EXPECT_EQ(parsed[0].size(), 3);
EXPECT_EQ(compare.size(), 3);
for(size_t i = 0; i < 3; i++)
{
// Comparing individual fields
assert(compare[i].hw_id.wave_id == parsed[0][i].hw_id.wave_id);
assert(compare[i].hw_id.simd_id == parsed[0][i].hw_id.simd_id);
assert(compare[i].hw_id.pipe_id == parsed[0][i].hw_id.pipe_id);
assert(compare[i].hw_id.cu_or_wgp_id == parsed[0][i].hw_id.cu_or_wgp_id);
assert(compare[i].hw_id.shader_array_id == parsed[0][i].hw_id.shader_array_id);
assert(compare[i].hw_id.shader_engine_id == parsed[0][i].hw_id.shader_engine_id);
assert(compare[i].hw_id.workgroup_id == parsed[0][i].hw_id.workgroup_id);
assert(compare[i].hw_id.vm_id == parsed[0][i].hw_id.vm_id);
assert(compare[i].hw_id.queue_id == parsed[0][i].hw_id.queue_id);
assert(compare[i].hw_id.microengine_id == parsed[0][i].hw_id.microengine_id);
EXPECT_EQ(compare[i].hw_id.wave_id, parsed[0][i].hw_id.wave_id);
EXPECT_EQ(compare[i].hw_id.simd_id, parsed[0][i].hw_id.simd_id);
EXPECT_EQ(compare[i].hw_id.pipe_id, parsed[0][i].hw_id.pipe_id);
EXPECT_EQ(compare[i].hw_id.cu_or_wgp_id, parsed[0][i].hw_id.cu_or_wgp_id);
EXPECT_EQ(compare[i].hw_id.shader_array_id, parsed[0][i].hw_id.shader_array_id);
EXPECT_EQ(compare[i].hw_id.shader_engine_id, parsed[0][i].hw_id.shader_engine_id);
EXPECT_EQ(compare[i].hw_id.workgroup_id, parsed[0][i].hw_id.workgroup_id);
EXPECT_EQ(compare[i].hw_id.vm_id, parsed[0][i].hw_id.vm_id);
EXPECT_EQ(compare[i].hw_id.queue_id, parsed[0][i].hw_id.queue_id);
EXPECT_EQ(compare[i].hw_id.microengine_id, parsed[0][i].hw_id.microengine_id);
}
}
@@ -451,8 +523,9 @@ class HwIdTest : public WaveSnapTest<PcSamplingRecordT>
// raw register value
snap.hw_id = hw_id.raw;
snap.correlation_id = this->dispatch->getMockId().raw;
snap.perf_snapshot_data |= 0x1; // sample is valid
assert(this->dispatch.get());
EXPECT_NE(this->dispatch.get(), nullptr);
this->dispatch->submit(snap);
};
@@ -473,26 +546,26 @@ class WaveOtherFieldsTest : public WaveSnapTest<PcSamplingRecordT>
void CheckBuffers() override
{
auto parsed = this->buffer->get_parsed_buffer(9); // GFXIP==9
assert(parsed.size() == 1);
assert(parsed[0].size() == 3);
assert(compare.size() == 3);
EXPECT_EQ(parsed.size(), 1);
EXPECT_EQ(parsed[0].size(), 3);
EXPECT_EQ(compare.size(), 3);
for(size_t i = 0; i < 3; i++)
{
// TODO: if we decide to test flags, make specialization for
// rocprofiler_pc_sampling_record_stochastic_v0_t
// assert(parsed[0][i].flags.has_stall_reason == true);
// assert(parsed[0][i].flags.has_wave_cnt == true);
// assert(parsed[0][i].flags.reserved == false);
// EXPECT_EQ(parsed[0][i].flags.has_stall_reason, true);
// EXPECT_EQ(parsed[0][i].flags.has_wave_cnt, true);
// EXPECT_EQ(parsed[0][i].flags.reserved, false);
assert(compare[i].exec_mask == parsed[0][i].exec_mask);
assert(compare[i].workgroup_id == parsed[0][i].workgroup_id);
EXPECT_EQ(compare[i].exec_mask, parsed[0][i].exec_mask);
EXPECT_EQ(compare[i].workgroup_id, parsed[0][i].workgroup_id);
assert(compare[i].hw_id.chiplet == parsed[0][i].hw_id.chiplet);
assert(compare[i].wave_in_group == parsed[0][i].wave_in_group);
EXPECT_EQ(compare[i].hw_id.chiplet, parsed[0][i].hw_id.chiplet);
EXPECT_EQ(compare[i].wave_in_group, parsed[0][i].wave_in_group);
// TODO: handle HW_ID as well.
// assert(compare[i].hw_id == parsed[0][i].hw_id);
assert(compare[i].correlation_id.internal == parsed[0][i].correlation_id.internal);
// EXPECT_EQ(compare[i].hw_id, parsed[0][i].hw_id);
EXPECT_EQ(compare[i].correlation_id.internal, parsed[0][i].correlation_id.internal);
}
}
@@ -525,7 +598,11 @@ class WaveOtherFieldsTest : public WaveSnapTest<PcSamplingRecordT>
snap.chiplet_and_wave_id = (chip << 8) | (wave & 0x3F);
snap.correlation_id = this->dispatch->getMockId().raw;
assert(this->dispatch.get());
// to ensure all stochastic samples are generated properly,
// marked them as valid
snap.perf_snapshot_data |= 0x1; // set the bit indicating the sample is valid
EXPECT_NE(this->dispatch.get(), nullptr);
this->dispatch->submit(snap);
(void) pc;
@@ -538,10 +615,12 @@ TEST(pcs_parser, gfx9_test)
{
// Tests specific to stochastic sampling only
WaveCntTest<rocprofiler_pc_sampling_record_stochastic_v0_t>{}.Test();
// InstTypeTest{}.Test();
// StallReasonTest{}.Test();
// ArbStateTest{}.Test();
// WaveIssueAndErrorTest{}.Test();
InstTypeTest<rocprofiler_pc_sampling_record_stochastic_v0_t>{}.Test();
StallReasonTest<rocprofiler_pc_sampling_record_stochastic_v0_t>{}.Test();
ArbStateTest<rocprofiler_pc_sampling_record_stochastic_v0_t>{}.Test();
WaveIssueAndErrorTest<rocprofiler_pc_sampling_record_stochastic_v0_t,
rocprofiler_pc_sampling_record_invalid_t>{}
.Test();
// Tests commong for both host trap and stochastic sampling.
HwIdTest<rocprofiler_pc_sampling_record_host_trap_v0_t>{}.Test();
@@ -309,6 +309,8 @@ public:
::memset(&uni, 0, sizeof(uni));
uni.snap.pc = dispatch->unique_id;
uni.snap.correlation_id = dispatch->getMockId().raw;
// mark sample valid in case of stochastic sampling tests
uni.snap.perf_snapshot_data |= 0x1; // stochastic sample is valid
dispatch->submit(uni);
};
void print()
@@ -250,6 +250,7 @@ multithread_codeobj(size_t tid, Latch* latch)
for(int s = 0; s < NUM_SAMPLES; s++)
{
uni.snap.pc = pc_base_addr + s;
uni.snap.perf_snapshot_data |= 0x1; // sample is valid
dispatch->submit(uni);
}
@@ -30,7 +30,8 @@
#include "lib/rocprofiler-sdk/pc_sampling/parser/gfx9.hpp"
#include "lib/rocprofiler-sdk/pc_sampling/parser/parser_types.hpp"
#include "lib/rocprofiler-sdk/pc_sampling/parser/rocr.h"
#include "lib/rocprofiler-sdk/pc_sampling/parser/stochastic_records.h"
#include <rocprofiler-sdk/pc_sampling.h>
// TODO: refactor the commented code for stochastic sampling
@@ -51,7 +52,6 @@
// ret.wave_count = sample.perf_snapshot_data1 & 0x3F;
// ret.wave_issued = sample.perf_snapshot_data >> 1;
// ret.snapshot.dual_issue_valu = sample.perf_snapshot_data >> 2;
// ret.snapshot.inst_type = sample.perf_snapshot_data >> 3;
// ret.snapshot.reason_not_issued = (sample.perf_snapshot_data >> 7) & 0x7;
@@ -103,90 +103,76 @@
// #undef BITSHIFT
// #define LUTOVERLOAD(sname) this->operator[](GFX::sname) = PCSAMPLE::sname
#define LUTOVERLOAD(sname, rocp_prefix) this->operator[](GFX::sname) = rocp_prefix##_##sname
#define LUTOVERLOAD_INST(sname) LUTOVERLOAD(sname, ROCPROFILER_PC_SAMPLING_INSTRUCTION)
#define LUTOVERLOAD_INST_NOT_ISSUED(sname) \
LUTOVERLOAD(sname, ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED)
// template <typename GFX>
// class GFX_REASON_LUT : public std::array<int, 32>
// {
// public:
// GFX_REASON_LUT()
// {
// std::memset(data(), 0, size() * sizeof(int));
// LUTOVERLOAD(REASON_NOT_AVAILABLE);
// LUTOVERLOAD(REASON_ALU);
// LUTOVERLOAD(REASON_WAITCNT);
// LUTOVERLOAD(REASON_INTERNAL);
// LUTOVERLOAD(REASON_BARRIER);
// LUTOVERLOAD(REASON_ARBITER);
// LUTOVERLOAD(REASON_EX_STALL);
// LUTOVERLOAD(REASON_OTHER_WAIT);
// LUTOVERLOAD(REASON_SLEEP);
// }
// };
template <typename GFX>
struct gfx_inst_lut : public std::array<int, 32>
{
gfx_inst_lut()
{
std::memset(data(), 0, size() * sizeof(int));
LUTOVERLOAD_INST(TYPE_VALU);
LUTOVERLOAD_INST(TYPE_MATRIX);
LUTOVERLOAD_INST(TYPE_SCALAR);
LUTOVERLOAD_INST(TYPE_TEX);
LUTOVERLOAD_INST(TYPE_LDS);
LUTOVERLOAD_INST(TYPE_LDS_DIRECT);
LUTOVERLOAD_INST(TYPE_FLAT);
LUTOVERLOAD_INST(TYPE_EXPORT);
LUTOVERLOAD_INST(TYPE_MESSAGE);
LUTOVERLOAD_INST(TYPE_BARRIER);
LUTOVERLOAD_INST(TYPE_BRANCH_NOT_TAKEN);
LUTOVERLOAD_INST(TYPE_BRANCH_TAKEN);
LUTOVERLOAD_INST(TYPE_JUMP);
LUTOVERLOAD_INST(TYPE_OTHER);
LUTOVERLOAD_INST(TYPE_NO_INST);
LUTOVERLOAD_INST(TYPE_DUAL_VALU);
}
};
// template <typename GFX>
// class GFX_INST_LUT : public std::array<int, 32>
// {
// public:
// GFX_INST_LUT()
// {
// std::memset(data(), 0, size() * sizeof(int));
// LUTOVERLOAD(TYPE_VALU);
// LUTOVERLOAD(TYPE_MATRIX);
// LUTOVERLOAD(TYPE_SCALAR);
// LUTOVERLOAD(TYPE_TEX);
// LUTOVERLOAD(TYPE_LDS);
// LUTOVERLOAD(TYPE_LDS_DIRECT);
// LUTOVERLOAD(TYPE_FLAT);
// LUTOVERLOAD(TYPE_EXP);
// LUTOVERLOAD(TYPE_MESSAGE);
// LUTOVERLOAD(TYPE_BARRIER);
// LUTOVERLOAD(TYPE_BRANCH_NOT_TAKEN);
// LUTOVERLOAD(TYPE_BRANCH_TAKEN);
// LUTOVERLOAD(TYPE_JUMP);
// LUTOVERLOAD(TYPE_OTHER);
// LUTOVERLOAD(TYPE_NO_INST);
// LUTOVERLOAD(TYPE_DUAL_VALU);
// }
// };
template <typename GFX>
struct gfx_reason_lut : public std::array<int, 32>
{
gfx_reason_lut()
{
std::memset(data(), 0, size() * sizeof(int));
LUTOVERLOAD_INST_NOT_ISSUED(REASON_NO_INSTRUCTION_AVAILABLE);
LUTOVERLOAD_INST_NOT_ISSUED(REASON_ALU_DEPENDENCY);
LUTOVERLOAD_INST_NOT_ISSUED(REASON_WAITCNT);
LUTOVERLOAD_INST_NOT_ISSUED(REASON_INTERNAL_INSTRUCTION);
LUTOVERLOAD_INST_NOT_ISSUED(REASON_BARRIER_WAIT);
LUTOVERLOAD_INST_NOT_ISSUED(REASON_ARBITER_NOT_WIN);
LUTOVERLOAD_INST_NOT_ISSUED(REASON_ARBITER_WIN_EX_STALL);
LUTOVERLOAD_INST_NOT_ISSUED(REASON_OTHER_WAIT);
LUTOVERLOAD_INST_NOT_ISSUED(REASON_SLEEP_WAIT);
}
};
// template <typename GFX>
// inline int
// translate_reason(int in)
// {
// static GFX_REASON_LUT<GFX> lut;
// return lut[in & 0x1F];
// }
template <typename GFX>
inline int
translate_inst(int in)
{
static gfx_inst_lut<GFX> lut;
return lut[in & 0x1F];
}
// template <typename GFX>
// inline int
// translate_inst(int in)
// {
// static GFX_INST_LUT<GFX> lut;
// return lut[in & 0x1F];
// }
template <typename GFX>
inline int
translate_reason(int in)
{
static gfx_reason_lut<GFX> lut;
return lut[in & 0x1F];
}
// #undef LUTOVERLOAD
// template <bool HostTrap, typename GFX>
// inline rocprofiler_pc_sampling_record_t
// copySample(const void* sample)
// {
// if(HostTrap) return copyHostTrapSample(*(const perf_sample_host_trap_v1*) sample);
// rocprofiler_pc_sampling_record_t ret =
// copyStochasticSample<GFX>(*(const perf_sample_snapshot_v1*) sample);
// ret.snapshot.inst_type = translate_inst<GFX>(ret.snapshot.inst_type);
// ret.snapshot.arb_state_issue = translate_arb<GFX>(ret.snapshot.arb_state_issue);
// ret.snapshot.arb_state_stall = translate_arb<GFX>(ret.snapshot.arb_state_stall);
// ret.snapshot.reason_not_issued = translate_reason<GFX>(ret.snapshot.reason_not_issued);
// return ret;
// }
#undef LUTOVERLOAD_INST_NOT_ISSUED
#undef LUTOVERLOAD_INST
#undef LUTOVERLOAD
#define EXTRACT_BITS(val, bit_end, bit_start) \
(val >> bit_start) & ((1U << (bit_end - bit_start + 1)) - 1)
((val >> bit_start) & ((1U << (bit_end - bit_start + 1)) - 1))
template <typename GFX, typename PcSamplingRecordT, typename SType>
inline void
@@ -228,8 +214,6 @@ copyHwId<GFX9, rocprofiler_pc_sampling_hw_id_v0_t>(rocprofiler_pc_sampling_hw_id
hw_id.microengine_id = EXTRACT_BITS(hw_id_reg, 31, 30);
}
#undef EXTRACT_BITS
template <typename PcSamplingRecordT, typename SType>
inline PcSamplingRecordT
copySampleHeader(const SType& sample)
@@ -276,11 +260,65 @@ inline rocprofiler_pc_sampling_record_stochastic_v0_t
copySample<GFX9, rocprofiler_pc_sampling_record_stochastic_v0_t>(const void* sample)
{
const auto& sample_ = *static_cast<const perf_sample_snapshot_v1*>(sample);
auto ret = copySampleHeader<rocprofiler_pc_sampling_record_stochastic_v0_t>(sample_);
// Extracting data from the perf_snapshot_data register
auto perf_snapshot_data = sample_.perf_snapshot_data;
// The sample is valid iff neither of perf_snapshot_data.valid and perf_snapshot_data.error == 0
// is one
auto valid = static_cast<bool>(EXTRACT_BITS(perf_snapshot_data, 0, 0) &
~EXTRACT_BITS(perf_snapshot_data, 26, 26));
if(!valid)
{
// To reduce refactoring of the PC sampling parser, we agreed to internally represent
// invalid samples with `rocprofiler_pc_sampling_record_stochastic_v0_t` with size 0.
// Eventually, those records are replaced with rocprofiler_pc_sampling_record_invalid_t
// and placed into the SDK buffer consumed by the end tool.
rocprofiler_pc_sampling_record_stochastic_v0_t invalid{};
invalid.size = 0;
// No need to further process invalid samples
return invalid;
}
auto ret = copySampleHeader<rocprofiler_pc_sampling_record_stochastic_v0_t>(sample_);
copyChipletId<GFX9>(ret, sample_);
copyHwId<GFX9>(ret.hw_id, sample_.hw_id);
ret.wave_count = sample_.perf_snapshot_data1 & 0x3F;
// TODO: implement logic for manipulating stochastic related fields
// no memory counters on GFX9
ret.flags.has_memory_counter = false;
// wave issued an instruction
ret.wave_issued = EXTRACT_BITS(perf_snapshot_data, 1, 1);
// type of issued instruction, valid only if `ret.wave_issued` is true.
ret.inst_type = translate_inst<GFX9>(EXTRACT_BITS(perf_snapshot_data, 6, 3));
// two VALU instructions issued in this cycles
ret.snapshot.dual_issue_valu = EXTRACT_BITS(perf_snapshot_data, 2, 2);
// reason for not issuing an instruction, valid only if `ret.wave_issued` is false
ret.snapshot.reason_not_issued = translate_reason<GFX9>(EXTRACT_BITS(perf_snapshot_data, 9, 7));
// arbiter state information
uint16_t arb_state = EXTRACT_BITS(perf_snapshot_data, 25, 10);
ret.snapshot.arb_state_issue_valu = EXTRACT_BITS(arb_state, 7, 7);
ret.snapshot.arb_state_issue_matrix = EXTRACT_BITS(arb_state, 6, 6);
ret.snapshot.arb_state_issue_lds = EXTRACT_BITS(arb_state, 3, 3);
ret.snapshot.arb_state_issue_scalar = EXTRACT_BITS(arb_state, 5, 5);
ret.snapshot.arb_state_issue_vmem_tex = EXTRACT_BITS(arb_state, 4, 4);
ret.snapshot.arb_state_issue_flat = EXTRACT_BITS(arb_state, 2, 2);
ret.snapshot.arb_state_issue_exp = EXTRACT_BITS(arb_state, 1, 1);
ret.snapshot.arb_state_issue_misc = EXTRACT_BITS(arb_state, 0, 0);
ret.snapshot.arb_state_stall_valu = EXTRACT_BITS(arb_state, 15, 15);
ret.snapshot.arb_state_stall_matrix = EXTRACT_BITS(arb_state, 14, 14);
ret.snapshot.arb_state_stall_lds = EXTRACT_BITS(arb_state, 11, 11);
ret.snapshot.arb_state_stall_scalar = EXTRACT_BITS(arb_state, 13, 13);
ret.snapshot.arb_state_stall_vmem_tex = EXTRACT_BITS(arb_state, 12, 12);
ret.snapshot.arb_state_stall_flat = EXTRACT_BITS(arb_state, 10, 10);
ret.snapshot.arb_state_stall_exp = EXTRACT_BITS(arb_state, 9, 9);
ret.snapshot.arb_state_stall_misc = EXTRACT_BITS(arb_state, 8, 8);
// Extracting data from the perf_snapshot_data1 register
// Active waves on CU at the moment of sampling
ret.wave_count = EXTRACT_BITS(sample_.perf_snapshot_data1, 5, 0);
return ret;
}
@@ -309,3 +347,5 @@ copySample<GFX11, rocprofiler_pc_sampling_record_stochastic_v0_t>(const void* sa
// ret.wave_count = sample_.perf_snapshot_data1 & 0x3F;
return ret;
}
#undef EXTRACT_BITS