Host trap PC sampling uses new record type (#1207)
* Host trap PC sampling uses new record type * removing redundant field * formatting * simplifying templates in the parser - no need for HostTrap boolean * reviving some parser tests * hw_id decoding on GFX9 * HW id parser test * parser CID test * Parser multigpu test * removing rocprofiler_pc_sampling_record_t and some fields from hw_id * simplifying parser context * keep bench test internally * initializing gfx9_hw_id_t differently * anonymous struct first * avoiding inlining initialization of struct
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
55aea3ef10
Коммит
bc52c17e64
@@ -100,14 +100,15 @@
|
||||
ARBCHECK2(ISSUE_EXP); \
|
||||
ARBCHECK2(ISSUE_MISC);
|
||||
|
||||
template <typename PcSamplingRecordT>
|
||||
class WaveSnapTest
|
||||
{
|
||||
public:
|
||||
WaveSnapTest()
|
||||
{
|
||||
buffer = std::make_shared<MockRuntimeBuffer>();
|
||||
queue = std::make_shared<MockQueue>(16, buffer);
|
||||
dispatch = std::make_shared<MockDispatch>(queue);
|
||||
buffer = std::make_shared<MockRuntimeBuffer<PcSamplingRecordT>>();
|
||||
queue = std::make_shared<MockQueue<PcSamplingRecordT>>(16, buffer);
|
||||
dispatch = std::make_shared<MockDispatch<PcSamplingRecordT>>(queue);
|
||||
}
|
||||
|
||||
void Test()
|
||||
@@ -140,25 +141,27 @@ public:
|
||||
dispatch->submit(packet_union_t{.snap = snap});
|
||||
};
|
||||
|
||||
std::shared_ptr<MockRuntimeBuffer> buffer;
|
||||
std::shared_ptr<MockQueue> queue;
|
||||
std::shared_ptr<MockDispatch> dispatch;
|
||||
std::shared_ptr<MockRuntimeBuffer<PcSamplingRecordT>> buffer;
|
||||
std::shared_ptr<MockQueue<PcSamplingRecordT>> queue;
|
||||
std::shared_ptr<MockDispatch<PcSamplingRecordT>> dispatch;
|
||||
};
|
||||
|
||||
class WaveCntTest : public WaveSnapTest
|
||||
template <typename PcSamplingRecordT>
|
||||
class WaveCntTest : public WaveSnapTest<PcSamplingRecordT>
|
||||
{
|
||||
public:
|
||||
void FillBuffers() override
|
||||
{
|
||||
// Loop over all possible wave_cnt
|
||||
buffer->genUpcomingSamples(max_wave_number);
|
||||
this->buffer->genUpcomingSamples(max_wave_number);
|
||||
for(size_t i = 0; i < max_wave_number; i++)
|
||||
genPCSample(i, GFX9::TYPE_LDS, GFX9::REASON_ALU, GFX9::ISSUE_VALU, GFX9::ISSUE_VALU);
|
||||
this->genPCSample(
|
||||
i, GFX9::TYPE_LDS, GFX9::REASON_ALU, GFX9::ISSUE_VALU, GFX9::ISSUE_VALU);
|
||||
}
|
||||
|
||||
void CheckBuffers() override
|
||||
{
|
||||
auto parsed = buffer->get_parsed_buffer(9); // GFXIP==9
|
||||
auto parsed = this->buffer->get_parsed_buffer(9); // GFXIP==9
|
||||
assert(parsed.size() == 1);
|
||||
assert(parsed[0].size() == max_wave_number);
|
||||
|
||||
@@ -166,204 +169,336 @@ public:
|
||||
assert(parsed[0][i].wave_count == i);
|
||||
}
|
||||
|
||||
const size_t max_wave_number = 64;
|
||||
std::vector<rocprofiler_pc_sampling_snapshot_v1_t> snapshots;
|
||||
const size_t max_wave_number = 64;
|
||||
std::vector<PcSamplingRecordT> snapshots;
|
||||
};
|
||||
|
||||
class InstTypeTest : public WaveSnapTest
|
||||
// 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);
|
||||
// }
|
||||
|
||||
// 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);
|
||||
|
||||
// for(size_t i = 0; i < GFX9::TYPE_LAST; i++)
|
||||
// assert(snapshots[i].inst_type == parsed[0][i].snapshot.inst_type);
|
||||
// }
|
||||
|
||||
// std::vector<rocprofiler_pc_sampling_snapshot_v1_t> 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);
|
||||
// }
|
||||
|
||||
// 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);
|
||||
|
||||
// for(size_t i = 0; i < GFX9::REASON_LAST; i++)
|
||||
// assert(snapshots[i].reason_not_issued == parsed[0][i].snapshot.reason_not_issued);
|
||||
// }
|
||||
|
||||
// std::vector<rocprofiler_pc_sampling_snapshot_v1_t> 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);
|
||||
// }
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
|
||||
// std::vector<rocprofiler_pc_sampling_snapshot_v1_t> 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);
|
||||
// }
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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;
|
||||
// };
|
||||
|
||||
// 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;
|
||||
|
||||
// sample.correlation_id.internal = dispatch->getMockId().raw;
|
||||
|
||||
// sample.flags.valid = valid && !error;
|
||||
// sample.wave_issued = issued;
|
||||
// sample.snapshot.dual_issue_valu = dual;
|
||||
|
||||
// assert(dispatch.get());
|
||||
|
||||
// compare.push_back(sample);
|
||||
|
||||
// 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 = dispatch->getMockId().raw;
|
||||
// dispatch->submit(std::move(pss));
|
||||
// };
|
||||
|
||||
// std::vector<rocprofiler_pc_sampling_record_t> compare;
|
||||
// };
|
||||
|
||||
template <typename PcSamplingRecordT>
|
||||
class HwIdTest : public WaveSnapTest<PcSamplingRecordT>
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
for(size_t i = 0; i < GFX9::TYPE_LAST; i++)
|
||||
assert(snapshots[i].inst_type == parsed[0][i].snapshot.inst_type);
|
||||
}
|
||||
|
||||
std::vector<rocprofiler_pc_sampling_snapshot_v1_t> 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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
for(size_t i = 0; i < GFX9::REASON_LAST; i++)
|
||||
assert(snapshots[i].reason_not_issued == parsed[0][i].snapshot.reason_not_issued);
|
||||
}
|
||||
|
||||
std::vector<rocprofiler_pc_sampling_snapshot_v1_t> 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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<rocprofiler_pc_sampling_snapshot_v1_t> 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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
union trap_snapshot_v1
|
||||
union gfx9_hw_id_t
|
||||
{
|
||||
uint32_t raw;
|
||||
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 wave_id : 4; ///< wave slot index
|
||||
uint32_t simd_id : 2; ///< SIMD index
|
||||
uint32_t pipe_id : 2; ///< pipe index
|
||||
uint32_t cu_id : 4; ///< Index of compute unit on GFX9 or workgroup processer on other
|
||||
///< architectures
|
||||
uint32_t shader_array_id : 1; ///< Shared array index
|
||||
uint32_t shader_engine_id : 3; ///< shared engine index
|
||||
uint32_t
|
||||
threadgroup_id : 4; ///< thread_group index on GFX9, and workgroup index on GFX10+
|
||||
uint32_t vm_id : 4; ///< virtual memory ID
|
||||
uint32_t queue_id : 3; ///< queue id
|
||||
uint32_t gfx_context_state_id : 3; ///< GFX context (state) id (only on GFX9) - ignored
|
||||
uint32_t microengine_id : 2; ///< ACE (microengine) index
|
||||
};
|
||||
uint32_t raw;
|
||||
};
|
||||
|
||||
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.loaded_code_object_offset
|
||||
// as the absolute physical address of the mocked PC.
|
||||
sample.pc.loaded_code_object_offset = dispatch->unique_id;
|
||||
|
||||
sample.correlation_id.internal = dispatch->getMockId().raw;
|
||||
|
||||
sample.flags.valid = valid && !error;
|
||||
sample.wave_issued = issued;
|
||||
sample.snapshot.dual_issue_valu = dual;
|
||||
|
||||
assert(dispatch.get());
|
||||
|
||||
compare.push_back(sample);
|
||||
|
||||
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 = dispatch->getMockId().raw;
|
||||
dispatch->submit(std::move(pss));
|
||||
};
|
||||
|
||||
std::vector<rocprofiler_pc_sampling_record_t> compare;
|
||||
};
|
||||
|
||||
class WaveOtherFieldsTest : public WaveSnapTest
|
||||
{
|
||||
void FillBuffers() override
|
||||
{
|
||||
buffer->genUpcomingSamples(3);
|
||||
genPCSample(1, 2, 3, 4, 5, 6, 7, 8); // Counting
|
||||
genPCSample(3, 5, 7, 11, 13, 17, 19, 23); // Some prime numbers
|
||||
genPCSample(23, 19, 17, 13, 11, 7, 5, 3); // Some reversed primes
|
||||
gfx9_hw_id_t hw_id_val0;
|
||||
hw_id_val0.wave_id = 0;
|
||||
hw_id_val0.simd_id = 0;
|
||||
hw_id_val0.pipe_id = 0;
|
||||
hw_id_val0.cu_id = 0;
|
||||
hw_id_val0.shader_array_id = 0;
|
||||
hw_id_val0.shader_engine_id = 0;
|
||||
hw_id_val0.threadgroup_id = 0;
|
||||
hw_id_val0.vm_id = 0;
|
||||
hw_id_val0.queue_id = 0;
|
||||
hw_id_val0.gfx_context_state_id = 0;
|
||||
hw_id_val0.microengine_id = 0;
|
||||
|
||||
gfx9_hw_id_t hw_id_val1;
|
||||
hw_id_val0.wave_id = 15;
|
||||
hw_id_val0.simd_id = 3;
|
||||
hw_id_val0.pipe_id = 3;
|
||||
hw_id_val0.cu_id = 15;
|
||||
hw_id_val0.shader_array_id = 1;
|
||||
hw_id_val0.shader_engine_id = 7;
|
||||
hw_id_val0.threadgroup_id = 15;
|
||||
hw_id_val0.vm_id = 15;
|
||||
hw_id_val0.queue_id = 7;
|
||||
hw_id_val0.gfx_context_state_id = 7;
|
||||
hw_id_val0.microengine_id = 3;
|
||||
|
||||
gfx9_hw_id_t hw_id_val2;
|
||||
hw_id_val2.wave_id = 7;
|
||||
hw_id_val2.simd_id = 2;
|
||||
hw_id_val2.pipe_id = 2;
|
||||
hw_id_val2.cu_id = 6;
|
||||
hw_id_val2.shader_array_id = 0;
|
||||
hw_id_val2.shader_engine_id = 3;
|
||||
hw_id_val2.threadgroup_id = 8;
|
||||
hw_id_val2.vm_id = 9;
|
||||
hw_id_val2.queue_id = 3;
|
||||
hw_id_val2.gfx_context_state_id = 2;
|
||||
hw_id_val2.microengine_id = 1;
|
||||
|
||||
this->buffer->genUpcomingSamples(3);
|
||||
genPCSample(hw_id_val0);
|
||||
genPCSample(hw_id_val1);
|
||||
genPCSample(hw_id_val2);
|
||||
}
|
||||
|
||||
void CheckBuffers() override
|
||||
{
|
||||
auto parsed = buffer->get_parsed_buffer(9); // GFXIP==9
|
||||
auto parsed = this->buffer->get_parsed_buffer(9); // GFXIP==9
|
||||
assert(parsed.size() == 1);
|
||||
assert(parsed[0].size() == 3);
|
||||
assert(compare.size() == 3);
|
||||
|
||||
for(size_t i = 0; i < 3; i++)
|
||||
{
|
||||
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);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
void genPCSample(gfx9_hw_id_t hw_id)
|
||||
{
|
||||
PcSamplingRecordT sample;
|
||||
::memset(&sample, 0, sizeof(sample));
|
||||
// Unpacking individual fields
|
||||
// NOTE: chiplet is tested in a WaveOtherFieldsTest test, becuase it's not
|
||||
// transferred via hw_id, but chiplet_and_wave_id field.
|
||||
sample.hw_id.wave_id = hw_id.wave_id;
|
||||
sample.hw_id.simd_id = hw_id.simd_id;
|
||||
sample.hw_id.pipe_id = hw_id.pipe_id;
|
||||
sample.hw_id.cu_or_wgp_id = hw_id.cu_id;
|
||||
sample.hw_id.shader_array_id = hw_id.shader_array_id;
|
||||
sample.hw_id.shader_engine_id = hw_id.shader_engine_id;
|
||||
sample.hw_id.workgroup_id = hw_id.threadgroup_id;
|
||||
sample.hw_id.vm_id = hw_id.vm_id;
|
||||
sample.hw_id.queue_id = hw_id.queue_id;
|
||||
sample.hw_id.microengine_id = hw_id.microengine_id;
|
||||
|
||||
compare.push_back(sample);
|
||||
|
||||
perf_sample_snapshot_v1 snap;
|
||||
::memset(&snap, 0, sizeof(snap));
|
||||
|
||||
// raw register value
|
||||
snap.hw_id = hw_id.raw;
|
||||
snap.correlation_id = this->dispatch->getMockId().raw;
|
||||
|
||||
assert(this->dispatch.get());
|
||||
this->dispatch->submit(snap);
|
||||
};
|
||||
|
||||
std::vector<PcSamplingRecordT> compare;
|
||||
};
|
||||
|
||||
template <typename PcSamplingRecordT>
|
||||
class WaveOtherFieldsTest : public WaveSnapTest<PcSamplingRecordT>
|
||||
{
|
||||
void FillBuffers() override
|
||||
{
|
||||
this->buffer->genUpcomingSamples(3);
|
||||
genPCSample(1, 2, 3, 4, 5, 6, 7); // Counting
|
||||
genPCSample(3, 5, 7, 11, 13, 17, 19); // Some prime numbers
|
||||
genPCSample(23, 19, 17, 13, 11, 7, 5); // Some reversed primes
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
assert(compare[i].exec_mask == parsed[0][i].exec_mask);
|
||||
assert(compare[i].workgroup_id == parsed[0][i].workgroup_id);
|
||||
|
||||
assert(compare[i].chiplet == parsed[0][i].chiplet);
|
||||
assert(compare[i].wave_id == parsed[0][i].wave_id);
|
||||
assert(compare[i].hw_id == parsed[0][i].hw_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);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
void genPCSample(int pc, int exec, int blkx, int blky, int blkz, int chip, int wave, int hwid)
|
||||
void genPCSample(int pc, int exec, int blkx, int blky, int blkz, int chip, int wave)
|
||||
{
|
||||
rocprofiler_pc_sampling_record_t sample;
|
||||
PcSamplingRecordT sample;
|
||||
::memset(&sample, 0, sizeof(sample));
|
||||
|
||||
sample.exec_mask = exec;
|
||||
@@ -371,13 +506,15 @@ class WaveOtherFieldsTest : public WaveSnapTest
|
||||
sample.workgroup_id.y = blky;
|
||||
sample.workgroup_id.z = blkz;
|
||||
|
||||
sample.chiplet = chip;
|
||||
sample.wave_id = wave;
|
||||
sample.hw_id = hwid;
|
||||
sample.correlation_id.internal = dispatch->unique_id;
|
||||
sample.hw_id.chiplet = chip;
|
||||
sample.wave_in_group = wave;
|
||||
sample.correlation_id.internal = this->dispatch->unique_id;
|
||||
|
||||
compare.push_back(sample);
|
||||
|
||||
// We're testing fields commong for both perf_sample_host_trap_v1 and
|
||||
// perf_sample_snapshot_v1, so either struct is suitable here. No need to make
|
||||
// specialization,
|
||||
perf_sample_snapshot_v1 snap;
|
||||
::memset(&snap, 0, sizeof(snap));
|
||||
snap.exec_mask = exec;
|
||||
@@ -386,26 +523,31 @@ class WaveOtherFieldsTest : public WaveSnapTest
|
||||
snap.workgroup_id_y = blky;
|
||||
snap.workgroup_id_z = blkz;
|
||||
snap.chiplet_and_wave_id = (chip << 8) | (wave & 0x3F);
|
||||
snap.hw_id = hwid;
|
||||
snap.correlation_id = dispatch->getMockId().raw;
|
||||
snap.correlation_id = this->dispatch->getMockId().raw;
|
||||
|
||||
assert(dispatch.get());
|
||||
dispatch->submit(snap);
|
||||
assert(this->dispatch.get());
|
||||
this->dispatch->submit(snap);
|
||||
|
||||
(void) pc;
|
||||
};
|
||||
|
||||
std::vector<rocprofiler_pc_sampling_record_t> compare;
|
||||
std::vector<PcSamplingRecordT> compare;
|
||||
};
|
||||
|
||||
TEST(pcs_parser, gfx9_test)
|
||||
{
|
||||
WaveCntTest{}.Test();
|
||||
InstTypeTest{}.Test();
|
||||
StallReasonTest{}.Test();
|
||||
ArbStateTest{}.Test();
|
||||
WaveIssueAndErrorTest{}.Test();
|
||||
WaveOtherFieldsTest{}.Test();
|
||||
// Tests specific to stochastic sampling only
|
||||
WaveCntTest<rocprofiler_pc_sampling_record_stochastic_v0_t>{}.Test();
|
||||
// InstTypeTest{}.Test();
|
||||
// StallReasonTest{}.Test();
|
||||
// ArbStateTest{}.Test();
|
||||
// WaveIssueAndErrorTest{}.Test();
|
||||
|
||||
// Tests commong for both host trap and stochastic sampling.
|
||||
HwIdTest<rocprofiler_pc_sampling_record_host_trap_v0_t>{}.Test();
|
||||
HwIdTest<rocprofiler_pc_sampling_record_stochastic_v0_t>{}.Test();
|
||||
WaveOtherFieldsTest<rocprofiler_pc_sampling_record_host_trap_v0_t>{}.Test();
|
||||
WaveOtherFieldsTest<rocprofiler_pc_sampling_record_stochastic_v0_t>{}.Test();
|
||||
|
||||
std::cout << "GFX9 Test Done." << std::endl;
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user