gpu_info_cuda.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef __APPLE__
  2. #ifndef __GPU_INFO_CUDA_H__
  3. #define __GPU_INFO_CUDA_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 struct cuda_handle {
  17. void *handle;
  18. nvmlReturn_t (*initFn)(void);
  19. nvmlReturn_t (*shutdownFn)(void);
  20. nvmlReturn_t (*getHandle)(unsigned int, nvmlDevice_t *);
  21. nvmlReturn_t (*getMemInfo)(nvmlDevice_t, nvmlMemory_t *);
  22. nvmlReturn_t (*getCount)(unsigned int *);
  23. nvmlReturn_t (*getComputeCapability)(nvmlDevice_t, int* major, int* minor);
  24. } cuda_handle_t;
  25. typedef struct cuda_init_resp {
  26. char *err; // If err is non-null handle is invalid
  27. cuda_handle_t ch;
  28. } cuda_init_resp_t;
  29. typedef struct cuda_compute_capability {
  30. char *err;
  31. int major;
  32. int minor;
  33. } cuda_compute_capability_t;
  34. void cuda_init(cuda_init_resp_t *resp);
  35. void cuda_check_vram(cuda_handle_t ch, mem_info_t *resp);
  36. void cuda_compute_capability(cuda_handle_t ch, cuda_compute_capability_t *cc);
  37. #endif // __GPU_INFO_CUDA_H__
  38. #endif // __APPLE__