PC Sampling: Push data to PC Sampling client

Each time there is enough data to fill the client session buffer,
callback the client data ready function to transfer the buffer contents
to the client.

Change-Id: Id79775426fa6d22e00dc2ef6f55c439eacb9b2af


[ROCm/ROCR-Runtime commit: 5177d17f5d]
This commit is contained in:
David Yat Sin
2023-09-05 17:05:10 +00:00
parent d8b7c22609
commit b0d88f22dd
3 changed files with 97 additions and 2 deletions
@@ -159,6 +159,40 @@ void PcsRuntime::PcSamplingSession::GetHsaKmtSamplingInfo(HsaPcSamplingInfo* sam
}
}
hsa_status_t PcSamplingDataCopyCallback(void* _session, size_t bytes_to_copy, void* destination) {
assert(_session);
assert(destination);
PcsRuntime::PcSamplingSession* session =
reinterpret_cast<PcsRuntime::PcSamplingSession*>(_session);
return session->DataCopyCallback(reinterpret_cast<uint8_t*>(destination), bytes_to_copy);
}
hsa_status_t PcsRuntime::PcSamplingSession::DataCopyCallback(uint8_t* buffer,
size_t bytes_to_copy) {
if (bytes_to_copy != (data_rdy.buf1_sz + data_rdy.buf2_sz)) return HSA_STATUS_ERROR_EXCEPTION;
if (data_rdy.buf1_sz) memcpy(buffer, data_rdy.buf1, data_rdy.buf1_sz);
if (data_rdy.buf2_sz) memcpy(buffer + data_rdy.buf1_sz, data_rdy.buf2, data_rdy.buf2_sz);
return HSA_STATUS_SUCCESS;
}
hsa_status_t PcsRuntime::PcSamplingSession::HandleSampleData(uint8_t* buf1, size_t buf1_sz,
uint8_t* buf2, size_t buf2_sz,
size_t lost_sample_count) {
data_rdy.buf1 = buf1;
data_rdy.buf1_sz = buf1_sz;
data_rdy.buf2 = buf2;
data_rdy.buf2_sz = buf2_sz;
csd.data_ready_callback(csd.client_callback_data, buf1_sz + buf2_sz, lost_sample_count,
&PcSamplingDataCopyCallback,
/* hsa_callback_data*/ this);
return HSA_STATUS_SUCCESS;
}
hsa_status_t PcsRuntime::PcSamplingIterateConfig(
core::Agent* agent, hsa_ven_amd_pcs_iterate_configuration_callback_t configuration_callback,
void* callback_data) {