Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing of information from the rocminfo application to helping the user to view #95

Open
wants to merge 9 commits into
base: amd-staging
Choose a base branch
from
140 changes: 131 additions & 9 deletions rocminfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,70 @@ AcquireAndDisplayAgentInfo(hsa_agent_t agent, void* data) {
return HSA_STATUS_SUCCESS;
}

static hsa_status_t
showCPUInfo(hsa_agent_t agent, void* data) {
int pool_number = 0;
int isa_number = 0;

hsa_status_t err;
agent_info_t agent_i;

int *agent_number = reinterpret_cast<int*>(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems agent_number is not used, and it can be removed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently it is not used, I had thought to use it when we need to index the individual agent display. So removed and updated in the fork branch as provided below. Also made some changes in help message display
ajitclarencejoseph@026828a

(*agent_number)++;

err = AcquireAgentInfo(agent, &agent_i);
RET_IF_HSA_ERR(err);
if(agent_i.device_type == HSA_DEVICE_TYPE_CPU){
DisplayAgentInfo(&agent_i);

printLabel("Pool Info:", true, 1);
err = hsa_amd_agent_iterate_memory_pools(agent, get_pool_info, &pool_number);
RET_IF_HSA_ERR(err);

printLabel("ISA Info:", true, 1);
err = hsa_agent_iterate_isas(agent, get_isa_info, &isa_number);
if (err == HSA_STATUS_ERROR_INVALID_AGENT) {
printLabel("N/A", true, 2);
return HSA_STATUS_SUCCESS;
}
RET_IF_HSA_ERR(err);
}

return HSA_STATUS_SUCCESS;
}

static hsa_status_t
showGPUInfo(hsa_agent_t agent, void* data) {
int pool_number = 0;
int isa_number = 0;

hsa_status_t err;
agent_info_t agent_i;

int *agent_number = reinterpret_cast<int*>(data);
dayatsin-amd marked this conversation as resolved.
Show resolved Hide resolved
(*agent_number)++;

err = AcquireAgentInfo(agent, &agent_i);
RET_IF_HSA_ERR(err);

if(agent_i.device_type == HSA_DEVICE_TYPE_GPU){
DisplayAgentInfo(&agent_i);

printLabel("Pool Info:", true, 1);
err = hsa_amd_agent_iterate_memory_pools(agent, get_pool_info, &pool_number);
RET_IF_HSA_ERR(err);

printLabel("ISA Info:", true, 1);
err = hsa_agent_iterate_isas(agent, get_isa_info, &isa_number);
if (err == HSA_STATUS_ERROR_INVALID_AGENT) {
printLabel("N/A", true, 2);
return HSA_STATUS_SUCCESS;
}
RET_IF_HSA_ERR(err);
}
return HSA_STATUS_SUCCESS;
}

int CheckInitialState(void) {
// Check kernel module for ROCk is loaded

Expand Down Expand Up @@ -1306,6 +1370,15 @@ int CheckInitialState(void) {
delete []groups;
return -1;
}
#include<iostream>
void print_help(const vector<string>& options, const vector<string>& descriptions) {
std::cout << "Usage: <program_name> [options]\n";
std::cout << "Available options:\n";

for (size_t i = 0; i < options.size(); ++i) {
cout << " -" << options[i] << ": " << descriptions[i] << endl;
}
}

// Print out all static information known to HSA about the target system.
// Throughout this program, the Acquire-type functions make HSA calls to
Expand All @@ -1315,6 +1388,11 @@ int CheckInitialState(void) {
// accumulated data in a formatted way.
int main(int argc, char* argv[]) {
hsa_status_t err;
string option;

for (int i = 1; i < argc; ++i) {
option = argv[i];
}

DetectWSLEnvironment();

Expand All @@ -1326,27 +1404,71 @@ int main(int argc, char* argv[]) {

// Acquire and display system information
system_info_t sys_info;
uint32_t agent_ind = 0;

// This function will call HSA get_info functions to gather information
// about the system.
err = AcquireSystemInfo(&sys_info);
RET_IF_HSA_ERR(err);

//add code for help message
vector<string> options = {"help", "version", "verbose",
"CPU", "GPU", "Sys"
};
vector<string> descriptions = {"Display this help message",
"Print program version information",
"Enable verbose output",
"Display CPU details",
"Display GPU details",
"Display System details"
};


printLabel("=====================", true);
printLabel("HSA System Attributes", true);
printLabel("=====================", true);
DisplaySystemInfo(&sys_info);

// Iterate through every agent and get and display their info
printLabel("==========", true);
printLabel("HSA Agents", true);
printLabel("==========", true);
uint32_t agent_ind = 0;
err = hsa_iterate_agents(AcquireAndDisplayAgentInfo, &agent_ind);
RET_IF_HSA_ERR(err);

printLabel("*** Done ***", true);
if (option == "-h" || option == "--help") {
print_help(options, descriptions);
}
else if (option == "-ver" || option == "--version") {
std::ifstream amdgpu_version("/sys/module/amdgpu/version");
if (amdgpu_version){
std::stringstream buffer;
buffer << amdgpu_version.rdbuf();
std::string vers;
std::getline(buffer, vers);
amdgpu_version.close();
printf("%sROCk module version %s is loaded%s\n", COL_WHT, vers.c_str(), COL_RESET);
}
}
else if (option == "-v" || option == "--verbose") {
}
else if (option == "-c" || option == "--CPU") {
err = hsa_iterate_agents(showCPUInfo, &agent_ind);
}
else if (option == "-g" || option == "--GPU") {
err = hsa_iterate_agents(showGPUInfo, &agent_ind);
}
else if (option == "-s" || option == "--Sys") {
DisplaySystemInfo(&sys_info);
}
else {
DisplaySystemInfo(&sys_info);

// Iterate through every agent and get and display their info
printLabel("==========", true);
printLabel("HSA Agents", true);
printLabel("==========", true);


err = hsa_iterate_agents(AcquireAndDisplayAgentInfo, &agent_ind);
RET_IF_HSA_ERR(err);

printLabel("*** Done ***", true);
}

err = hsa_shut_down();
RET_IF_HSA_ERR(err);
return 0;
Expand Down