PCS parser is aware of external correlation IDs (#639)
* PCS parser is aware of external correlation IDs * source formatting (clang-format v11) (#640) Co-authored-by: vlaindic <139573562+vlaindic@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <rocprofiler-sdk/fwd.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
@@ -133,7 +135,7 @@ public:
|
||||
* Given a device dev, doorbell and and wrapped dispatch_id,
|
||||
* @returns the correlation_id set by dispatch_pkt_id_t
|
||||
*/
|
||||
uint64_t get(device_handle dev, trap_correlation_id_t correlation_in)
|
||||
rocprofiler_correlation_id_t get(device_handle dev, trap_correlation_id_t correlation_in)
|
||||
{
|
||||
#ifndef _PARSER_CORRELATION_DISABLE_CACHE
|
||||
if(dev.handle == cache_dev_id && correlation_in == cache_correlation_id_in)
|
||||
@@ -166,12 +168,14 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<DispatchPkt, uint64_t> dispatch_to_correlation{};
|
||||
std::unordered_map<DispatchPkt, rocprofiler_correlation_id_t> dispatch_to_correlation{};
|
||||
|
||||
// Making get() const and these cache variables mutable causes performance to be unstable
|
||||
trap_correlation_id_t cache_correlation_id_in{.raw = ~0ul}; // Invalid value in cache
|
||||
uint64_t cache_correlation_id_out = ~0ul;
|
||||
uint64_t cache_dev_id = ~0ul; // Invalid device Id in cache
|
||||
trap_correlation_id_t cache_correlation_id_in{.raw = ~0ul}; // Invalid value in cache
|
||||
rocprofiler_correlation_id_t cache_correlation_id_out{
|
||||
.internal = ~0ul,
|
||||
.external = rocprofiler_user_data_t{.value = ~0ul}};
|
||||
uint64_t cache_dev_id = ~0ul; // Invalid device Id in cache
|
||||
};
|
||||
} // namespace Parser
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <rocprofiler-sdk/fwd.h>
|
||||
|
||||
/**
|
||||
* ######## Parser Definitions ########
|
||||
*/
|
||||
@@ -130,9 +132,9 @@ typedef struct
|
||||
uint32_t workgroup_id_y;
|
||||
uint32_t workgroup_id_z;
|
||||
|
||||
uint32_t wave_count;
|
||||
uint64_t timestamp;
|
||||
uint64_t correlation_id;
|
||||
uint32_t wave_count;
|
||||
uint64_t timestamp;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
|
||||
pcsample_snapshot_v1_t snapshot;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ PCSamplingParserContext::newDispatch(const dispatch_pkt_id_t& pkt)
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(mut);
|
||||
corr_map->newDispatch(pkt);
|
||||
active_dispatches[pkt.correlation_id] = pkt;
|
||||
active_dispatches[pkt.correlation_id.internal] = pkt;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -148,6 +148,7 @@ protected:
|
||||
//! Data allocated to store samples. Temporary.
|
||||
std::vector<std::unique_ptr<PCSamplingData>> data;
|
||||
//! Dispatches not yet completed.
|
||||
// Uses only the internal correlation_id.
|
||||
std::unordered_map<uint64_t, dispatch_pkt_id_t> active_dispatches;
|
||||
//! List of correlation ids whose dispatches have been completed and can be forgotten after the
|
||||
//! buffer flip.
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <rocprofiler-sdk/fwd.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
@@ -69,8 +71,9 @@ typedef struct
|
||||
uint64_t queue_size;
|
||||
uint64_t write_index;
|
||||
uint64_t read_index;
|
||||
uint64_t correlation_id;
|
||||
reserved_type _[4];
|
||||
/// both internal and external correlation ID.
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
reserved_type _[2];
|
||||
} dispatch_pkt_id_t;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -52,7 +52,7 @@ static bool
|
||||
check_samples(pcsample_v1_t* samples, uint64_t size)
|
||||
{
|
||||
for(size_t i = 0; i < size; i++)
|
||||
if(samples[i].correlation_id != samples[i].pc) return false;
|
||||
if(samples[i].correlation_id.internal != samples[i].pc) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -296,8 +296,8 @@ class WaveIssueAndErrorTest : public WaveSnapTest
|
||||
{
|
||||
pcsample_v1_t sample;
|
||||
::memset(&sample, 0, sizeof(sample));
|
||||
sample.pc = dispatch->unique_id;
|
||||
sample.correlation_id = dispatch->getMockId().raw;
|
||||
sample.pc = dispatch->unique_id;
|
||||
sample.correlation_id.internal = dispatch->getMockId().raw;
|
||||
|
||||
sample.flags.valid = valid && !error;
|
||||
sample.wave_issued = issued;
|
||||
@@ -353,7 +353,7 @@ class WaveOtherFieldsTest : public WaveSnapTest
|
||||
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].correlation_id == parsed[0][i].correlation_id);
|
||||
assert(compare[i].correlation_id.internal == parsed[0][i].correlation_id.internal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,10 +367,10 @@ 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 = dispatch->unique_id;
|
||||
sample.chiplet = chip;
|
||||
sample.wave_id = wave;
|
||||
sample.hw_id = hwid;
|
||||
sample.correlation_id.internal = dispatch->unique_id;
|
||||
|
||||
compare.push_back(sample);
|
||||
|
||||
|
||||
@@ -188,12 +188,12 @@ public:
|
||||
|
||||
packet_union_t uni;
|
||||
::memset(&uni, 0, sizeof(uni));
|
||||
uni.dispatch_id.type = AMD_DISPATCH_PKT_ID;
|
||||
uni.dispatch_id.doorbell_id = doorbell_id;
|
||||
uni.dispatch_id.queue_size = queue->size;
|
||||
uni.dispatch_id.write_index = dispatch_id;
|
||||
uni.dispatch_id.read_index = queue->read_index;
|
||||
uni.dispatch_id.correlation_id = unique_id;
|
||||
uni.dispatch_id.type = AMD_DISPATCH_PKT_ID;
|
||||
uni.dispatch_id.doorbell_id = doorbell_id;
|
||||
uni.dispatch_id.queue_size = queue->size;
|
||||
uni.dispatch_id.write_index = dispatch_id;
|
||||
uni.dispatch_id.read_index = queue->read_index;
|
||||
uni.dispatch_id.correlation_id.internal = unique_id;
|
||||
queue->submit(uni);
|
||||
queue->write_index++;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user