Skip to content

Commit

Permalink
rsmi: handle HWLOC_HIDE_ERRORS
Browse files Browse the repository at this point in the history
Cannot use the main one because it's not available to plugins.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed May 28, 2020
1 parent 818f2cf commit e10bc99
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions hwloc/topology-rsmi.c
Expand Up @@ -15,6 +15,20 @@

#include <rocm_smi.h>

/* duplicated from topology.c because cannot be used by plugins */
static int hwloc_hide_rsmi_errors(void)
{
static int hide = 0;
static int checked = 0;
if (!checked) {
const char *envvar = getenv("HWLOC_HIDE_ERRORS");
if (envvar)
hide = atoi(envvar);
checked = 1;
}
return hide;
}

/*
* Get the name of the GPU
*
Expand All @@ -29,7 +43,8 @@ static int get_device_name(uint32_t dv_ind, char *device_name, unsigned int size

if (rsmi_rc != RSMI_STATUS_SUCCESS) {
rsmi_rc = rsmi_status_string(rsmi_rc, &status_string);
fprintf(stderr, "RSMI: GPU(%d): Failed to get name: %s\n", dv_ind, status_string);
if (!hwloc_hide_rsmi_errors())
fprintf(stderr, "RSMI: GPU(%d): Failed to get name: %s\n", dv_ind, status_string);
return -1;
}
return 0;
Expand All @@ -48,7 +63,8 @@ static int get_device_pci_info(uint32_t dv_ind, uint64_t *bdfid)

if (rsmi_rc != RSMI_STATUS_SUCCESS) {
rsmi_rc = rsmi_status_string(rsmi_rc, &status_string);
fprintf(stderr, "RSMI: GPU(%d): Failed to get PCI Info: %s\n", dv_ind, status_string);
if (!hwloc_hide_rsmi_errors())
fprintf(stderr, "RSMI: GPU(%d): Failed to get PCI Info: %s\n", dv_ind, status_string);
return -1;
}
return 0;
Expand Down

0 comments on commit e10bc99

Please sign in to comment.