Agent Profiling Fixes for Broken/Improper API Usage (#1122)

Prevent's multiple setups of agent profiling on the same agent.

Fixes agent read context to only read agents that were setup.

Prevent copy of agent profiling internal data struct and reset
hsa_signal on move to prevent inadvertant delete.
此提交包含在:
Benjamin Welton authored and GitHub committed 2024-10-18 15:48:22 -07:00
1 父節點 b502f98ea3
當前提交 788e687167
5 file changed
+18 -2

No files matched your search

+2
查看文件
@@ -84,6 +84,8 @@ typedef void (*rocprofiler_device_counting_service_callback_t)(
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID Returned if the context does not exist.
* @retval ::ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND Returned if the buffer is not found.
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT Returned if context already has agent
* profiling configured for agent_id.
* @retval ::ROCPROFILER_STATUS_SUCCESS Returned if succesfully configured
*/
rocprofiler_status_t
+1
查看文件
@@ -91,6 +91,7 @@ struct dispatch_counter_collection_service
struct device_counting_service
{
std::unordered_set<uint64_t> conf_agents;
std::vector<rocprofiler::counters::agent_callback_data> agent_data;
enum class state
+5
查看文件
@@ -92,6 +92,11 @@ CounterController::configure_agent_collection(rocprofiler_context_id_t context_i
std::make_unique<rocprofiler::context::device_counting_service>();
}
if(ctx.device_counter_collection->conf_agents.emplace(agent_id.handle).second == false)
{
return ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT;
}
ctx.device_counter_collection->agent_data.emplace_back();
ctx.device_counter_collection->agent_data.back().callback_data =
rocprofiler_user_data_t{.ptr = user_data};
+3 -1
查看文件
@@ -280,6 +280,7 @@ read_agent_ctx(const context::context* ctx,
for(auto& callback_data : agent_ctx.agent_data)
{
if(!callback_data.profile || !callback_data.set_profile) continue;
const auto* agent = agent::get_agent_cache(callback_data.profile->agent);
// If the agent no longer exists or we don't have a profile queue, reading is an error
@@ -402,6 +403,8 @@ start_agent_ctx(const context::context* ctx)
break;
}
callback_data.set_profile = false;
// Ask the tool what profile we should use for this agent
callback_data.cb(
{.handle = ctx->context_idx},
@@ -455,7 +458,6 @@ start_agent_ctx(const context::context* ctx)
continue;
}
callback_data.set_profile = false;
CHECK(callback_data.profile);
// Generate necessary structures in the context (packet gen, etc) to process
+7 -1
查看文件
@@ -73,7 +73,13 @@ struct agent_callback_data
, agent_id(rhs.agent_id)
, cb(rhs.cb)
, buffer(rhs.buffer)
{}
{
rhs.completion.handle = 0;
rhs.start_signal.handle = 0;
}
agent_callback_data& operator=(const agent_callback_data&) = delete;
agent_callback_data(const agent_callback_data&) = delete;
~agent_callback_data();
};