[1/N] Agent Counter Collection Implementation (#832)
Added public API call to setup agent counter collection on a context. Refactored the return types internally for dispatch counter collection to use rocprofiler_status_t (allow for more verbose failures to be surfaced via the API) Subsequent commits will fill out the sampling functionality for agent counter collection. Co-authored-by: Benjamin Welton <ben@amd.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e21609c80e
Коммит
cb3fc070c7
@@ -27,6 +27,7 @@
|
||||
#include <rocprofiler-sdk/fwd.h>
|
||||
#include <rocprofiler-sdk/rocprofiler.h>
|
||||
|
||||
#include "lib/rocprofiler-sdk/buffer.hpp"
|
||||
#include "lib/rocprofiler-sdk/context/context.hpp"
|
||||
|
||||
namespace rocprofiler
|
||||
@@ -62,11 +63,42 @@ CounterController::destroy_profile(uint64_t id)
|
||||
_configs.wlock([&](auto& data) { data.erase(id); });
|
||||
}
|
||||
|
||||
rocprofiler_status_t
|
||||
CounterController::configure_agent_collection(rocprofiler_context_id_t context_id,
|
||||
rocprofiler_buffer_id_t buffer,
|
||||
rocprofiler_profile_config_id_t config_id)
|
||||
{
|
||||
auto* ctx_p = rocprofiler::context::get_mutable_registered_context(context_id);
|
||||
if(!ctx_p) return ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID;
|
||||
|
||||
auto& ctx = *ctx_p;
|
||||
|
||||
if(ctx.counter_collection) return ROCPROFILER_STATUS_ERROR_AGENT_DISPATCH_CONFLICT;
|
||||
if(!rocprofiler::buffer::get_buffer(buffer.handle))
|
||||
{
|
||||
return ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND;
|
||||
}
|
||||
auto cfg = get_profile_cfg(config_id);
|
||||
|
||||
if(!cfg) return ROCPROFILER_STATUS_ERROR_PROFILE_NOT_FOUND;
|
||||
|
||||
if(!ctx.agent_counter_collection)
|
||||
{
|
||||
ctx.agent_counter_collection =
|
||||
std::make_unique<rocprofiler::context::agent_counter_collection_service>();
|
||||
}
|
||||
|
||||
ctx.agent_counter_collection->profile = cfg;
|
||||
ctx.agent_counter_collection->buffer = buffer;
|
||||
|
||||
return ROCPROFILER_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Setup the counter collection service. counter_callback_info is created here
|
||||
// to contain the counters that need to be collected (specified in profile_id) and
|
||||
// the AQL packet generator for injecting packets. Note: the service is created
|
||||
// in the stop state.
|
||||
bool
|
||||
rocprofiler_status_t
|
||||
CounterController::configure_dispatch(
|
||||
rocprofiler_context_id_t context_id,
|
||||
rocprofiler_buffer_id_t buffer,
|
||||
@@ -76,10 +108,12 @@ CounterController::configure_dispatch(
|
||||
void* record_callback_args)
|
||||
{
|
||||
auto* ctx_p = rocprofiler::context::get_mutable_registered_context(context_id);
|
||||
if(!ctx_p) return false;
|
||||
if(!ctx_p) return ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID;
|
||||
|
||||
auto& ctx = *ctx_p;
|
||||
|
||||
if(ctx.agent_counter_collection) return ROCPROFILER_STATUS_ERROR_AGENT_DISPATCH_CONFLICT;
|
||||
|
||||
if(!ctx.counter_collection)
|
||||
{
|
||||
ctx.counter_collection =
|
||||
@@ -100,7 +134,7 @@ CounterController::configure_dispatch(
|
||||
cb.record_callback = record_callback;
|
||||
cb.record_callback_args = record_callback_args;
|
||||
|
||||
return true;
|
||||
return ROCPROFILER_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
std::shared_ptr<profile_config>
|
||||
|
||||
Ссылка в новой задаче
Block a user