Class NvmlFunctions
java.lang.Object
oshi.ffm.ForeignFunctions
oshi.ffm.common.NvmlFunctions
FFM bindings for the NVIDIA Management Library (NVML).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StructLayoutLayout for nvmlMemory_t struct.static final intGraphics clock domain.static final intMemory clock domain.static final intBuffer size for device name queries.static final intSuccessful return code.static final intGPU temperature sensor type.static final StructLayoutLayout for nvmlPciInfo_t struct.static final StructLayoutLayout for nvmlUtilization_t struct.Fields inherited from class ForeignFunctions
CAPTURE_CALL_STATE, CAPTURED_STATE_LAYOUT, ERRNO_HANDLE, LIBRARY_ARENA, LINKER, NATIVE_LONG_SIZE, NATIVE_POINTER_SIZE, NATIVE_SIZE_T_SIZE, SYMBOL_LOOKUP -
Method Summary
Modifier and TypeMethodDescriptionstatic intdeviceGetClockInfo(MemorySegment device, int clockType, MemorySegment clockSeg) Gets clock info for a device.static intdeviceGetCount(MemorySegment countSeg) Gets the device count.static intdeviceGetFanSpeed(MemorySegment device, MemorySegment speedSeg) Gets fan speed for a device.static intdeviceGetHandleByIndex(int index, MemorySegment handleSeg) Gets a device handle by index.static intdeviceGetMemoryInfo(MemorySegment device, MemorySegment memSeg) Gets memory info for a device.static intdeviceGetName(MemorySegment device, MemorySegment nameSeg, int length) Gets the device name.static intdeviceGetPciInfo(MemorySegment device, MemorySegment pciSeg) Gets PCI info for a device.static intdeviceGetPowerUsage(MemorySegment device, MemorySegment powerSeg) Gets power usage for a device.static intdeviceGetTemperature(MemorySegment device, int sensorType, MemorySegment tempSeg) Gets temperature for a device.static intdeviceGetUtilizationRates(MemorySegment device, MemorySegment utilSeg) Gets utilization rates for a device.static intinit()Calls nvmlInit_v2.static booleanReturns whether the NVML native library was successfully loaded.static StringreadString(MemorySegment seg, long offset, int maxLen) Reads a null-terminated string from a byte sequence within a struct segment.static intshutdown()Calls nvmlShutdown.Methods inherited from class ForeignFunctions
downcall, getByteArrayFromNativePointer, getErrno, getStringFromNativePointer, getStructFromNativePointer, lib, libraryLookup
-
Field Details
-
NVML_SUCCESS
public static final int NVML_SUCCESSSuccessful return code.- See Also:
-
NVML_TEMPERATURE_GPU
public static final int NVML_TEMPERATURE_GPUGPU temperature sensor type.- See Also:
-
NVML_CLOCK_GRAPHICS
public static final int NVML_CLOCK_GRAPHICSGraphics clock domain.- See Also:
-
NVML_CLOCK_MEM
public static final int NVML_CLOCK_MEMMemory clock domain.- See Also:
-
NVML_DEVICE_NAME_BUFFER_SIZE
public static final int NVML_DEVICE_NAME_BUFFER_SIZEBuffer size for device name queries.- See Also:
-
UTILIZATION_LAYOUT
Layout for nvmlUtilization_t struct. -
MEMORY_LAYOUT
Layout for nvmlMemory_t struct. -
PCI_INFO_LAYOUT
Layout for nvmlPciInfo_t struct.
-
-
Method Details
-
isAvailable
public static boolean isAvailable()Returns whether the NVML native library was successfully loaded.- Returns:
- true if the NVML library is available
-
init
public static int init()Calls nvmlInit_v2.- Returns:
- NVML return code
-
shutdown
public static int shutdown()Calls nvmlShutdown.- Returns:
- NVML return code
-
deviceGetCount
Gets the device count.- Parameters:
countSeg- pointer to int to receive count- Returns:
- NVML return code
-
deviceGetHandleByIndex
Gets a device handle by index.- Parameters:
index- device indexhandleSeg- pointer to receive device handle- Returns:
- NVML return code
-
deviceGetName
Gets the device name.- Parameters:
device- device handlenameSeg- buffer to receive namelength- buffer length- Returns:
- NVML return code
-
deviceGetPciInfo
Gets PCI info for a device.- Parameters:
device- device handlepciSeg- nvmlPciInfo_t struct to fill- Returns:
- NVML return code
-
deviceGetUtilizationRates
Gets utilization rates for a device.- Parameters:
device- device handleutilSeg- nvmlUtilization_t struct to fill- Returns:
- NVML return code
-
deviceGetMemoryInfo
Gets memory info for a device.- Parameters:
device- device handlememSeg- nvmlMemory_t struct to fill- Returns:
- NVML return code
-
deviceGetTemperature
Gets temperature for a device.- Parameters:
device- device handlesensorType- sensor type constanttempSeg- pointer to int to receive temperature- Returns:
- NVML return code
-
deviceGetPowerUsage
Gets power usage for a device.- Parameters:
device- device handlepowerSeg- pointer to int to receive power in milliwatts- Returns:
- NVML return code
-
deviceGetClockInfo
Gets clock info for a device.- Parameters:
device- device handleclockType- clock type constantclockSeg- pointer to int to receive clock in MHz- Returns:
- NVML return code
-
deviceGetFanSpeed
Gets fan speed for a device.- Parameters:
device- device handlespeedSeg- pointer to int to receive fan speed percentage- Returns:
- NVML return code
-
readString
Reads a null-terminated string from a byte sequence within a struct segment.- Parameters:
seg- the struct segmentoffset- byte offset of the char array fieldmaxLen- maximum length of the char array- Returns:
- the string, or empty if null/empty
-