1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-18 11:40:58 +00:00

Added support for --gpu-temp-retain for nvidia devices on windows

Disabled retain support by default, you can reactive it using --gpu-temp-retain
Completely get rid of HAVE_ADL, HAVE_NVML and HAVE_NVAPI in sources
This commit is contained in:
jsteube 2016-05-30 00:05:46 +02:00
parent 8ffbeac954
commit 19e36694da
10 changed files with 275 additions and 320 deletions

View File

@ -23,7 +23,8 @@ It combines all features of all hashcat projects in one project.
- Added makefile native compilation target - Added makefile native compilation target
- Added makefile install and uninstall targets - Added makefile install and uninstall targets
- Added autotuning engine and user-configurable tuning database - Added autotuning engine and user-configurable tuning database
- Added current engine clock and current memory clock to the status display - Added current engine clock, current memory clock and pci-e lanes to the status display
- Added support for --gpu-temp-retain for nvidia devices on windows
- Added execution timer of the running kernel to the status display - Added execution timer of the running kernel to the status display
- Added command prompt to quit at next restore checkpoint - Added command prompt to quit at next restore checkpoint
- Added human-readable error message for the OpenCL error codes - Added human-readable error message for the OpenCL error codes
@ -130,3 +131,5 @@ It combines all features of all hashcat projects in one project.
- Created environment variable to inform NVidia OpenCL runtime to not create its own kernel cache - Created environment variable to inform NVidia OpenCL runtime to not create its own kernel cache
- Created environment variable to inform pocl OpenCL runtime to not create its own kernel cache - Created environment variable to inform pocl OpenCL runtime to not create its own kernel cache
- Dropped special 64-bit rotate() handling for NV, it seems that they've added it to their OpenCL runtime - Dropped special 64-bit rotate() handling for NV, it seems that they've added it to their OpenCL runtime
- Disabled retain support by default, you can reactive it using --gpu-temp-retain
- Completely get rid of HAVE_ADL, HAVE_NVML and HAVE_NVAPI in sources

View File

@ -9,7 +9,7 @@
#ifndef EXT_ADL_H #ifndef EXT_ADL_H
#define EXT_ADL_H #define EXT_ADL_H
#if defined(HAVE_HWMON) && defined(HAVE_ADL) #if defined(HAVE_HWMON)
#include <common.h> #include <common.h>
@ -393,6 +393,6 @@ int hm_ADL_Overdrive6_PowerControl_Caps (ADL_PTR *adl, int iAdapterIndex, int *l
int hm_ADL_Overdrive6_TargetTemperatureData_Get (ADL_PTR *adl, int iAdapterIndex, int *cur_temp, int *default_temp); int hm_ADL_Overdrive6_TargetTemperatureData_Get (ADL_PTR *adl, int iAdapterIndex, int *cur_temp, int *default_temp);
int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo); int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo);
#endif // HAVE_HWMON && HAVE_ADL #endif // HAVE_HWMON
#endif // EXT_ADL_H #endif // EXT_ADL_H

View File

@ -8,7 +8,7 @@
#ifndef EXT_NVAPI_H #ifndef EXT_NVAPI_H
#define EXT_NVAPI_H #define EXT_NVAPI_H
#if defined(HAVE_HWMON) && defined(HAVE_NVAPI) #if defined(HAVE_HWMON)
#include <common.h> #include <common.h>
@ -296,7 +296,9 @@ typedef struct
#define NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER MAKE_NVAPI_VERSION(NV_GPU_DYNAMIC_PSTATES_INFO_EX,1) #define NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER MAKE_NVAPI_VERSION(NV_GPU_DYNAMIC_PSTATES_INFO_EX,1)
#define NVAPI_MAX_COOLER_PER_GPU 20 #define NVAPI_MAX_COOLER_PER_GPU 20
#define GPU_COOLER_SETTINGS_VER 0x20000 #define GPU_COOLER_SETTINGS_VER 0x20000
#define GPU_COOLER_LEVELS_VER 0x10000
// Used in NV_GPU_COOLER_SETTINGS // Used in NV_GPU_COOLER_SETTINGS
typedef struct typedef struct
@ -325,6 +327,20 @@ typedef struct
} NV_GPU_COOLER_SETTINGS; } NV_GPU_COOLER_SETTINGS;
typedef struct
{
NvS32 Level;
NvS32 Policy;
} NvLevel;
typedef struct
{
NvU32 Version;
NvLevel Levels[NVAPI_MAX_COOLER_PER_GPU];
} NV_GPU_COOLER_LEVELS;
#define NVAPI_MAX_GPU_PUBLIC_CLOCKS 32 #define NVAPI_MAX_GPU_PUBLIC_CLOCKS 32
typedef enum _NV_GPU_PUBLIC_CLOCK_ID typedef enum _NV_GPU_PUBLIC_CLOCK_ID
@ -407,6 +423,7 @@ NVAPI_INTERFACE NvAPI_EnumPhysicalGPUs(NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX
NVAPI_INTERFACE NvAPI_GPU_GetThermalSettings(NvPhysicalGpuHandle hPhysicalGpu, NvU32 sensorIndex, NV_GPU_THERMAL_SETTINGS *pThermalSettings); NVAPI_INTERFACE NvAPI_GPU_GetThermalSettings(NvPhysicalGpuHandle hPhysicalGpu, NvU32 sensorIndex, NV_GPU_THERMAL_SETTINGS *pThermalSettings);
NVAPI_INTERFACE NvAPI_GPU_GetTachReading(NvPhysicalGpuHandle hPhysicalGPU, NvU32 *pValue); NVAPI_INTERFACE NvAPI_GPU_GetTachReading(NvPhysicalGpuHandle hPhysicalGPU, NvU32 *pValue);
NVAPI_INTERFACE NvAPI_GPU_GetCoolerSettings(NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_SETTINGS *pCoolerSettings); NVAPI_INTERFACE NvAPI_GPU_GetCoolerSettings(NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_SETTINGS *pCoolerSettings);
NVAPI_INTERFACE NvAPI_GPU_SetCoolerLevels(NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels);
NVAPI_INTERFACE NvAPI_GPU_GetDynamicPstatesInfoEx(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_DYNAMIC_PSTATES_INFO_EX *pDynamicPstatesInfoEx); NVAPI_INTERFACE NvAPI_GPU_GetDynamicPstatesInfoEx(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_DYNAMIC_PSTATES_INFO_EX *pDynamicPstatesInfoEx);
NVAPI_INTERFACE NvAPI_GPU_GetAllClockFrequencies(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_CLOCK_FREQUENCIES *pClkFreqs); NVAPI_INTERFACE NvAPI_GPU_GetAllClockFrequencies(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_CLOCK_FREQUENCIES *pClkFreqs);
NVAPI_INTERFACE NvAPI_GPU_GetCurrentPCIEDownstreamWidth(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pWidth); NVAPI_INTERFACE NvAPI_GPU_GetCurrentPCIEDownstreamWidth(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pWidth);
@ -478,6 +495,7 @@ typedef int (*NVAPI_ENUMPHYSICALGPUS) (NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX
typedef int (*NVAPI_GPU_GETTHERMALSETTINGS) (NvPhysicalGpuHandle, NvU32, NV_GPU_THERMAL_SETTINGS *); typedef int (*NVAPI_GPU_GETTHERMALSETTINGS) (NvPhysicalGpuHandle, NvU32, NV_GPU_THERMAL_SETTINGS *);
typedef int (*NVAPI_GPU_GETTACHREADING) (NvPhysicalGpuHandle, NvU32 *); typedef int (*NVAPI_GPU_GETTACHREADING) (NvPhysicalGpuHandle, NvU32 *);
typedef int (*NVAPI_GPU_GETCOOLERSETTINGS) (NvPhysicalGpuHandle, NvU32, NV_GPU_COOLER_SETTINGS *); typedef int (*NVAPI_GPU_GETCOOLERSETTINGS) (NvPhysicalGpuHandle, NvU32, NV_GPU_COOLER_SETTINGS *);
typedef int (*NVAPI_GPU_SETCOOLERLEVELS) (NvPhysicalGpuHandle, NvU32, NV_GPU_COOLER_LEVELS *);
typedef int (*NVAPI_GPU_GETDYNAMICPSTATESINFOEX) (NvPhysicalGpuHandle, NV_GPU_DYNAMIC_PSTATES_INFO_EX *); typedef int (*NVAPI_GPU_GETDYNAMICPSTATESINFOEX) (NvPhysicalGpuHandle, NV_GPU_DYNAMIC_PSTATES_INFO_EX *);
typedef int (*NVAPI_GPU_GETALLCLOCKFREQUENCIES) (NvPhysicalGpuHandle, NV_GPU_CLOCK_FREQUENCIES *); typedef int (*NVAPI_GPU_GETALLCLOCKFREQUENCIES) (NvPhysicalGpuHandle, NV_GPU_CLOCK_FREQUENCIES *);
typedef int (*NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH) (NvPhysicalGpuHandle, NvU32 *); typedef int (*NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH) (NvPhysicalGpuHandle, NvU32 *);
@ -495,6 +513,7 @@ typedef struct
NVAPI_GPU_GETTHERMALSETTINGS NvAPI_GPU_GetThermalSettings; NVAPI_GPU_GETTHERMALSETTINGS NvAPI_GPU_GetThermalSettings;
NVAPI_GPU_GETTACHREADING NvAPI_GPU_GetTachReading; NVAPI_GPU_GETTACHREADING NvAPI_GPU_GetTachReading;
NVAPI_GPU_GETCOOLERSETTINGS NvAPI_GPU_GetCoolerSettings; NVAPI_GPU_GETCOOLERSETTINGS NvAPI_GPU_GetCoolerSettings;
NVAPI_GPU_SETCOOLERLEVELS NvAPI_GPU_SetCoolerLevels;
NVAPI_GPU_GETDYNAMICPSTATESINFOEX NvAPI_GPU_GetDynamicPstatesInfoEx; NVAPI_GPU_GETDYNAMICPSTATESINFOEX NvAPI_GPU_GetDynamicPstatesInfoEx;
NVAPI_GPU_GETALLCLOCKFREQUENCIES NvAPI_GPU_GetAllClockFrequencies; NVAPI_GPU_GETALLCLOCKFREQUENCIES NvAPI_GPU_GetAllClockFrequencies;
NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH NvAPI_GPU_GetCurrentPCIEDownstreamWidth; NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH NvAPI_GPU_GetCurrentPCIEDownstreamWidth;
@ -515,11 +534,12 @@ int hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle
int hm_NvAPI_GPU_GetThermalSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 sensorIndex, NV_GPU_THERMAL_SETTINGS *pThermalSettings); int hm_NvAPI_GPU_GetThermalSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 sensorIndex, NV_GPU_THERMAL_SETTINGS *pThermalSettings);
int hm_NvAPI_GPU_GetTachReading (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGPU, NvU32 *pValue); int hm_NvAPI_GPU_GetTachReading (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGPU, NvU32 *pValue);
int hm_NvAPI_GPU_GetCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_SETTINGS *pCoolerSettings); int hm_NvAPI_GPU_GetCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_SETTINGS *pCoolerSettings);
int hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels);
int hm_NvAPI_GPU_GetDynamicPstatesInfoEx (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_DYNAMIC_PSTATES_INFO_EX *pDynamicPstatesInfoEx); int hm_NvAPI_GPU_GetDynamicPstatesInfoEx (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_DYNAMIC_PSTATES_INFO_EX *pDynamicPstatesInfoEx);
int hm_NvAPI_GPU_GetAllClockFrequencies (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_CLOCK_FREQUENCIES *pClkFreqs); int hm_NvAPI_GPU_GetAllClockFrequencies (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_CLOCK_FREQUENCIES *pClkFreqs);
int hm_NvAPI_GPU_GetCurrentPCIEDownstreamWidth (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pWidth); int hm_NvAPI_GPU_GetCurrentPCIEDownstreamWidth (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pWidth);
int hm_NvAPI_GPU_GetPerfDecreaseInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pPerfDecrInfo); int hm_NvAPI_GPU_GetPerfDecreaseInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pPerfDecrInfo);
#endif // HAVE_HWMON && HAVE_NVAPI #endif // HAVE_HWMON
#endif // EXT_NVAPI_H #endif // EXT_NVAPI_H

View File

@ -9,7 +9,7 @@
#ifndef EXT_NVML_H #ifndef EXT_NVML_H
#define EXT_NVML_H #define EXT_NVML_H
#if defined(HAVE_HWMON) && defined(HAVE_NVML) #if defined(HAVE_HWMON)
#include <common.h> #include <common.h>
@ -128,6 +128,6 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetTemperatureThreshold (NVML_PTR *nvml, nvmlDevi
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (NVML_PTR *nvml, nvmlDevice_t device, unsigned int *currLinkGen); nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (NVML_PTR *nvml, nvmlDevice_t device, unsigned int *currLinkGen);
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (NVML_PTR *nvml, nvmlDevice_t device, unsigned int *currLinkWidth); nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (NVML_PTR *nvml, nvmlDevice_t device, unsigned int *currLinkWidth);
#endif // HAVE_HWMON && HAVE_NVML #endif // HAVE_HWMON
#endif // EXT_NVML_H #endif // EXT_NVML_H

View File

@ -1434,11 +1434,8 @@ void fsync (int fd);
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]); int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]);
#endif
#ifdef HAVE_ADL
int get_adapters_num_amd (void *adl, int *iNumberAdapters); int get_adapters_num_amd (void *adl, int *iNumberAdapters);
int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo); int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
@ -1452,18 +1449,26 @@ int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_
// int hm_get_device_num (void *adl, HM_ADAPTER_AMD hm_adapter_index, int *hm_device_num); // int hm_get_device_num (void *adl, HM_ADAPTER_AMD hm_adapter_index, int *hm_device_num);
// void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices, cl_device_id *devices); // void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices, cl_device_id *devices);
#endif // HAVE_ADL
int hm_get_threshold_slowdown_with_device_id (const uint device_id); int hm_get_threshold_slowdown_with_device_id (const uint device_id);
int hm_get_temperature_with_device_id (const uint device_id); int hm_get_temperature_with_device_id (const uint device_id);
int hm_get_fanspeed_with_device_id (const uint device_id); int hm_get_fanspeed_with_device_id (const uint device_id);
int hm_get_fanpolicy_with_device_id (const uint device_id);
int hm_get_buslanes_with_device_id (const uint device_id); int hm_get_buslanes_with_device_id (const uint device_id);
int hm_get_utilization_with_device_id (const uint device_id); int hm_get_utilization_with_device_id (const uint device_id);
int hm_get_memoryspeed_with_device_id (const uint device_id); int hm_get_memoryspeed_with_device_id (const uint device_id);
int hm_get_corespeed_with_device_id (const uint device_id); int hm_get_corespeed_with_device_id (const uint device_id);
int hm_get_throttle_with_device_id (const uint device_id); int hm_get_throttle_with_device_id (const uint device_id);
int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed); int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed, const int fanpolicy);
#if defined(WIN)
int hm_set_fanspeed_with_device_id_nvapi (const uint device_id, const int fanspeed, const int fanpolicy);
#endif
#if defined(LINUX)
int hm_set_fanspeed_with_device_id_nvml (const uint device_id, const int fanspeed, const int fanpolicy);
#endif
void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int value); void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int value);
#endif // HAVE_HWMON #endif // HAVE_HWMON

View File

@ -1088,18 +1088,15 @@ typedef struct
{ {
union union
{ {
#ifdef HAVE_ADL
HM_ADAPTER_AMD amd; HM_ADAPTER_AMD amd;
#endif
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
HM_ADAPTER_NV nv; HM_ADAPTER_NV nv;
#endif
} adapter_index; } adapter_index;
int od_version; int od_version;
int fan_supported;
int fan_get_supported;
int fan_set_supported;
int gpu_temp_threshold_slowdown; int gpu_temp_threshold_slowdown;
int gpu_temp_threshold_shutdown; int gpu_temp_threshold_shutdown;

View File

@ -49,12 +49,6 @@ DOCUMENT_FOLDER ?= $(PREFIX)/share/doc/$(PROG_NAME)
OPENCL_HEADERS_KHRONOS := deps/OpenCL-Headers OPENCL_HEADERS_KHRONOS := deps/OpenCL-Headers
##
WITH_ADL := 1
WITH_NVML := 1
WITH_NVAPI := 1
## ##
## Native compiler paths ## Native compiler paths
## ##
@ -93,11 +87,9 @@ ifndef DEBUG
CFLAGS += -O2 CFLAGS += -O2
else else
CFLAGS += -DDEBUG -g -ggdb CFLAGS += -DDEBUG -g -ggdb
ifeq ($(DEBUG),2) ifeq ($(DEBUG),2)
CFLAGS += -fsanitize=address -fno-omit-frame-pointer CFLAGS += -fsanitize=address -fno-omit-frame-pointer
endif endif
endif endif
## ##
@ -108,41 +100,20 @@ BINARY_NATIVE := $(PROG_NAME)
ifeq ($(UNAME),Darwin) ifeq ($(UNAME),Darwin)
export MACOSX_DEPLOYMENT_TARGET=10.9 export MACOSX_DEPLOYMENT_TARGET=10.9
BINARY_NATIVE := $(BINARY_NATIVE).app
BINARY_NATIVE := $(PROG_NAME).app
CFLAGS_NATIVE := -D_POSIX -DOSX CFLAGS_NATIVE := -D_POSIX -DOSX
CFLAGS_NATIVE += $(CFLAGS) CFLAGS_NATIVE += $(CFLAGS)
LFLAGS_NATIVE := -lpthread LFLAGS_NATIVE := -lpthread
WITH_ADL := 0
WITH_NVML := 0
endif # darwin endif # darwin
ifeq ($(UNAME),Linux) ifeq ($(UNAME),Linux)
CFLAGS_NATIVE := -D_POSIX -DLINUX CFLAGS_NATIVE := -D_POSIX -DLINUX
ifndef DEBUG ifndef DEBUG
CFLAGS_NATIVE += -s CFLAGS_NATIVE += -s
endif endif
CFLAGS_NATIVE += $(CFLAGS) CFLAGS_NATIVE += $(CFLAGS)
LFLAGS_NATIVE := -lpthread -ldl LFLAGS_NATIVE := -lpthread -ldl
ifneq (,$(filter 1,$(WITH_ADL) $(WITH_NVML)))
CFLAGS_NATIVE += -DHAVE_HWMON CFLAGS_NATIVE += -DHAVE_HWMON
ifeq ($(WITH_ADL),1)
CFLAGS_NATIVE += -DHAVE_ADL
endif
ifeq ($(WITH_NVML),1)
CFLAGS_NATIVE += -DHAVE_NVML
endif
endif
endif # linux endif # linux
## ##
@ -156,40 +127,17 @@ CFLAGS_CROSS_LINUX += -s
endif endif
CFLAGS_CROSS_LINUX += $(CFLAGS) CFLAGS_CROSS_LINUX += $(CFLAGS)
CFLAGS_CROSS_LINUX +=
ifneq (,$(filter 1,$(WITH_ADL) $(WITH_NVML)))
CFLAGS_CROSS_LINUX += -DHAVE_HWMON CFLAGS_CROSS_LINUX += -DHAVE_HWMON
ifeq ($(WITH_ADL),1) CFLAGS_CROSS_WIN := -D_WIN -DWIN -D__MSVCRT__ -D__USE_MINGW_ANSI_STDIO=1
CFLAGS_CROSS_LINUX += -DHAVE_ADL
endif
ifeq ($(WITH_NVML),1)
CFLAGS_CROSS_LINUX += -DHAVE_NVML
endif
endif
CFLAGS_CROSS_WIN := -D_WIN -DWIN -D__MSVCRT__ -D__USE_MINGW_ANSI_STDIO=1
ifndef DEBUG ifndef DEBUG
CFLAGS_CROSS_WIN += -s CFLAGS_CROSS_WIN += -s
endif endif
CFLAGS_CROSS_WIN += $(filter-out -fsanitize=address,$(CFLAGS)) CFLAGS_CROSS_WIN += $(filter-out -fsanitize=address,$(CFLAGS))
ifneq (,$(filter 1,$(WITH_ADL) $(WITH_NVAPI)))
CFLAGS_CROSS_WIN += -DHAVE_HWMON CFLAGS_CROSS_WIN += -DHAVE_HWMON
ifeq ($(WITH_ADL),1)
CFLAGS_CROSS_WIN += -DHAVE_ADL
endif
ifeq ($(WITH_NVAPI),1)
CFLAGS_CROSS_WIN += -DHAVE_NVAPI
endif
endif
CFLAGS_CROSS_32 := -m32 CFLAGS_CROSS_32 := -m32
CFLAGS_CROSS_64 := -m64 CFLAGS_CROSS_64 := -m64
@ -202,40 +150,17 @@ LFLAGS_CROSS_WIN := -lpsapi
NATIVE_OBJS := obj/ext_OpenCL.NATIVE.o obj/shared.NATIVE.o obj/rp_kernel_on_cpu.NATIVE.o NATIVE_OBJS := obj/ext_OpenCL.NATIVE.o obj/shared.NATIVE.o obj/rp_kernel_on_cpu.NATIVE.o
ifneq (,$(filter 1,$(WITH_ADL) $(WITH_NVML))) ifeq ($(UNAME),Linux)
ifeq ($(WITH_ADL),1)
NATIVE_OBJS += obj/ext_ADL.NATIVE.o NATIVE_OBJS += obj/ext_ADL.NATIVE.o
endif
ifeq ($(WITH_NVML),1)
NATIVE_OBJS += obj/ext_nvml.NATIVE.o NATIVE_OBJS += obj/ext_nvml.NATIVE.o
endif endif
endif
LINUX_32_OBJS := obj/ext_OpenCL.LINUX.32.o obj/shared.LINUX.32.o obj/rp_kernel_on_cpu.LINUX.32.o LINUX_32_OBJS := obj/ext_OpenCL.LINUX.32.o obj/shared.LINUX.32.o obj/rp_kernel_on_cpu.LINUX.32.o obj/ext_ADL.LINUX.32.o obj/ext_nvml.LINUX.32.o
LINUX_64_OBJS := obj/ext_OpenCL.LINUX.64.o obj/shared.LINUX.64.o obj/rp_kernel_on_cpu.LINUX.64.o LINUX_64_OBJS := obj/ext_OpenCL.LINUX.64.o obj/shared.LINUX.64.o obj/rp_kernel_on_cpu.LINUX.64.o obj/ext_ADL.LINUX.64.o obj/ext_nvml.LINUX.64.o
WIN_32_OBJS := obj/ext_OpenCL.WIN.32.o obj/shared.WIN.32.o obj/rp_kernel_on_cpu.WIN.32.o
WIN_64_OBJS := obj/ext_OpenCL.WIN.64.o obj/shared.WIN.64.o obj/rp_kernel_on_cpu.WIN.64.o
ifeq ($(WITH_ADL),1)
LINUX_32_OBJS += obj/ext_ADL.LINUX.32.o
LINUX_64_OBJS += obj/ext_ADL.LINUX.64.o
WIN_32_OBJS += obj/ext_ADL.WIN.32.o
WIN_64_OBJS += obj/ext_ADL.WIN.64.o
endif
ifeq ($(WITH_NVML),1)
LINUX_32_OBJS += obj/ext_nvml.LINUX.32.o
LINUX_64_OBJS += obj/ext_nvml.LINUX.64.o
endif
ifeq ($(WITH_NVAPI),1)
WIN_32_OBJS += obj/ext_nvapi.WIN.32.o
WIN_64_OBJS += obj/ext_nvapi.WIN.64.o
endif
WIN_32_OBJS := obj/ext_OpenCL.WIN.32.o obj/shared.WIN.32.o obj/rp_kernel_on_cpu.WIN.32.o obj/ext_ADL.WIN.32.o obj/ext_nvapi.WIN.32.o
WIN_64_OBJS := obj/ext_OpenCL.WIN.64.o obj/shared.WIN.64.o obj/rp_kernel_on_cpu.WIN.64.o obj/ext_ADL.WIN.64.o obj/ext_nvapi.WIN.64.o
## ##
## Targets: Global ## Targets: Global
## ##

View File

@ -36,6 +36,7 @@ int nvapi_init (NVAPI_PTR *nvapi)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetThermalSettings, NVAPI_GPU_GETTHERMALSETTINGS, nvapi_QueryInterface, 0xE3640A56, NVAPI, 0) HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetThermalSettings, NVAPI_GPU_GETTHERMALSETTINGS, nvapi_QueryInterface, 0xE3640A56, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetTachReading, NVAPI_GPU_GETTACHREADING, nvapi_QueryInterface, 0x5F608315, NVAPI, 0) HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetTachReading, NVAPI_GPU_GETTACHREADING, nvapi_QueryInterface, 0x5F608315, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetCoolerSettings, NVAPI_GPU_GETCOOLERSETTINGS, nvapi_QueryInterface, 0xDA141340, NVAPI, 0) HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetCoolerSettings, NVAPI_GPU_GETCOOLERSETTINGS, nvapi_QueryInterface, 0xDA141340, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_SetCoolerLevels, NVAPI_GPU_SETCOOLERLEVELS, nvapi_QueryInterface, 0x891FA0AE, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetAllClockFrequencies, NVAPI_GPU_GETALLCLOCKFREQUENCIES, nvapi_QueryInterface, 0xDCB616C3, NVAPI, 0) HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetAllClockFrequencies, NVAPI_GPU_GETALLCLOCKFREQUENCIES, nvapi_QueryInterface, 0xDCB616C3, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetCurrentPCIEDownstreamWidth, NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH, nvapi_QueryInterface, 0xD048C3B1, NVAPI, 0) HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetCurrentPCIEDownstreamWidth, NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH, nvapi_QueryInterface, 0xD048C3B1, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfDecreaseInfo, NVAPI_GPU_GETPERFDECREASEINFO, nvapi_QueryInterface, 0x7F7F4600, NVAPI, 0) HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfDecreaseInfo, NVAPI_GPU_GETPERFDECREASEINFO, nvapi_QueryInterface, 0x7F7F4600, NVAPI, 0)
@ -171,6 +172,24 @@ int hm_NvAPI_GPU_GetCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysi
return NvAPI_rc; return NvAPI_rc;
} }
int hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels)
{
if (!nvapi) return (-1);
NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_SetCoolerLevels (hPhysicalGpu, coolerIndex, pCoolerLevels);
if (NvAPI_rc != NVAPI_OK)
{
NvAPI_ShortString string = { 0 };
hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string);
log_info ("WARN: %s %d %s\n", "NvAPI_GPU_SetCoolerLevels()", NvAPI_rc, string);
}
return NvAPI_rc;
}
int hm_NvAPI_GPU_GetDynamicPstatesInfoEx (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_DYNAMIC_PSTATES_INFO_EX *pDynamicPstatesInfoEx) int hm_NvAPI_GPU_GetDynamicPstatesInfoEx (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_DYNAMIC_PSTATES_INFO_EX *pDynamicPstatesInfoEx)
{ {
if (!nvapi) return (-1); if (!nvapi) return (-1);

View File

@ -76,7 +76,7 @@ double TARGET_MS_PROFILE[4] = { 2, 12, 96, 480 };
#define BITMAP_MAX 24 #define BITMAP_MAX 24
#define GPU_TEMP_DISABLE 0 #define GPU_TEMP_DISABLE 0
#define GPU_TEMP_ABORT 90 #define GPU_TEMP_ABORT 90
#define GPU_TEMP_RETAIN 70 #define GPU_TEMP_RETAIN 0
#define WORKLOAD_PROFILE 2 #define WORKLOAD_PROFILE 2
#define KERNEL_ACCEL 0 #define KERNEL_ACCEL 0
#define KERNEL_LOOPS 0 #define KERNEL_LOOPS 0
@ -411,10 +411,8 @@ const char *USAGE_BIG[] =
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
" --gpu-temp-abort | Num | Abort if GPU temperature reaches X degrees celsius | --gpu-temp-abort=100", " --gpu-temp-abort | Num | Abort if GPU temperature reaches X degrees celsius | --gpu-temp-abort=100",
" --gpu-temp-retain | Num | Try to retain GPU temperature at X degrees celsius | --gpu-temp-retain=95", " --gpu-temp-retain | Num | Try to retain GPU temperature at X degrees celsius | --gpu-temp-retain=95",
#ifdef HAVE_ADL
" --powertune-enable | | Enable automatic power tuning (AMD OverDrive 6 only) |", " --powertune-enable | | Enable automatic power tuning (AMD OverDrive 6 only) |",
#endif #endif
#endif
" --scrypt-tmto | Num | Manually override TMTO value for scrypt to X | --scrypt-tmto=3", " --scrypt-tmto | Num | Manually override TMTO value for scrypt to X | --scrypt-tmto=3",
" -s, --skip | Num | Skip X words from the start | -s 1000000", " -s, --skip | Num | Skip X words from the start | -s 1000000",
" -l, --limit | Num | Limit X words from the start + skipped words | -l 1000000", " -l, --limit | Num | Limit X words from the start + skipped words | -l 1000000",
@ -3820,7 +3818,7 @@ static void *thread_monitor (void *p)
int slowdown_warnings = 0; int slowdown_warnings = 0;
// these variables are mainly used for fan control (AMD only) // these variables are mainly used for fan control
int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int)); int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int));
@ -3829,12 +3827,10 @@ static void *thread_monitor (void *p)
int *temp_diff_old = (int *) mycalloc (data.devices_cnt, sizeof (int)); int *temp_diff_old = (int *) mycalloc (data.devices_cnt, sizeof (int));
int *temp_diff_sum = (int *) mycalloc (data.devices_cnt, sizeof (int)); int *temp_diff_sum = (int *) mycalloc (data.devices_cnt, sizeof (int));
#ifdef HAVE_ADL
int temp_threshold = 1; // degrees celcius int temp_threshold = 1; // degrees celcius
int fan_speed_min = 15; // in percentage int fan_speed_min = 15; // in percentage
int fan_speed_max = 100; int fan_speed_max = 100;
#endif // HAVE_ADL
time_t last_temp_check_time; time_t last_temp_check_time;
#endif // HAVE_HWMON #endif // HAVE_HWMON
@ -3961,12 +3957,11 @@ static void *thread_monitor (void *p)
break; break;
} }
#ifdef HAVE_ADL
const int gpu_temp_retain = data.gpu_temp_retain; const int gpu_temp_retain = data.gpu_temp_retain;
if (gpu_temp_retain) // VENDOR_ID_AMD implied if (gpu_temp_retain)
{ {
if (data.hm_device[device_id].fan_supported == 1) if (data.hm_device[device_id].fan_set_supported == 1)
{ {
int temp_cur = temperature; int temp_cur = temperature;
@ -4006,7 +4001,16 @@ static void *thread_monitor (void *p)
if ((freely_change_fan_speed == 1) || (fan_speed_must_change == 1)) if ((freely_change_fan_speed == 1) || (fan_speed_must_change == 1))
{ {
hm_set_fanspeed_with_device_id_amd (device_id, fan_speed_new); if (device_param->device_vendor_id == VENDOR_ID_AMD)
{
hm_set_fanspeed_with_device_id_amd (device_id, fan_speed_new, 1);
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
#ifdef _WIN
hm_set_fanspeed_with_device_id_nvapi (device_id, fan_speed_new, 1);
#endif
}
fan_speed_chgd[device_id] = 1; fan_speed_chgd[device_id] = 1;
} }
@ -4016,7 +4020,6 @@ static void *thread_monitor (void *p)
} }
} }
} }
#endif // HAVE_ADL
} }
hc_thread_mutex_unlock (mux_adl); hc_thread_mutex_unlock (mux_adl);
@ -5361,7 +5364,7 @@ static uint hlfmt_detect (FILE *fp, uint max_check)
// wrapper around mymalloc for ADL // wrapper around mymalloc for ADL
#if defined(HAVE_HWMON) && defined(HAVE_ADL) #if defined(HAVE_HWMON)
void *__stdcall ADL_Main_Memory_Alloc (const int iSize) void *__stdcall ADL_Main_Memory_Alloc (const int iSize)
{ {
return mymalloc (iSize); return mymalloc (iSize);
@ -5580,10 +5583,8 @@ int main (int argc, char **argv)
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
uint gpu_temp_abort = GPU_TEMP_ABORT; uint gpu_temp_abort = GPU_TEMP_ABORT;
uint gpu_temp_retain = GPU_TEMP_RETAIN; uint gpu_temp_retain = GPU_TEMP_RETAIN;
#ifdef HAVE_ADL
uint powertune_enable = POWERTUNE_ENABLE; uint powertune_enable = POWERTUNE_ENABLE;
#endif #endif
#endif
uint logfile_disable = LOGFILE_DISABLE; uint logfile_disable = LOGFILE_DISABLE;
uint segment_size = SEGMENT_SIZE; uint segment_size = SEGMENT_SIZE;
uint scrypt_tmto = SCRYPT_TMTO; uint scrypt_tmto = SCRYPT_TMTO;
@ -5737,9 +5738,7 @@ int main (int argc, char **argv)
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
{"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT}, {"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT},
{"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN}, {"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN},
#ifdef HAVE_ADL
{"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE}, {"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE},
#endif
#endif // HAVE_HWMON #endif // HAVE_HWMON
{"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE}, {"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE},
{"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES}, {"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES},
@ -5963,11 +5962,6 @@ int main (int argc, char **argv)
uint workload_profile_chgd = 0; uint workload_profile_chgd = 0;
uint opencl_vector_width_chgd = 0; uint opencl_vector_width_chgd = 0;
#if defined(HAVE_HWMON) && defined(HAVE_ADL)
uint gpu_temp_retain_chgd = 0;
uint gpu_temp_abort_chgd = 0;
#endif
optind = 1; optind = 1;
optopt = 0; optopt = 0;
option_index = 0; option_index = 0;
@ -6048,19 +6042,9 @@ int main (int argc, char **argv)
kernel_loops_chgd = 1; break; kernel_loops_chgd = 1; break;
case IDX_GPU_TEMP_DISABLE: gpu_temp_disable = 1; break; case IDX_GPU_TEMP_DISABLE: gpu_temp_disable = 1; break;
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
case IDX_GPU_TEMP_ABORT: gpu_temp_abort = atoi (optarg); case IDX_GPU_TEMP_ABORT: gpu_temp_abort = atoi (optarg); break;
#ifdef HAVE_ADL case IDX_GPU_TEMP_RETAIN: gpu_temp_retain = atoi (optarg); break;
gpu_temp_abort_chgd = 1;
#endif
break;
case IDX_GPU_TEMP_RETAIN: gpu_temp_retain = atoi (optarg);
#ifdef HAVE_ADL
gpu_temp_retain_chgd = 1;
#endif
break;
#ifdef HAVE_ADL
case IDX_POWERTUNE_ENABLE: powertune_enable = 1; break; case IDX_POWERTUNE_ENABLE: powertune_enable = 1; break;
#endif
#endif // HAVE_HWMON #endif // HAVE_HWMON
case IDX_LOGFILE_DISABLE: logfile_disable = 1; break; case IDX_LOGFILE_DISABLE: logfile_disable = 1; break;
case IDX_TRUECRYPT_KEYFILES: truecrypt_keyfiles = optarg; break; case IDX_TRUECRYPT_KEYFILES: truecrypt_keyfiles = optarg; break;
@ -6765,10 +6749,8 @@ int main (int argc, char **argv)
data.skip = skip; data.skip = skip;
data.limit = limit; data.limit = limit;
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
#ifdef HAVE_ADL
data.powertune_enable = powertune_enable; data.powertune_enable = powertune_enable;
#endif #endif
#endif
data.logfile_disable = logfile_disable; data.logfile_disable = logfile_disable;
data.truecrypt_keyfiles = truecrypt_keyfiles; data.truecrypt_keyfiles = truecrypt_keyfiles;
data.veracrypt_keyfiles = veracrypt_keyfiles; data.veracrypt_keyfiles = veracrypt_keyfiles;
@ -6870,7 +6852,7 @@ int main (int argc, char **argv)
logfile_top_uint (outfile_format); logfile_top_uint (outfile_format);
logfile_top_uint (potfile_disable); logfile_top_uint (potfile_disable);
logfile_top_string (potfile_path); logfile_top_string (potfile_path);
#if defined(HAVE_HWMON) && defined(HAVE_ADL) #if defined(HAVE_HWMON)
logfile_top_uint (powertune_enable); logfile_top_uint (powertune_enable);
#endif #endif
logfile_top_uint (scrypt_tmto); logfile_top_uint (scrypt_tmto);
@ -6968,10 +6950,8 @@ int main (int argc, char **argv)
gpu_temp_disable = 1; gpu_temp_disable = 1;
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
#ifdef HAVE_ADL
powertune_enable = 1; powertune_enable = 1;
#endif #endif
#endif
data.status_timer = status_timer; data.status_timer = status_timer;
data.restore_timer = restore_timer; data.restore_timer = restore_timer;
@ -13303,32 +13283,6 @@ int main (int argc, char **argv)
} }
} }
/**
* OpenCL platforms: For each platform check if we need to unset features that we can not use, eg: temp_retain
*/
for (uint platform_id = 0; platform_id < platforms_cnt; platform_id++)
{
cl_platform_id platform = platforms[platform_id];
char platform_vendor[INFOSZ] = { 0 };
hc_clGetPlatformInfo (data.ocl, platform, CL_PLATFORM_VENDOR, sizeof (platform_vendor), platform_vendor, NULL);
#ifdef HAVE_HWMON
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (strcmp (platform_vendor, CL_VENDOR_NV) == 0)
{
// make sure that we do not directly control the fan for NVidia
gpu_temp_retain = 0;
data.gpu_temp_retain = gpu_temp_retain;
}
#endif // HAVE_NVML || HAVE_NVAPI
#endif
}
/** /**
* OpenCL device types: * OpenCL device types:
* In case the user did not specify --opencl-device-types and the user runs hashcat in a system with only a CPU only he probably want to use that CPU. * In case the user did not specify --opencl-device-types and the user runs hashcat in a system with only a CPU only he probably want to use that CPU.
@ -14028,17 +13982,13 @@ int main (int argc, char **argv)
*/ */
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
#if defined(HAVE_NVML) || defined(HAVE_NVAPI) hm_attrs_t hm_adapters_nv[DEVICES_MAX] = { { { 0 }, 0, 0, 0, 0, 0 } };
hm_attrs_t hm_adapters_nv[DEVICES_MAX] = { { { 0 }, 0, 0, 0, 0 } }; hm_attrs_t hm_adapters_amd[DEVICES_MAX] = { { { 0 }, 0, 0, 0, 0, 0 } };
#endif
#ifdef HAVE_ADL
hm_attrs_t hm_adapters_amd[DEVICES_MAX] = { { { 0 }, 0, 0, 0, 0 } };
#endif #endif
if (gpu_temp_disable == 0) if (gpu_temp_disable == 0)
{ {
#if defined(WIN) && defined(HAVE_NVAPI) #if defined(WIN)
NVAPI_PTR *nvapi = (NVAPI_PTR *) mymalloc (sizeof (NVAPI_PTR)); NVAPI_PTR *nvapi = (NVAPI_PTR *) mymalloc (sizeof (NVAPI_PTR));
if (nvapi_init (nvapi) == 0) if (nvapi_init (nvapi) == 0)
@ -14065,13 +14015,13 @@ int main (int argc, char **argv)
pCoolerSettings.Version = GPU_COOLER_SETTINGS_VER | sizeof (NV_GPU_COOLER_SETTINGS); pCoolerSettings.Version = GPU_COOLER_SETTINGS_VER | sizeof (NV_GPU_COOLER_SETTINGS);
if (hm_NvAPI_GPU_GetCoolerSettings (data.hm_nv, hm_adapters_nv[i].adapter_index.nv, 0, &pCoolerSettings) != NVAPI_NOT_SUPPORTED) hm_adapters_nv[i].fan_supported = 1; if (hm_NvAPI_GPU_GetCoolerSettings (data.hm_nv, hm_adapters_nv[i].adapter_index.nv, 0, &pCoolerSettings) != NVAPI_NOT_SUPPORTED) hm_adapters_nv[i].fan_get_supported = 1;
} }
} }
} }
#endif // WIN && HAVE_NVAPI #endif // WIN
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
NVML_PTR *nvml = (NVML_PTR *) mymalloc (sizeof (NVML_PTR)); NVML_PTR *nvml = (NVML_PTR *) mymalloc (sizeof (NVML_PTR));
if (nvml_init (nvml) == 0) if (nvml_init (nvml) == 0)
@ -14096,15 +14046,14 @@ int main (int argc, char **argv)
{ {
unsigned int speed; unsigned int speed;
if (hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nv, 1, hm_adapters_nv[i].adapter_index.nv, &speed) != NVML_ERROR_NOT_SUPPORTED) hm_adapters_nv[i].fan_supported = 1; if (hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nv, 1, hm_adapters_nv[i].adapter_index.nv, &speed) != NVML_ERROR_NOT_SUPPORTED) hm_adapters_nv[i].fan_get_supported = 1;
} }
} }
} }
#endif // LINUX && HAVE_NVML #endif // LINUX
data.hm_amd = NULL; data.hm_amd = NULL;
#ifdef HAVE_ADL
ADL_PTR *adl = (ADL_PTR *) mymalloc (sizeof (ADL_PTR)); ADL_PTR *adl = (ADL_PTR *) mymalloc (sizeof (ADL_PTR));
if (adl_init (adl) == 0) if (adl_init (adl) == 0)
@ -14150,7 +14099,6 @@ int main (int argc, char **argv)
myfree (lpAdapterInfo); myfree (lpAdapterInfo);
} }
} }
#endif // HAVE_ADL
if (data.hm_amd == NULL && data.hm_nv == NULL) if (data.hm_amd == NULL && data.hm_nv == NULL)
{ {
@ -14163,13 +14111,12 @@ int main (int argc, char **argv)
*/ */
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
int *temp_retain_fanspeed_value = (int *) mycalloc (data.devices_cnt, sizeof (int)); int *temp_retain_fanspeed_value = (int *) mycalloc (data.devices_cnt, sizeof (int));
int *temp_retain_fanpolicy_value = (int *) mycalloc (data.devices_cnt, sizeof (int));
#ifdef HAVE_ADL
ADLOD6MemClockState *od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (data.devices_cnt, sizeof (ADLOD6MemClockState)); ADLOD6MemClockState *od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (data.devices_cnt, sizeof (ADLOD6MemClockState));
int *od_power_control_status = (int *) mycalloc (data.devices_cnt, sizeof (int)); int *od_power_control_status = (int *) mycalloc (data.devices_cnt, sizeof (int));
#endif // ADL
#endif #endif
/** /**
@ -14270,6 +14217,8 @@ int main (int argc, char **argv)
#endif #endif
} }
#ifdef HAVE_HWMON
/** /**
* HM devices: copy * HM devices: copy
*/ */
@ -14286,19 +14235,15 @@ int main (int argc, char **argv)
const uint platform_devices_id = device_param->platform_devices_id; const uint platform_devices_id = device_param->platform_devices_id;
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (device_param->device_vendor_id == VENDOR_ID_NV) if (device_param->device_vendor_id == VENDOR_ID_NV)
{ {
memcpy (&data.hm_device[device_id], &hm_adapters_nv[platform_devices_id], sizeof (hm_attrs_t)); memcpy (&data.hm_device[device_id], &hm_adapters_nv[platform_devices_id], sizeof (hm_attrs_t));
} }
#endif
#ifdef HAVE_ADL
if (device_param->device_vendor_id == VENDOR_ID_AMD) if (device_param->device_vendor_id == VENDOR_ID_AMD)
{ {
memcpy (&data.hm_device[device_id], &hm_adapters_amd[platform_devices_id], sizeof (hm_attrs_t)); memcpy (&data.hm_device[device_id], &hm_adapters_amd[platform_devices_id], sizeof (hm_attrs_t));
} }
#endif
} }
} }
@ -14310,7 +14255,6 @@ int main (int argc, char **argv)
* Driver / ADL bug? * Driver / ADL bug?
*/ */
#ifdef HAVE_ADL
if (powertune_enable == 1) if (powertune_enable == 1)
{ {
hc_thread_mutex_lock (mux_adl); hc_thread_mutex_lock (mux_adl);
@ -14360,7 +14304,7 @@ int main (int argc, char **argv)
hc_thread_mutex_unlock (mux_adl); hc_thread_mutex_unlock (mux_adl);
} }
#endif // HAVE_ADK
#endif // HAVE_HWMON #endif // HAVE_HWMON
#ifdef DEBUG #ifdef DEBUG
@ -15648,72 +15592,71 @@ int main (int argc, char **argv)
run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css); run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
} }
#if defined(HAVE_HWMON)
/** /**
* Store thermal target temperature so we can send a notice to user * Store thermal target temperature so we can send a notice to user
*/ */
#if defined(HAVE_HWMON)
if (gpu_temp_disable == 0) if (gpu_temp_disable == 0)
{ {
const int gpu_temp_threshold_slowdown = hm_get_threshold_slowdown_with_device_id (device_id); const int gpu_temp_threshold_slowdown = hm_get_threshold_slowdown_with_device_id (device_id);
data.hm_device[device_id].gpu_temp_threshold_slowdown = (gpu_temp_threshold_slowdown == -1) ? 100000 : gpu_temp_threshold_slowdown; data.hm_device[device_id].gpu_temp_threshold_slowdown = (gpu_temp_threshold_slowdown == -1) ? 100000 : gpu_temp_threshold_slowdown;
} }
#endif
/** /**
* Store initial fanspeed if gpu_temp_retain is enabled * Store initial fanspeed if gpu_temp_retain is enabled
*/ */
#if defined(HAVE_HWMON) && defined(HAVE_ADL)
int gpu_temp_retain_set = 0;
if (gpu_temp_disable == 0) if (gpu_temp_disable == 0)
{ {
if (gpu_temp_retain != 0) // VENDOR_ID_AMD implied if (gpu_temp_retain != 0)
{ {
hc_thread_mutex_lock (mux_adl); hc_thread_mutex_lock (mux_adl);
if (data.hm_device[device_id].fan_supported == 1) if (data.hm_device[device_id].fan_get_supported == 1)
{ {
if (gpu_temp_retain_chgd == 0) const int fanspeed = hm_get_fanspeed_with_device_id (device_id);
const int fanpolicy = hm_get_fanpolicy_with_device_id (device_id);
temp_retain_fanspeed_value[device_id] = fanspeed;
temp_retain_fanpolicy_value[device_id] = fanpolicy;
// we also set it to tell the OS we take control over the fan and it's automatic controller
// if it was set to automatic. we do not control user-defined fanspeeds.
if (fanpolicy == 1)
{ {
uint cur_temp = 0; data.hm_device[device_id].fan_set_supported = 1;
uint default_temp = 0;
int ADL_rc = hm_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, (int *) &cur_temp, (int *) &default_temp); int rc = -1;
if (ADL_rc == ADL_OK) if (device_param->device_vendor_id == VENDOR_ID_AMD)
{ {
#define GPU_TEMP_RETAIN_ABORT_DIFF 15 rc = hm_set_fanspeed_with_device_id_amd (device_id, fanspeed, 1);
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
#ifdef _WIN
rc = hm_set_fanspeed_with_device_id_nvapi (device_id, fanspeed, 1);
#endif
}
const uint gpu_temp_retain_target = default_temp - GPU_TEMP_RETAIN_ABORT_DIFF; if (rc == 0)
{
data.hm_device[device_id].fan_set_supported = 1;
}
else
{
log_info ("WARNING: Failed to set initial fan speed for device #%u", device_id + 1);
// special case with multi gpu setups: always use minimum retain data.hm_device[device_id].fan_set_supported = 0;
if (gpu_temp_retain_set == 0)
{
gpu_temp_retain = gpu_temp_retain_target;
gpu_temp_retain_set = 1;
}
else
{
gpu_temp_retain = MIN (gpu_temp_retain, gpu_temp_retain_target);
}
if (gpu_temp_abort_chgd == 0) gpu_temp_abort = gpu_temp_retain + GPU_TEMP_RETAIN_ABORT_DIFF;
} }
} }
else
const int fan_speed = hm_get_fanspeed_with_device_id (device_id);
temp_retain_fanspeed_value[device_id] = fan_speed;
if (fan_speed == -1)
{ {
log_info ("WARNING: Failed to get current fan speed settings for gpu number: %i:", device_id + 1); data.hm_device[device_id].fan_set_supported = 0;
temp_retain_fanspeed_value[device_id] = 0;
} }
} }
@ -15836,7 +15779,8 @@ int main (int argc, char **argv)
hc_thread_mutex_unlock (mux_adl); hc_thread_mutex_unlock (mux_adl);
} }
#endif // HAVE_HWMON && HAVE_ADL
#endif // HAVE_HWMON
} }
data.kernel_power_all = kernel_power_all; data.kernel_power_all = kernel_power_all;
@ -17949,7 +17893,6 @@ int main (int argc, char **argv)
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
if (gpu_temp_disable == 0) if (gpu_temp_disable == 0)
{ {
#ifdef HAVE_ADL
if (gpu_temp_retain != 0) // VENDOR_ID_AMD is implied here if (gpu_temp_retain != 0) // VENDOR_ID_AMD is implied here
{ {
hc_thread_mutex_lock (mux_adl); hc_thread_mutex_lock (mux_adl);
@ -17960,24 +17903,35 @@ int main (int argc, char **argv)
if (device_param->skipped) continue; if (device_param->skipped) continue;
if (data.hm_device[device_id].fan_supported == 1) if (data.hm_device[device_id].fan_set_supported == 1)
{ {
int fanspeed = temp_retain_fanspeed_value[device_id]; int fanspeed = temp_retain_fanspeed_value[device_id];
int fanpolicy = temp_retain_fanpolicy_value[device_id];
if (fanspeed == -1) continue; if (fanpolicy == 1)
{
int rc = -1;
int rc = hm_set_fanspeed_with_device_id_amd (device_id, fanspeed); if (device_param->device_vendor_id == VENDOR_ID_AMD)
{
rc = hm_set_fanspeed_with_device_id_amd (device_id, fanspeed, 0);
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
#ifdef _WIN
rc = hm_set_fanspeed_with_device_id_nvapi (device_id, fanspeed, 16);
#endif
}
if (rc == -1) log_info ("WARNING: Failed to restore default fan speed for gpu number: %i:", device_id); if (rc == -1) log_info ("WARNING: Failed to restore default fan speed and policy for device #%", device_id + 1);
}
} }
} }
hc_thread_mutex_unlock (mux_adl); hc_thread_mutex_unlock (mux_adl);
} }
#endif // HAVE_ADL
} }
#ifdef HAVE_ADL
// reset power tuning // reset power tuning
if (powertune_enable == 1) // VENDOR_ID_AMD is implied here if (powertune_enable == 1) // VENDOR_ID_AMD is implied here
@ -18039,20 +17993,18 @@ int main (int argc, char **argv)
hc_thread_mutex_unlock (mux_adl); hc_thread_mutex_unlock (mux_adl);
} }
#endif // HAVE_ADL
if (gpu_temp_disable == 0) if (gpu_temp_disable == 0)
{ {
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (data.hm_nv) if (data.hm_nv)
{ {
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
hm_NVML_nvmlShutdown (data.hm_nv); hm_NVML_nvmlShutdown (data.hm_nv);
nvml_close (data.hm_nv); nvml_close (data.hm_nv);
#elif defined(WIN) && (HAVE_NVAPI) #elif defined(WIN)
hm_NvAPI_Unload (data.hm_nv); hm_NvAPI_Unload (data.hm_nv);
@ -18062,17 +18014,15 @@ int main (int argc, char **argv)
data.hm_nv = NULL; data.hm_nv = NULL;
} }
#endif
#ifdef HAVE_ADL
if (data.hm_amd) if (data.hm_amd)
{ {
hm_ADL_Main_Control_Destroy (data.hm_amd); hm_ADL_Main_Control_Destroy (data.hm_amd);
adl_close (data.hm_amd); adl_close (data.hm_amd);
data.hm_amd = NULL; data.hm_amd = NULL;
} }
#endif
} }
#endif // HAVE_HWMON #endif // HAVE_HWMON
@ -18115,10 +18065,8 @@ int main (int argc, char **argv)
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
local_free (temp_retain_fanspeed_value); local_free (temp_retain_fanspeed_value);
#ifdef HAVE_ADL
local_free (od_clock_mem_status); local_free (od_clock_mem_status);
local_free (od_power_control_status); local_free (od_power_control_status);
#endif // ADL
#endif #endif
global_free (devices_param); global_free (devices_param);

View File

@ -2671,7 +2671,8 @@ void fsync (int fd)
*/ */
#ifdef HAVE_HWMON #ifdef HAVE_HWMON
#if defined(_WIN) && defined(HAVE_NVAPI)
#if defined(_WIN)
int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]) int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
{ {
NvU32 pGpuCount; NvU32 pGpuCount;
@ -2687,9 +2688,9 @@ int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
return (pGpuCount); return (pGpuCount);
} }
#endif // _WIN && HAVE_NVAPI #endif // _WIN
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]) int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
{ {
int pGpuCount = 0; int pGpuCount = 0;
@ -2714,9 +2715,8 @@ int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
return (pGpuCount); return (pGpuCount);
} }
#endif // LINUX && HAVE_NVML #endif
#ifdef HAVE_ADL
int get_adapters_num_amd (void *adl, int *iNumberAdapters) int get_adapters_num_amd (void *adl, int *iNumberAdapters)
{ {
if (hm_ADL_Adapter_NumberOfAdapters_Get ((ADL_PTR *) adl, iNumberAdapters) != ADL_OK) return -1; if (hm_ADL_Adapter_NumberOfAdapters_Get ((ADL_PTR *) adl, iNumberAdapters) != ADL_OK) return -1;
@ -2969,11 +2969,11 @@ int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_
if ((FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_READ) && if ((FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_READ) &&
(FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE)) (FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE))
{ {
hm_device[opencl_device_index].fan_supported = 1; hm_device[opencl_device_index].fan_get_supported = 1;
} }
else else
{ {
hm_device[opencl_device_index].fan_supported = 0; hm_device[opencl_device_index].fan_get_supported = 0;
} }
} }
else // od_version == 6 else // od_version == 6
@ -2988,11 +2988,11 @@ int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_
if (faninfo.iSpeedType & ADL_OD6_FANSPEED_TYPE_PERCENT) if (faninfo.iSpeedType & ADL_OD6_FANSPEED_TYPE_PERCENT)
{ {
hm_device[opencl_device_index].fan_supported = 1; hm_device[opencl_device_index].fan_get_supported = 1;
} }
else else
{ {
hm_device[opencl_device_index].fan_supported = 0; hm_device[opencl_device_index].fan_get_supported = 0;
} }
} }
} }
@ -3055,13 +3055,11 @@ int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list,
return num_adl_adapters; return num_adl_adapters;
} }
#endif // HAVE_ADL
int hm_get_threshold_slowdown_with_device_id (const uint device_id) int hm_get_threshold_slowdown_with_device_id (const uint device_id)
{ {
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
#ifdef HAVE_ADL
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{ {
if (data.hm_amd) if (data.hm_amd)
@ -3083,12 +3081,10 @@ int hm_get_threshold_slowdown_with_device_id (const uint device_id)
} }
} }
} }
#endif
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{ {
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
int target = 0; int target = 0;
hm_NVML_nvmlDeviceGetTemperatureThreshold (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target); hm_NVML_nvmlDeviceGetTemperatureThreshold (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target);
@ -3096,11 +3092,10 @@ int hm_get_threshold_slowdown_with_device_id (const uint device_id)
return target; return target;
#endif #endif
#if defined(WIN) && defined(HAVE_NVAPI) #if defined(WIN)
#endif // WIN && HAVE_NVAPI #endif // WIN
} }
#endif // HAVE_NVML || HAVE_NVAPI
return -1; return -1;
} }
@ -3109,7 +3104,6 @@ int hm_get_temperature_with_device_id (const uint device_id)
{ {
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
#ifdef HAVE_ADL
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{ {
if (data.hm_amd) if (data.hm_amd)
@ -3134,12 +3128,10 @@ int hm_get_temperature_with_device_id (const uint device_id)
} }
} }
} }
#endif
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{ {
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
int temperature = 0; int temperature = 0;
hm_NVML_nvmlDeviceGetTemperature (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_GPU, (uint *) &temperature); hm_NVML_nvmlDeviceGetTemperature (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_GPU, (uint *) &temperature);
@ -3147,7 +3139,7 @@ int hm_get_temperature_with_device_id (const uint device_id)
return temperature; return temperature;
#endif #endif
#if defined(WIN) && defined(HAVE_NVAPI) #if defined(WIN)
NV_GPU_THERMAL_SETTINGS pThermalSettings; NV_GPU_THERMAL_SETTINGS pThermalSettings;
pThermalSettings.version = NV_GPU_THERMAL_SETTINGS_VER; pThermalSettings.version = NV_GPU_THERMAL_SETTINGS_VER;
@ -3158,21 +3150,63 @@ int hm_get_temperature_with_device_id (const uint device_id)
if (hm_NvAPI_GPU_GetThermalSettings (data.hm_nv, data.hm_device[device_id].adapter_index.nv, 0, &pThermalSettings) != NVAPI_OK) return -1; if (hm_NvAPI_GPU_GetThermalSettings (data.hm_nv, data.hm_device[device_id].adapter_index.nv, 0, &pThermalSettings) != NVAPI_OK) return -1;
return pThermalSettings.sensor[0].currentTemp; return pThermalSettings.sensor[0].currentTemp;
#endif // WIN && HAVE_NVAPI #endif // WIN
}
return -1;
}
int hm_get_fanpolicy_with_device_id (const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.hm_device[device_id].fan_get_supported == 1)
{
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
if (data.hm_amd)
{
if (data.hm_device[device_id].od_version == 5)
{
ADLFanSpeedValue lpFanSpeedValue;
memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue));
lpFanSpeedValue.iSize = sizeof (lpFanSpeedValue);
lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
if (hm_ADL_Overdrive5_FanSpeed_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1;
return (lpFanSpeedValue.iFanSpeed & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) ? 0 : 1;
}
else // od_version == 6
{
return 1;
}
}
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
#if defined(LINUX)
return 0;
#endif
#if defined(WIN)
return 1;
#endif
}
} }
#endif // HAVE_NVML || HAVE_NVAPI
return -1; return -1;
} }
int hm_get_fanspeed_with_device_id (const uint device_id) int hm_get_fanspeed_with_device_id (const uint device_id)
{ {
// we shouldn't really need this extra CL_DEVICE_TYPE_GPU check, because fan_supported should not be set w/ CPUs
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.hm_device[device_id].fan_supported == 1) if (data.hm_device[device_id].fan_get_supported == 1)
{ {
#ifdef HAVE_ADL
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{ {
if (data.hm_amd) if (data.hm_amd)
@ -3203,12 +3237,10 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
} }
} }
} }
#endif // HAVE_ADL
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{ {
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
int speed = 0; int speed = 0;
hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nv, 1, data.hm_device[device_id].adapter_index.nv, (uint *) &speed); hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nv, 1, data.hm_device[device_id].adapter_index.nv, (uint *) &speed);
@ -3216,17 +3248,16 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
return speed; return speed;
#endif #endif
#if defined(WIN) && defined(HAVE_NVAPI) #if defined(WIN)
NV_GPU_COOLER_SETTINGS pCoolerSettings; NV_GPU_COOLER_SETTINGS pCoolerSettings;
pCoolerSettings.Version = GPU_COOLER_SETTINGS_VER | sizeof (NV_GPU_COOLER_SETTINGS); pCoolerSettings.Version = GPU_COOLER_SETTINGS_VER | sizeof (NV_GPU_COOLER_SETTINGS);
hm_NvAPI_GPU_GetCoolerSettings (data.hm_nv, data.hm_device[device_id].adapter_index.nv, 0, &pCoolerSettings); if (hm_NvAPI_GPU_GetCoolerSettings (data.hm_nv, data.hm_device[device_id].adapter_index.nv, 0, &pCoolerSettings) != NVAPI_OK) return -1;
return pCoolerSettings.Cooler[0].CurrentLevel; return pCoolerSettings.Cooler[0].CurrentLevel;
#endif #endif
} }
#endif // HAVE_NVML || HAVE_NVAPI
} }
return -1; return -1;
@ -3236,7 +3267,6 @@ int hm_get_buslanes_with_device_id (const uint device_id)
{ {
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
#ifdef HAVE_ADL
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{ {
if (data.hm_amd) if (data.hm_amd)
@ -3250,12 +3280,10 @@ int hm_get_buslanes_with_device_id (const uint device_id)
return PMActivity.iCurrentBusLanes; return PMActivity.iCurrentBusLanes;
} }
} }
#endif // HAVE_ADL
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{ {
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
unsigned int currLinkWidth; unsigned int currLinkWidth;
hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &currLinkWidth); hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &currLinkWidth);
@ -3263,7 +3291,7 @@ int hm_get_buslanes_with_device_id (const uint device_id)
return currLinkWidth; return currLinkWidth;
#endif #endif
#if defined(WIN) && defined(HAVE_NVAPI) #if defined(WIN)
int Width; int Width;
if (hm_NvAPI_GPU_GetCurrentPCIEDownstreamWidth (data.hm_nv, data.hm_device[device_id].adapter_index.nv, (NvU32 *) &Width) != NVAPI_OK) return -1; if (hm_NvAPI_GPU_GetCurrentPCIEDownstreamWidth (data.hm_nv, data.hm_device[device_id].adapter_index.nv, (NvU32 *) &Width) != NVAPI_OK) return -1;
@ -3271,7 +3299,6 @@ int hm_get_buslanes_with_device_id (const uint device_id)
return Width; return Width;
#endif #endif
} }
#endif // HAVE_NVML || HAVE_NVAPI
return -1; return -1;
} }
@ -3280,7 +3307,6 @@ int hm_get_utilization_with_device_id (const uint device_id)
{ {
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
#ifdef HAVE_ADL
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{ {
if (data.hm_amd) if (data.hm_amd)
@ -3294,12 +3320,10 @@ int hm_get_utilization_with_device_id (const uint device_id)
return PMActivity.iActivityPercent; return PMActivity.iActivityPercent;
} }
} }
#endif // HAVE_ADL
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{ {
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
nvmlUtilization_t utilization; nvmlUtilization_t utilization;
hm_NVML_nvmlDeviceGetUtilizationRates (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &utilization); hm_NVML_nvmlDeviceGetUtilizationRates (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &utilization);
@ -3307,7 +3331,7 @@ int hm_get_utilization_with_device_id (const uint device_id)
return utilization.gpu; return utilization.gpu;
#endif #endif
#if defined(WIN) && defined(HAVE_NVAPI) #if defined(WIN)
NV_GPU_DYNAMIC_PSTATES_INFO_EX pDynamicPstatesInfoEx; NV_GPU_DYNAMIC_PSTATES_INFO_EX pDynamicPstatesInfoEx;
pDynamicPstatesInfoEx.version = NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER; pDynamicPstatesInfoEx.version = NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER;
@ -3317,7 +3341,6 @@ int hm_get_utilization_with_device_id (const uint device_id)
return pDynamicPstatesInfoEx.utilization[0].percentage; return pDynamicPstatesInfoEx.utilization[0].percentage;
#endif #endif
} }
#endif // HAVE_NVML || HAVE_NVAPI
return -1; return -1;
} }
@ -3326,7 +3349,6 @@ int hm_get_memoryspeed_with_device_id (const uint device_id)
{ {
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
#ifdef HAVE_ADL
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{ {
if (data.hm_amd) if (data.hm_amd)
@ -3340,12 +3362,10 @@ int hm_get_memoryspeed_with_device_id (const uint device_id)
return PMActivity.iMemoryClock / 100; return PMActivity.iMemoryClock / 100;
} }
} }
#endif // HAVE_ADL
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{ {
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
unsigned int clock; unsigned int clock;
hm_NVML_nvmlDeviceGetClockInfo (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_CLOCK_MEM, &clock); hm_NVML_nvmlDeviceGetClockInfo (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_CLOCK_MEM, &clock);
@ -3353,7 +3373,7 @@ int hm_get_memoryspeed_with_device_id (const uint device_id)
return clock; return clock;
#endif #endif
#if defined(WIN) && defined(HAVE_NVAPI) #if defined(WIN)
NV_GPU_CLOCK_FREQUENCIES pClkFreqs = { 0 }; NV_GPU_CLOCK_FREQUENCIES pClkFreqs = { 0 };
pClkFreqs.version = NV_GPU_CLOCK_FREQUENCIES_VER; pClkFreqs.version = NV_GPU_CLOCK_FREQUENCIES_VER;
@ -3364,7 +3384,6 @@ int hm_get_memoryspeed_with_device_id (const uint device_id)
return pClkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_MEMORY].frequency / 1000; return pClkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_MEMORY].frequency / 1000;
#endif #endif
} }
#endif // HAVE_NVML || HAVE_NVAPI
return -1; return -1;
} }
@ -3373,7 +3392,6 @@ int hm_get_corespeed_with_device_id (const uint device_id)
{ {
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
#ifdef HAVE_ADL
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{ {
if (data.hm_amd) if (data.hm_amd)
@ -3387,12 +3405,10 @@ int hm_get_corespeed_with_device_id (const uint device_id)
return PMActivity.iEngineClock / 100; return PMActivity.iEngineClock / 100;
} }
} }
#endif // HAVE_ADL
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{ {
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
unsigned int clock; unsigned int clock;
hm_NVML_nvmlDeviceGetClockInfo (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_CLOCK_SM, &clock); hm_NVML_nvmlDeviceGetClockInfo (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_CLOCK_SM, &clock);
@ -3400,7 +3416,7 @@ int hm_get_corespeed_with_device_id (const uint device_id)
return clock; return clock;
#endif #endif
#if defined(WIN) && defined(HAVE_NVAPI) #if defined(WIN)
NV_GPU_CLOCK_FREQUENCIES pClkFreqs = { 0 }; NV_GPU_CLOCK_FREQUENCIES pClkFreqs = { 0 };
pClkFreqs.version = NV_GPU_CLOCK_FREQUENCIES_VER; pClkFreqs.version = NV_GPU_CLOCK_FREQUENCIES_VER;
@ -3411,7 +3427,6 @@ int hm_get_corespeed_with_device_id (const uint device_id)
return pClkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_GRAPHICS].frequency / 1000; return pClkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_GRAPHICS].frequency / 1000;
#endif #endif
} }
#endif // HAVE_NVML || HAVE_NVAPI
return -1; return -1;
} }
@ -3420,18 +3435,18 @@ int hm_get_throttle_with_device_id (const uint device_id)
{ {
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
#ifdef HAVE_ADL if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
#endif // HAVE_ADL }
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{ {
#if defined(LINUX) && defined(HAVE_NVML) #if defined(LINUX)
#endif #endif
#if defined(WIN) && defined(HAVE_NVAPI) #if defined(WIN)
NvU32 throttle = 0; NvU32 throttle = 0;
if (hm_NvAPI_GPU_GetPerfDecreaseInfo (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &throttle) != NVAPI_OK) return -1; if (hm_NvAPI_GPU_GetPerfDecreaseInfo (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &throttle) != NVAPI_OK) return -1;
@ -3439,15 +3454,13 @@ int hm_get_throttle_with_device_id (const uint device_id)
return throttle; return throttle;
#endif #endif
} }
#endif // HAVE_NVML || HAVE_NVAPI
return -1; return -1;
} }
#ifdef HAVE_ADL int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed, const int fanpolicy)
int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed)
{ {
if (data.hm_device[device_id].fan_supported == 1) if (data.hm_device[device_id].fan_set_supported == 1)
{ {
if (data.hm_amd) if (data.hm_amd)
{ {
@ -3459,7 +3472,7 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
lpFanSpeedValue.iSize = sizeof (lpFanSpeedValue); lpFanSpeedValue.iSize = sizeof (lpFanSpeedValue);
lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED; lpFanSpeedValue.iFlags = (fanpolicy == 1) ? ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED : 0;
lpFanSpeedValue.iFanSpeed = fanspeed; lpFanSpeedValue.iFanSpeed = fanspeed;
if (hm_ADL_Overdrive5_FanSpeed_Set (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1; if (hm_ADL_Overdrive5_FanSpeed_Set (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1;
@ -3484,23 +3497,48 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
return -1; return -1;
} }
#if defined(WIN)
int hm_set_fanspeed_with_device_id_nvapi (const uint device_id, const int fanspeed, const int fanpolicy)
{
if (data.hm_device[device_id].fan_set_supported == 1)
{
if (data.hm_nv)
{
NV_GPU_COOLER_LEVELS CoolerLevels = { 0 };
CoolerLevels.Version = GPU_COOLER_LEVELS_VER | sizeof (NV_GPU_COOLER_LEVELS);
CoolerLevels.Levels[0].Level = fanspeed;
CoolerLevels.Levels[0].Policy = fanpolicy;
if (hm_NvAPI_GPU_SetCoolerLevels (data.hm_nv, data.hm_device[device_id].adapter_index.nv, 0, &CoolerLevels) != NVAPI_OK) return -1;
return 0;
}
}
return -1;
}
#endif #endif
// helper function for status display #if defined(LINUX)
int hm_set_fanspeed_with_device_id_nvml (const uint device_id, const int fanspeed, const int fanpolicy)
void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int value)
{ {
#define VALUE_NOT_AVAILABLE "N/A" if (data.hm_device[device_id].fan_set_supported == 1)
{
if (data.hm_nv)
{
// NVML does not support setting the fan speed... :((
if (value == -1) if (fanspeed == fanpolicy) return -1; // makes the compiler happy
{ }
snprintf (target_buf, max_buf_size, VALUE_NOT_AVAILABLE);
}
else
{
snprintf (target_buf, max_buf_size, "%2d%s", value, suffix);
} }
return -1;
} }
#endif
#endif // HAVE_HWMON #endif // HAVE_HWMON
/** /**