gpu_info_cudart.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef __APPLE__
  2. #ifndef __GPU_INFO_CUDART_H__
  3. #define __GPU_INFO_CUDART_H__
  4. #include "gpu_info.h"
  5. // Just enough typedef's to dlopen/dlsym for memory information
  6. typedef enum cudartReturn_enum {
  7. CUDART_SUCCESS = 0,
  8. CUDART_UNSUPPORTED = 1,
  9. // Other values omitted for now...
  10. } cudartReturn_t;
  11. typedef enum cudartDeviceAttr_enum {
  12. cudartDevAttrComputeCapabilityMajor = 75,
  13. cudartDevAttrComputeCapabilityMinor = 76,
  14. } cudartDeviceAttr_t;
  15. typedef void *cudartDevice_t; // Opaque is sufficient
  16. typedef struct cudartMemory_st {
  17. size_t total;
  18. size_t free;
  19. size_t used;
  20. } cudartMemory_t;
  21. typedef struct cudartDriverVersion {
  22. int major;
  23. int minor;
  24. } cudartDriverVersion_t;
  25. typedef struct cudart_handle {
  26. void *handle;
  27. uint16_t verbose;
  28. cudartReturn_t (*cudaSetDevice)(int device);
  29. cudartReturn_t (*cudaDeviceSynchronize)(void);
  30. cudartReturn_t (*cudaDeviceReset)(void);
  31. cudartReturn_t (*cudaMemGetInfo)(size_t *, size_t *);
  32. cudartReturn_t (*cudaGetDeviceCount)(int *);
  33. cudartReturn_t (*cudaDeviceGetAttribute)(int* value, cudartDeviceAttr_t attr, int device);
  34. cudartReturn_t (*cudaDriverGetVersion) (int *driverVersion);
  35. } cudart_handle_t;
  36. typedef struct cudart_init_resp {
  37. char *err; // If err is non-null handle is invalid
  38. cudart_handle_t ch;
  39. } cudart_init_resp_t;
  40. typedef struct cudart_compute_capability {
  41. char *err;
  42. int major;
  43. int minor;
  44. } cudart_compute_capability_t;
  45. void cudart_init(char *cudart_lib_path, cudart_init_resp_t *resp);
  46. void cudart_check_vram(cudart_handle_t ch, mem_info_t *resp);
  47. void cudart_compute_capability(cudart_handle_t th, cudart_compute_capability_t *cc);
  48. #endif // __GPU_INFO_CUDART_H__
  49. #endif // __APPLE__