Adding more info

This commit is contained in:
Dr-Noob
2025-10-17 08:31:26 +02:00
parent 82ea16fc3d
commit 5beccaebb0

View File

@@ -23,6 +23,8 @@ struct agent_info {
char device_mkt_name[64];
uint32_t max_clock_freq;
uint32_t compute_unit;
uint32_t bus_width;
uint32_t lds_size;
};
#define RET_IF_HSA_ERR(err) { \
@@ -40,6 +42,22 @@ struct agent_info {
} \
}
hsa_status_t get_lds_size_callback(hsa_region_t region, void* data) {
hsa_region_segment_t segment;
hsa_status_t err = hsa_region_get_info(region, HSA_REGION_INFO_SEGMENT, &segment);
RET_IF_HSA_ERR(err);
if (segment == HSA_REGION_SEGMENT_GROUP) {
size_t size = 0;
err = hsa_region_get_info(region, HSA_REGION_INFO_SIZE, &size);
RET_IF_HSA_ERR(err);
*(size_t*)data = size;
}
return HSA_STATUS_SUCCESS;
}
hsa_status_t agent_callback(hsa_agent_t agent, void *data) {
struct agent_info* info = reinterpret_cast<struct agent_info *>(data);
@@ -62,6 +80,13 @@ hsa_status_t agent_callback(hsa_agent_t agent, void *data) {
err = hsa_agent_get_info(agent, (hsa_agent_info_t) HSA_AMD_AGENT_INFO_COMPUTE_UNIT_COUNT, &info->compute_unit);
RET_IF_HSA_ERR(err);
// According to the documentation, this is deprecated. But what should I be using then?
err = hsa_agent_get_info(agent, (hsa_agent_info_t) HSA_AMD_REGION_INFO_BUS_WIDTH, &info->bus_width);
RET_IF_HSA_ERR(err);
err = hsa_agent_iterate_regions(agent, get_lds_size_callback, &info->lds_size);
RET_IF_HSA_ERR(err);
}
return HSA_STATUS_SUCCESS;