Profiler - Remove buffer to fix memory leaks
Change-Id: Ia3717ccfc147221557f5469965c2abb76b3f451c Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
This commit is contained in:
committed by
Galantsev, Dmitrii
parent
58811fecbb
commit
dfae9cd37f
@@ -22,10 +22,8 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string_view>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "rdc/rdc.h"
|
#include "rdc/rdc.h"
|
||||||
@@ -33,7 +31,7 @@ THE SOFTWARE.
|
|||||||
rdc_handle_t rdc_handle;
|
rdc_handle_t rdc_handle;
|
||||||
rdc_status_t result;
|
rdc_status_t result;
|
||||||
|
|
||||||
constexpr std::string_view value_to_string(rdc_field_value value) {
|
const std::string value_to_string(rdc_field_value value) {
|
||||||
switch (value.type) {
|
switch (value.type) {
|
||||||
case INTEGER:
|
case INTEGER:
|
||||||
return std::to_string(value.value.l_int);
|
return std::to_string(value.value.l_int);
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ class CounterSampler {
|
|||||||
private:
|
private:
|
||||||
rocprofiler_agent_id_t agent_ = {};
|
rocprofiler_agent_id_t agent_ = {};
|
||||||
rocprofiler_context_id_t ctx_ = {};
|
rocprofiler_context_id_t ctx_ = {};
|
||||||
rocprofiler_buffer_id_t buf_ = {};
|
|
||||||
rocprofiler_profile_config_id_t profile_ = {.handle = 0};
|
rocprofiler_profile_config_id_t profile_ = {.handle = 0};
|
||||||
|
|
||||||
std::map<std::vector<std::string>, rocprofiler_profile_config_id_t> cached_profiles_;
|
std::map<std::vector<std::string>, rocprofiler_profile_config_id_t> cached_profiles_;
|
||||||
|
|||||||
@@ -63,31 +63,13 @@ std::vector<std::shared_ptr<CounterSampler>>& CounterSampler::get_samplers() { r
|
|||||||
|
|
||||||
CounterSampler::CounterSampler(rocprofiler_agent_id_t agent) : agent_(agent) {
|
CounterSampler::CounterSampler(rocprofiler_agent_id_t agent) : agent_(agent) {
|
||||||
// Setup context (should only be done once per agent)
|
// Setup context (should only be done once per agent)
|
||||||
auto client_thread = rocprofiler_callback_thread_t{};
|
|
||||||
RocprofilerCall([&]() { return rocprofiler_create_context(&ctx_); }, "context creation failed",
|
RocprofilerCall([&]() { return rocprofiler_create_context(&ctx_); }, "context creation failed",
|
||||||
__FILE__, __LINE__);
|
__FILE__, __LINE__);
|
||||||
|
|
||||||
RocprofilerCall(
|
|
||||||
[&]() {
|
|
||||||
// 4096 is total buffer size
|
|
||||||
// 2048 is size for callback buffer, not likely used as rdc reads results immediately, not
|
|
||||||
// from buffer feature will drop in future
|
|
||||||
return rocprofiler_create_buffer(
|
|
||||||
ctx_, 4096, 2048, ROCPROFILER_BUFFER_POLICY_LOSSLESS,
|
|
||||||
[](rocprofiler_context_id_t, rocprofiler_buffer_id_t, rocprofiler_record_header_t**,
|
|
||||||
size_t, void*, uint64_t) {},
|
|
||||||
nullptr, &buf_);
|
|
||||||
},
|
|
||||||
"buffer creation failed", __FILE__, __LINE__);
|
|
||||||
RocprofilerCall([&]() { return rocprofiler_create_callback_thread(&client_thread); },
|
|
||||||
"failure creating callback thread", __FILE__, __LINE__);
|
|
||||||
RocprofilerCall([&]() { return rocprofiler_assign_callback_thread(buf_, client_thread); },
|
|
||||||
"failed to assign thread for buffer", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
RocprofilerCall(
|
RocprofilerCall(
|
||||||
[&]() {
|
[&]() {
|
||||||
return rocprofiler_configure_device_counting_service(
|
return rocprofiler_configure_device_counting_service(
|
||||||
ctx_, buf_, agent,
|
ctx_, {.handle = 0}, agent,
|
||||||
[](rocprofiler_context_id_t context_id, rocprofiler_agent_id_t,
|
[](rocprofiler_context_id_t context_id, rocprofiler_agent_id_t,
|
||||||
rocprofiler_agent_set_profile_callback_t set_config, void* user_data) {
|
rocprofiler_agent_set_profile_callback_t set_config, void* user_data) {
|
||||||
if (user_data) {
|
if (user_data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user