Don't use all sysfs files if metrics_path
#include <fcntl.h>
#include "loaders/loader_libdrm.h"
#endif
+#include "amdgpu.h"
using namespace std::chrono_literals;
@@ -76,6 +77,8 @@ nvapi_util();
}
void getAmdGpuInfo(){
+ int64_t value = 0;
+ if (metrics_path.empty()){
if (amdgpu.busy) {
rewind(amdgpu.busy);
fflush(amdgpu.busy);
@@ -94,24 +97,6 @@ void getAmdGpuInfo(){
gpu_info.temp = value / 1000;
}
- int64_t value = 0;
-
- if (amdgpu.vram_total) {
- rewind(amdgpu.vram_total);
- fflush(amdgpu.vram_total);
- if (fscanf(amdgpu.vram_total, "%" PRId64, &value) != 1)
- value = 0;
- gpu_info.memoryTotal = float(value) / (1024 * 1024 * 1024);
- }
-
- if (amdgpu.vram_used) {
- rewind(amdgpu.vram_used);
- fflush(amdgpu.vram_used);
- if (fscanf(amdgpu.vram_used, "%" PRId64, &value) != 1)
- value = 0;
- gpu_info.memoryUsed = float(value) / (1024 * 1024 * 1024);
- }
-
if (amdgpu.core_clock) {
rewind(amdgpu.core_clock);
fflush(amdgpu.core_clock);
@@ -140,6 +125,23 @@ void getAmdGpuInfo(){
}
}
+ if (amdgpu.vram_total) {
+ rewind(amdgpu.vram_total);
+ fflush(amdgpu.vram_total);
+ if (fscanf(amdgpu.vram_total, "%" PRId64, &value) != 1)
+ value = 0;
+ gpu_info.memoryTotal = float(value) / (1024 * 1024 * 1024);
+ }
+
+ if (amdgpu.vram_used) {
+ rewind(amdgpu.vram_used);
+ fflush(amdgpu.vram_used);
+ if (fscanf(amdgpu.vram_used, "%" PRId64, &value) != 1)
+ value = 0;
+ gpu_info.memoryUsed = float(value) / (1024 * 1024 * 1024);
+ }
+}
+
#ifdef HAVE_LIBDRM_AMDGPU
#define DRM_ATLEAST_VERSION(ver, maj, min) \
(ver->version_major > maj || (ver->version_major == maj && ver->version_minor >= min))
