Class AdlUtil
java.lang.Object
oshi.util.gpu.AdlUtil
Optional runtime binding to the AMD Display Library (ADL) on Windows. All methods return sentinel values (
-1
or -1L) when ADL is unavailable or a specific query fails.
Only Overdrive N (Radeon RX 400 series and newer) is supported. Older Overdrive versions return -1.
The native library is loaded once at class initialization. Each metric call pairs ADL2_Main_Control_Create
with ADL2_Main_Control_Destroy to correctly manage ADL's internal reference count, ensuring OSHI does not
interfere with other code in the same process that may also be managing the ADL lifecycle.
Adapter bus-number-to-index mappings are enumerated once on first successful init and cached thereafter.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intfindAdapterIndex(int pciBusNumber) Finds the ADL adapter index for the given PCI bus number.static longgetCoreClockMhz(int adapterIndex) Returns GPU core clock speed in MHz, or -1 if unavailable.static doublegetFanSpeedPercent(int adapterIndex) Returns GPU fan speed as a percentage (0–100), or -1 if unavailable.static doublegetGpuUtilization(int adapterIndex) Returns GPU core utilization percentage (0–100), or -1 if unavailable.static longgetMemoryClockMhz(int adapterIndex) Returns GPU memory clock speed in MHz, or -1 if unavailable.static doublegetPowerDraw(int adapterIndex) Returns GPU power draw in watts, or -1 if unavailable.static doublegetTemperature(int adapterIndex) Returns GPU temperature in degrees Celsius, or -1 if unavailable.static booleanReturns whether the ADL native library was successfully loaded.
-
Method Details
-
isAvailable
public static boolean isAvailable()Returns whether the ADL native library was successfully loaded. Does not indicate whether any AMD GPU is present or whetherADL2_Main_Control_Createwill succeed.- Returns:
- true if the ADL library is available
-
findAdapterIndex
public static int findAdapterIndex(int pciBusNumber) Finds the ADL adapter index for the given PCI bus number.- Parameters:
pciBusNumber- PCI bus number- Returns:
- adapter index, or -1 if not found or ADL unavailable
-
getTemperature
public static double getTemperature(int adapterIndex) Returns GPU temperature in degrees Celsius, or -1 if unavailable.- Parameters:
adapterIndex- ADL adapter index fromfindAdapterIndex(int)- Returns:
- temperature in °C or -1
-
getGpuUtilization
public static double getGpuUtilization(int adapterIndex) Returns GPU core utilization percentage (0–100), or -1 if unavailable.- Parameters:
adapterIndex- ADL adapter index- Returns:
- utilization percentage or -1
-
getCoreClockMhz
public static long getCoreClockMhz(int adapterIndex) Returns GPU core clock speed in MHz, or -1 if unavailable. ADL reports clocks in 10 kHz units.- Parameters:
adapterIndex- ADL adapter index- Returns:
- core clock in MHz or -1
-
getMemoryClockMhz
public static long getMemoryClockMhz(int adapterIndex) Returns GPU memory clock speed in MHz, or -1 if unavailable.- Parameters:
adapterIndex- ADL adapter index- Returns:
- memory clock in MHz or -1
-
getPowerDraw
public static double getPowerDraw(int adapterIndex) Returns GPU power draw in watts, or -1 if unavailable. Uses Overdrive 6 power API which is available on Overdrive N adapters. Power is reported in units of 1/256 watts.- Parameters:
adapterIndex- ADL adapter index- Returns:
- power in watts or -1
-
getFanSpeedPercent
public static double getFanSpeedPercent(int adapterIndex) Returns GPU fan speed as a percentage (0–100), or -1 if unavailable.- Parameters:
adapterIndex- ADL adapter index- Returns:
- fan speed percentage or -1
-