- Add dynamic NVML loading for Linux GPU detection - Add macOS GPU detection via IOKit framework - Add Zig NVML wrapper for cross-platform GPU queries - Update native bridge to support platform-specific GPU libs - Add CMake support for NVML dynamic library
53 lines
1.4 KiB
C
53 lines
1.4 KiB
C
#ifndef NVML_DYNAMIC_H
|
|
#define NVML_DYNAMIC_H
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// Opaque handle
|
|
typedef struct nvml_dynamic nvml_dynamic_t;
|
|
|
|
// GPU info structure
|
|
typedef struct {
|
|
uint32_t index;
|
|
char name[256];
|
|
uint32_t utilization; // GPU utilization (0-100)
|
|
uint64_t memory_used; // Memory used in bytes
|
|
uint64_t memory_total; // Total memory in bytes
|
|
uint32_t temperature; // Temperature in Celsius
|
|
uint32_t power_draw; // Power draw in milliwatts
|
|
uint32_t clock_sm; // SM clock in MHz
|
|
uint32_t clock_memory; // Memory clock in MHz
|
|
uint32_t pcie_gen; // PCIe generation
|
|
uint32_t pcie_width; // PCIe link width
|
|
char uuid[64]; // GPU UUID
|
|
char vbios_version[32]; // VBIOS version
|
|
} gpu_info_t;
|
|
|
|
// Load NVML dynamically (returns NULL if not available)
|
|
nvml_dynamic_t* nvml_load(void);
|
|
|
|
// Unload NVML and free resources
|
|
void nvml_unload(nvml_dynamic_t* nvml);
|
|
|
|
// Check if NVML is available and loaded
|
|
int nvml_is_available(const nvml_dynamic_t* nvml);
|
|
|
|
// Get number of GPUs (-1 on error)
|
|
int nvml_get_gpu_count(nvml_dynamic_t* nvml);
|
|
|
|
// Get GPU info by index (returns 0 on success)
|
|
int nvml_get_gpu_info(nvml_dynamic_t* nvml, uint32_t index, gpu_info_t* info);
|
|
|
|
// Get last error message
|
|
const char* nvml_last_error(const nvml_dynamic_t* nvml);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // NVML_DYNAMIC_H
|