- Added makefile install and uninstall targets
- Added autotuning engine and user-configurable tuning database
- 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 support for --gpu-temp-retain for NVidia GPU, both Linux and Windows
- Added execution timer of the running kernel to the status display
- Added command prompt to quit at next restore checkpoint
- Added human-readable error message for the OpenCL error codes
- 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
- Replaced NVAPI with NVML on windows
-- Added support for XNVCTRL on Linux to add support for --gpu-temp-retain for NVidia GPU
+
#define NVAPI_INTERFACE extern NvAPI_Status
typedef unsigned long NvU32;
+typedef signed long NvS32;
#define NV_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
#define MAKE_NVAPI_VERSION(typeName,ver) (NvU32)(sizeof(typeName) | ((ver)<<16))
#define NVAPI_MAX_PHYSICAL_GPUS 64
+#define NVAPI_MAX_COOLER_PER_GPU 20
+
+#define GPU_COOLER_LEVELS_VER 0x10000
typedef enum _NvAPI_Status
{
} NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1;
+typedef struct
+{
+ NvS32 Level;
+ NvS32 Policy;
+
+} NvLevel;
+
+typedef struct
+{
+ NvU32 Version;
+ NvLevel Levels[NVAPI_MAX_COOLER_PER_GPU];
+
+} NV_GPU_COOLER_LEVELS;
+
NVAPI_INTERFACE NvAPI_QueryInterface (uint offset);
NVAPI_INTERFACE NvAPI_Initialize ();
NVAPI_INTERFACE NvAPI_Unload ();
NVAPI_INTERFACE NvAPI_EnumPhysicalGPUs (NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
NVAPI_INTERFACE NvAPI_GPU_GetPerfPoliciesInfo (NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info);
NVAPI_INTERFACE NvAPI_GPU_GetPerfPoliciesStatus (NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status);
+NVAPI_INTERFACE NvAPI_GPU_SetCoolerLevels (NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels);
/*
* End of declarations from nvapi.h and subheaders
typedef int (*NVAPI_API_CALL NVAPI_ENUMPHYSICALGPUS) (NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *);
typedef int (*NVAPI_API_CALL NVAPI_GPU_GETPERFPOLICIESINFO) (NvPhysicalGpuHandle, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *);
typedef int (*NVAPI_API_CALL NVAPI_GPU_GETPERFPOLICIESSTATUS) (NvPhysicalGpuHandle, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *);
+typedef int (*NVAPI_API_CALL NVAPI_GPU_SETCOOLERLEVELS) (NvPhysicalGpuHandle, NvU32, NV_GPU_COOLER_LEVELS *);
typedef struct
{
NVAPI_ENUMPHYSICALGPUS NvAPI_EnumPhysicalGPUs;
NVAPI_GPU_GETPERFPOLICIESINFO NvAPI_GPU_GetPerfPoliciesInfo;
NVAPI_GPU_GETPERFPOLICIESSTATUS NvAPI_GPU_GetPerfPoliciesStatus;
+ NVAPI_GPU_SETCOOLERLEVELS NvAPI_GPU_SetCoolerLevels;
} hm_nvapi_lib_t;
int hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
int hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info);
int hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status);
+int hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels);
#endif // HAVE_HWMON
int hm_get_corespeed_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_adl (const uint device_id, const int fanspeed, const int fanpolicy);
+int hm_set_fanspeed_with_device_id_nvapi (const uint device_id, const int fanspeed, const int fanpolicy);
int hm_set_fanspeed_with_device_id_xnvctrl (const uint device_id, const int fanspeed);
void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int value);
HC_LOAD_ADDR(nvapi, NvAPI_EnumPhysicalGPUs, NVAPI_ENUMPHYSICALGPUS, nvapi_QueryInterface, 0xE5AC921F, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesInfo, NVAPI_GPU_GETPERFPOLICIESINFO, nvapi_QueryInterface, 0x409D9841, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesStatus, NVAPI_GPU_GETPERFPOLICIESSTATUS, nvapi_QueryInterface, 0x3D358A0C, NVAPI, 0)
+ HC_LOAD_ADDR(nvapi, NvAPI_GPU_SetCoolerLevels, NVAPI_GPU_SETCOOLERLEVELS, nvapi_QueryInterface, 0x891FA0AE, NVAPI, 0)
return 0;
}
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;
+}
+
#ifdef __MINGW64__
void __security_check_cookie (uintptr_t _StackCookie)
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
- #ifdef _POSIX
+ #ifdef _WIN
+ hm_set_fanspeed_with_device_id_nvapi (device_id, fan_speed_new, 1);
+ #endif
+
+ #ifdef _LINUX
hm_set_fanspeed_with_device_id_xnvctrl (device_id, fan_speed_new);
#endif
}
{
need_nvml = 1;
- #ifdef _POSIX
+ #ifdef _LINUX
need_xnvctrl = 1;
#endif
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
- #ifdef _POSIX
+ #ifdef _WIN
+ rc = hm_set_fanspeed_with_device_id_nvapi (device_id, fanspeed, 1);
+ #endif
+
+ #ifdef _LINUX
rc = set_fan_control (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE);
#endif
}
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
- #ifdef _POSIX
+ #ifdef _WIN
+ rc = hm_set_fanspeed_with_device_id_nvapi (device_id, fanspeed, fanpolicy);
+ #endif
+
+ #ifdef _LINUX
rc = set_fan_control (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE);
#endif
}
return -1;
}
-int hm_set_fanspeed_with_device_id_xnvctrl (const uint device_id, const int fanspeed)
-{
- if (data.hm_device[device_id].fan_set_supported == 1)
- {
- if (data.hm_xnvctrl)
- {
- if (set_fan_speed_target (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, fanspeed) != 0) return -1;
-
- return 0;
- }
- }
-
- return -1;
-}
-
int hm_set_fanspeed_with_device_id_adl (const uint device_id, const int fanspeed, const int fanpolicy)
{
if (data.hm_device[device_id].fan_set_supported == 1)
return -1;
}
+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_nvapi)
+ {
+ 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_nvapi, data.hm_device[device_id].nvapi, 0, &CoolerLevels) != NVAPI_OK) return -1;
+
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int hm_set_fanspeed_with_device_id_xnvctrl (const uint device_id, const int fanspeed)
+{
+ if (data.hm_device[device_id].fan_set_supported == 1)
+ {
+ if (data.hm_xnvctrl)
+ {
+ if (set_fan_speed_target (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, fanspeed) != 0) return -1;
+
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
#endif // HAVE_HWMON
/**