Syllo / nvtop

GPU & Accelerator process monitoring for AMD, Apple, Huawei, Intel, NVIDIA and Qualcomm
Other
7.95k stars 291 forks source link

AMDGPU_FAMILY_YC is not defined in older libdrm versions. #137

Closed bachandi closed 2 years ago

bachandi commented 2 years ago

My libdrm version 2.4.107 does not have AMDGPU_FAMILY_YC defined resulting in this compilation error:

error: ‘AMDGPU_FAMILY_YC’ undeclared (first use in this function); did you mean ‘AMDGPU_FAMILY_AI’?
  521 |       case AMDGPU_FAMILY_YC:
      |            ^~~~~~~~~~~~~~~~
      |            AMDGPU_FAMILY_AI

As I don't have this kind of family installed I guarded this case:

diff --git a/src/extract_gpuinfo_amdgpu.c b/src/extract_gpuinfo_amdgpu.c
index d248fff..8d732fb 100644
--- a/src/extract_gpuinfo_amdgpu.c
+++ b/src/extract_gpuinfo_amdgpu.c
@@ -518,9 +518,11 @@ static void gpuinfo_amdgpu_populate_static_info(struct gpu_info *_gpu_info) {
       case AMDGPU_FAMILY_VGH:
         strncpy(dst, " (Van Gogh)", remaining_len);
         break;
+#ifdef AMDGPU_FAMILY_YC
       case AMDGPU_FAMILY_YC:
         strncpy(dst, " (Yellow Carp)", remaining_len);
         break;
+#endif
       }
     }
   } else

This way it compiles for my libdrm and runs great. Thanks for the new release. But maybe this ifdef is something to consider if you want to support older libdrm versions? Not sure about the other families in other libdrm versions though.

Syllo commented 2 years ago

Good point. I added the guards in 67802dff98da4feeadaaae279ad4880d51bc7ebf. Thanks.

Syllo commented 1 year ago

Good catch, thanks. I will push a patch to guard the cases in ifdef to avoid such problems.

On 4 Apr 2022, at 21:35, Andreas Bachlechner @.***> wrote:

 My libdrm version 2.4.107 does not have AMDGPU_FAMILY_YC defined resulting in this compilation error:

error: ‘AMDGPU_FAMILY_YC’ undeclared (first use in this function); did you mean ‘AMDGPU_FAMILY_AI’? 521 | case AMDGPU_FAMILY_YC: | ^~~~ | AMDGPU_FAMILY_AI As I don't have this kind of family installed I guarded this case:

diff --git a/src/extract_gpuinfo_amdgpu.c b/src/extract_gpuinfo_amdgpu.c index d248fff..8d732fb 100644 --- a/src/extract_gpuinfo_amdgpu.c +++ b/src/extract_gpuinfo_amdgpu.c @@ -518,9 +518,11 @@ static void gpuinfo_amdgpu_populate_static_info(struct gpu_info *_gpu_info) { case AMDGPU_FAMILY_VGH: strncpy(dst, " (Van Gogh)", remaining_len); break; +#ifdef AMDGPU_FAMILY_YC case AMDGPU_FAMILY_YC: strncpy(dst, " (Yellow Carp)", remaining_len); break; +#endif } } } else This way it compiles for my libdrm and runs great. Thanks for the new release. But maybe this ifdef is something to consider if you want to support older libdrm versions? Not sure about the other families in other libdrm versions though.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.