adding counters instancing info
Change-Id: Idccc776ed91cafe9662b84bfad4149dde0c82caf
This commit is contained in:
+4
-1
@@ -48,7 +48,7 @@ SOFTWARE.
|
||||
#include <hsa_ven_amd_aqlprofile.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define ROCPROFILER_VERSION_MAJOR 1
|
||||
#define ROCPROFILER_VERSION_MAJOR 2
|
||||
#define ROCPROFILER_VERSION_MINOR 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -331,8 +331,11 @@ typedef struct {
|
||||
union {
|
||||
struct {
|
||||
const char* name; // metric name
|
||||
uint32_t instances; // instances number
|
||||
const char* expr; // metric expression, NULL for basic counters
|
||||
const char* description; // metric description
|
||||
const char* block_name; // block name
|
||||
uint32_t block_counters; // number of block counters
|
||||
} metric;
|
||||
struct {
|
||||
const char* name; // trace name
|
||||
|
||||
@@ -481,6 +481,43 @@ PUBLIC_API hsa_status_t rocprofiler_iterate_info(
|
||||
info.metric.name = strdup(name.c_str());
|
||||
info.metric.description = strdup(descr.c_str());
|
||||
info.metric.expr = expr.empty() ? NULL : strdup(expr.c_str());
|
||||
|
||||
if (expr.empty()) {
|
||||
// Getting the block name
|
||||
const std::string block_name = node->opts["block"];
|
||||
|
||||
// Querying profile
|
||||
rocprofiler::profile_t profile = {};
|
||||
profile.agent = agent_info->dev_id;
|
||||
profile.type = HSA_VEN_AMD_AQLPROFILE_EVENT_TYPE_PMC;
|
||||
|
||||
// Query block id info
|
||||
hsa_ven_amd_aqlprofile_id_query_t query = {block_name.c_str(), 0, 0};
|
||||
hsa_status_t status = rocprofiler::util::HsaRsrcFactory::Instance().AqlProfileApi()->hsa_ven_amd_aqlprofile_get_info(
|
||||
&profile, HSA_VEN_AMD_AQLPROFILE_INFO_BLOCK_ID, &query);
|
||||
if (status != HSA_STATUS_SUCCESS) AQL_EXC_RAISING(HSA_STATUS_ERROR, "get block id info: '" << block_name << "'");
|
||||
|
||||
// Metric object
|
||||
const std::string metric_name = (query.instance_count > 1) ? name + "[0]" : name;
|
||||
const rocprofiler::Metric* metric = dict->Get(metric_name);
|
||||
if (metric == NULL) EXC_RAISING(HSA_STATUS_ERROR, "metric '" << name << "' is not found");
|
||||
|
||||
// Process metrics counters
|
||||
const rocprofiler::counters_vec_t& counters_vec = metric->GetCounters();
|
||||
if (counters_vec.size() != 1) EXC_RAISING(HSA_STATUS_ERROR, "error: '" << metric->GetName() << "' is not basic");
|
||||
|
||||
// Query block counters number
|
||||
uint32_t block_counters;
|
||||
profile.events = &(counters_vec[0]->event);
|
||||
status = rocprofiler::util::HsaRsrcFactory::Instance().AqlProfileApi()->hsa_ven_amd_aqlprofile_get_info(
|
||||
&profile, HSA_VEN_AMD_AQLPROFILE_INFO_BLOCK_COUNTERS, &block_counters);
|
||||
if (status != HSA_STATUS_SUCCESS) continue;
|
||||
|
||||
info.metric.instances = query.instance_count;
|
||||
info.metric.block_name = block_name.c_str();
|
||||
info.metric.block_counters = block_counters;
|
||||
}
|
||||
|
||||
status = callback(info, data);
|
||||
if (status != HSA_STATUS_SUCCESS) break;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ SOFTWARE.
|
||||
#define AQL_EXC_RAISING(error, stream) \
|
||||
{ \
|
||||
const char* error_string = NULL; \
|
||||
const rocprofiler::pfn_t* api = util::HsaRsrcFactory::Instance().AqlProfileApi(); \
|
||||
const rocprofiler::pfn_t* api = rocprofiler::util::HsaRsrcFactory::Instance().AqlProfileApi(); \
|
||||
api->hsa_ven_amd_aqlprofile_error_string(&error_string); \
|
||||
EXC_RAISING(error, stream << ", " << error_string); \
|
||||
}
|
||||
|
||||
+12
-3
@@ -646,8 +646,16 @@ static hsa_status_t info_callback(const rocprofiler_info_data_t info, void * arg
|
||||
if (((symb == 'b') && (info.metric.expr == NULL)) ||
|
||||
((symb == 'd') && (info.metric.expr != NULL)))
|
||||
{
|
||||
printf("\n gpu-agent%d : %s : %s\n", info.agent_index, info.metric.name, info.metric.description);
|
||||
if (info.metric.expr != NULL) printf(" %s = %s\n", info.metric.name, info.metric.expr);
|
||||
if (info.metric.expr != NULL) {
|
||||
fprintf(stdout, "\n gpu-agent%d : %s : %s\n", info.agent_index, info.metric.name, info.metric.description);
|
||||
fprintf(stdout, " %s = %s\n", info.metric.name, info.metric.expr);
|
||||
} else {
|
||||
fprintf(stdout, "\n gpu-agent%d : %s", info.agent_index, info.metric.name);
|
||||
if (info.metric.instances > 1) fprintf(stdout, "[0-%u]", info.metric.instances - 1);
|
||||
fprintf(stdout, " : %s\n", info.metric.description);
|
||||
fprintf(stdout, " block %s has %u counters\n", info.metric.block_name, info.metric.block_counters);
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -802,7 +810,8 @@ extern "C" PUBLIC_API void OnLoadToolProp(rocprofiler_settings_t* settings)
|
||||
} else {
|
||||
if (*info_symb == 'b') printf("Basic HW counters:\n");
|
||||
else printf("Derived metrics:\n");
|
||||
rocprofiler_iterate_info(NULL, ROCPROFILER_INFO_KIND_METRIC, info_callback, info_symb);
|
||||
hsa_status_t status = rocprofiler_iterate_info(NULL, ROCPROFILER_INFO_KIND_METRIC, info_callback, info_symb);
|
||||
check_status(status);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user