I know this sounds really strange, but I don't know how to even ask this properly. I've been trying to P/Invoke into NVidia's NVML library with limited success: I've managed to call a few of the APIs exported by that library
Now I am trying to call nvmlDeviceGetHandleByIndex_v2
but I've been stuck for a long while on this one. It takes in a nvmlDevice_t
pointer, but I've found nothing on what nvmlDevice_t
actually is beyond this header definition:
typedef struct nvmlDevice_st* nvmlDevice_t;
The problem is that the header file does not make any other reference to nvmlDevice_st
so I don't know how much heap space to allocate for it, if any. I've found this official C++ example that calls that same function like this:
nvmlDevice_t device;
CheckNVMLErrors(nvmlDeviceGetHandleByIndex(device_index, &device));
My main problem is that I'm not familiar enough with C/C++ to understand the implicit mechanics/memory allocation done by the device
declaration, and the nvml.h
header does not define what nvmlDevice_st
actually is.
I tried calling it with a ref int
parameter (with an initial 0
value) and apparently it does work but I want to understand why, if possible. For reference, the value of that ref int
parameter after the call was 1460391512
, in case something can be gleamed off that.