Skip to content

Commit

Permalink
AMD GPUs: Call rsmi_init() once
Browse files Browse the repository at this point in the history
  • Loading branch information
amarathe84 committed Jul 7, 2023
1 parent e9b6bcc commit 5150443
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 60 deletions.
60 changes: 0 additions & 60 deletions src/variorum/AMD_GPU/amd_gpu_power_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ void get_power_data(int chipid, int total_sockets, int verbose, FILE *output)

gethostname(hostname, 1024);

ret = rsmi_init(0);
if (ret != RSMI_STATUS_SUCCESS)
{
variorum_error_handler("Could not initialize RSMI",
VARIORUM_ERROR_PLATFORM_ENV,
getenv("HOSTNAME"), __FILE__, __FUNCTION__,
__LINE__);
exit(-1);
}

ret = rsmi_num_monitor_devices(&num_devices);
if (ret != RSMI_STATUS_SUCCESS)
{
Expand Down Expand Up @@ -115,16 +105,6 @@ void get_power_limit_data(int chipid, int total_sockets, int verbose,

gethostname(hostname, 1024);

ret = rsmi_init(0);
if (ret != RSMI_STATUS_SUCCESS)
{
variorum_error_handler("Could not initialize RSMI",
VARIORUM_ERROR_PLATFORM_ENV,
getenv("HOSTNAME"), __FILE__, __FUNCTION__,
__LINE__);
exit(-1);
}

ret = rsmi_num_monitor_devices(&num_devices);
if (ret != RSMI_STATUS_SUCCESS)
{
Expand Down Expand Up @@ -217,16 +197,6 @@ void get_thermals_data(int chipid, int total_sockets, int verbose, FILE *output)

gethostname(hostname, 1024);

ret = rsmi_init(0);
if (ret != RSMI_STATUS_SUCCESS)
{
variorum_error_handler("Could not initialize RSMI",
VARIORUM_ERROR_PLATFORM_ENV,
getenv("HOSTNAME"), __FILE__, __FUNCTION__,
__LINE__);
exit(-1);
}

ret = rsmi_num_monitor_devices(&num_devices);
if (ret != RSMI_STATUS_SUCCESS)
{
Expand Down Expand Up @@ -307,16 +277,6 @@ void get_clocks_data(int chipid, int total_sockets, int verbose, FILE *output)

gethostname(hostname, 1024);

ret = rsmi_init(0);
if (ret != RSMI_STATUS_SUCCESS)
{
variorum_error_handler("Could not initialize RSMI",
VARIORUM_ERROR_PLATFORM_ENV,
getenv("HOSTNAME"), __FILE__, __FUNCTION__,
__LINE__);
exit(-1);
}

ret = rsmi_num_monitor_devices(&num_devices);
if (ret != RSMI_STATUS_SUCCESS)
{
Expand Down Expand Up @@ -408,16 +368,6 @@ void get_gpu_utilization_data(int chipid, int total_sockets, int verbose,

gethostname(hostname, 1024);

ret = rsmi_init(0);
if (ret != RSMI_STATUS_SUCCESS)
{
variorum_error_handler("Could not initialize RSMI",
VARIORUM_ERROR_PLATFORM_ENV,
getenv("HOSTNAME"), __FILE__, __FUNCTION__,
__LINE__);
exit(-1);
}

ret = rsmi_num_monitor_devices(&num_devices);
if (ret != RSMI_STATUS_SUCCESS)
{
Expand Down Expand Up @@ -493,16 +443,6 @@ void cap_each_gpu_power_limit(int chipid, int total_sockets,

gethostname(hostname, 1024);

ret = rsmi_init(0);
if (ret != RSMI_STATUS_SUCCESS)
{
variorum_error_handler("Could not initialize RSMI",
VARIORUM_ERROR_PLATFORM_ENV,
getenv("HOSTNAME"), __FILE__, __FUNCTION__,
__LINE__);
exit(-1);
}

ret = rsmi_num_monitor_devices(&num_devices);
if (ret != RSMI_STATUS_SUCCESS)
{
Expand Down
15 changes: 15 additions & 0 deletions src/variorum/AMD_GPU/config_amd_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ uint64_t *detect_amd_gpu_arch(void)

int set_amd_gpu_func_ptrs(int idx)
{
static int init_complete = 0;
int err = 0;

if (*g_platform[idx].arch_id == AMD_INSTINCT)
Expand All @@ -43,5 +44,19 @@ int set_amd_gpu_func_ptrs(int idx)
err = VARIORUM_ERROR_UNSUPPORTED_PLATFORM;
}


if (init_complete == 0)
{
ret = rsmi_init(0);
if (ret != RSMI_STATUS_SUCCESS)
{
variorum_error_handler("Could not initialize RSMI",
VARIORUM_ERROR_PLATFORM_ENV,
getenv("HOSTNAME"), __FILE__, __FUNCTION__,
__LINE__);
exit(-1);
}
init_complete = 1;
}
return err;
}

0 comments on commit 5150443

Please sign in to comment.