gpu_info_nvml.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef __APPLE__
  2. #ifndef __GPU_INFO_NVML_H__
  3. #define __GPU_INFO_NVML_H__
  4. #include "gpu_info.h"
  5. // Just enough typedef's to dlopen/dlsym for memory information
  6. typedef enum nvmlReturn_enum {
  7. NVML_SUCCESS = 0,
  8. // Other values omitted for now...
  9. } nvmlReturn_t;
  10. typedef void *nvmlDevice_t; // Opaque is sufficient
  11. typedef struct nvmlMemory_st {
  12. unsigned long long total;
  13. unsigned long long free;
  14. unsigned long long used;
  15. } nvmlMemory_t;
  16. typedef enum nvmlBrandType_enum
  17. {
  18. NVML_BRAND_UNKNOWN = 0,
  19. } nvmlBrandType_t;
  20. typedef struct nvml_handle {
  21. void *handle;
  22. uint16_t verbose;
  23. nvmlReturn_t (*nvmlInit_v2)(void);
  24. nvmlReturn_t (*nvmlShutdown)(void);
  25. nvmlReturn_t (*nvmlDeviceGetHandleByIndex)(unsigned int, nvmlDevice_t *);
  26. nvmlReturn_t (*nvmlDeviceGetMemoryInfo)(nvmlDevice_t, nvmlMemory_t *);
  27. } nvml_handle_t;
  28. typedef struct nvml_init_resp {
  29. char *err; // If err is non-null handle is invalid
  30. nvml_handle_t ch;
  31. } nvml_init_resp_t;
  32. typedef struct nvml_compute_capability {
  33. char *err;
  34. int major;
  35. int minor;
  36. } nvml_compute_capability_t;
  37. void nvml_init(char *nvml_lib_path, nvml_init_resp_t *resp);
  38. void nvml_get_free(nvml_handle_t ch, int device_id, uint64_t *free, uint64_t *total, uint64_t *used);
  39. void nvml_release(nvml_handle_t ch);
  40. #endif // __GPU_INFO_NVML_H__
  41. #endif // __APPLE__