Update rocprofiler_query_available_agents(...) (#596)

* Agent info version

* Complete implementation

- revert "rocprofiler_iterate_agents" to "rocprofiler_query_available_agents"

* Misc tweaks

- update rocprofiler_query_available_agents impl

* Update include/rocprofiler-sdk/agent.h

- Fix undocumented param for rocprofiler_query_available_agents
This commit is contained in:
Jonathan R. Madsen authored and GitHub committed 2024-03-06 02:17:40 -06:00
1 parent 19971d5719
commit 1d33d4cf78
5 files changed
+106 -45

No files matched your search

+26 -9
View File
@@ -877,18 +877,35 @@ get_agent_available_properties()
extern "C" {
rocprofiler_status_t
rocprofiler_query_available_agents(rocprofiler_available_agents_cb_t callback,
size_t agent_size,
void* user_data)
rocprofiler_query_available_agents(rocprofiler_agent_version_t version,
rocprofiler_query_available_agents_cb_t callback,
size_t agent_size,
void* user_data)
{
if(agent_size > sizeof(rocprofiler_agent_t))
// only support version 0 for now
if(version != ROCPROFILER_AGENT_INFO_VERSION_0)
return ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT;
// this will need to be updated for new versions
if(version == ROCPROFILER_AGENT_INFO_VERSION_0)
{
LOG(ERROR) << "rocprofiler_agent_t used by caller is ABI-incompatible with "
"rocprofiler_agent_t in rocprofiler";
return ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_ABI;
if(agent_size > sizeof(rocprofiler_agent_v0_t))
{
LOG(ERROR) << "size of rocprofiler agent struct used by caller is ABI-incompatible "
"with rocprofiler_agent_v0_t in rocprofiler";
return ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_ABI;
}
}
else
{
LOG(FATAL) << "rocprofiler-sdk does not support given agent info version";
}
auto&& pointers = rocprofiler::agent::get_agents();
return callback(pointers.data(), pointers.size(), user_data);
auto&& pointers = rocprofiler::agent::get_agents();
auto v_pointers = std::vector<const void*>{};
v_pointers.reserve(pointers.size());
for(const auto& itr : pointers)
v_pointers.emplace_back(itr);
return callback(version, v_pointers.data(), pointers.size(), user_data);
}
}