From d89a8a68d6554f2e25b17c64383a6a2084b386e7 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 31 May 2016 22:48:58 +0200 Subject: [PATCH] Finally got rid of NvAPI on Windows, replace with NVML --- include/ext_nvapi.h | 545 -------------------------------------------- include/shared.h | 12 - src/Makefile | 4 +- src/ext_ADL.c | 4 +- src/ext_nvapi.c | 276 ---------------------- src/ext_nvml.c | 24 +- src/hashcat.c | 57 +---- src/shared.c | 137 ----------- 8 files changed, 30 insertions(+), 1029 deletions(-) delete mode 100644 include/ext_nvapi.h delete mode 100644 src/ext_nvapi.c diff --git a/include/ext_nvapi.h b/include/ext_nvapi.h deleted file mode 100644 index a48c737..0000000 --- a/include/ext_nvapi.h +++ /dev/null @@ -1,545 +0,0 @@ -/** - * Authors.....: Jens Steube - * Gabriele Gristina - * - * License.....: MIT - */ - -#ifndef EXT_NVAPI_H -#define EXT_NVAPI_H - -#if defined(HAVE_HWMON) - -#include - -/* - * Declarations from nvapi.h and subheaders - **/ - -#ifndef __success - #define __nvapi_success - #define __success(epxr) -#endif - -#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl - -/* - * Definitions from nvapi_lite_common.h - */ - -// 64-bit types for compilers that support them, plus some obsolete variants -#if defined(__GNUC__) || defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(__ghs__) || defined(_WIN64) -typedef unsigned long long NvU64; /* 0 to 18446744073709551615 */ -typedef long long NvS64; /* -9223372036854775808 to 9223372036854775807 */ -#else -typedef unsigned __int64 NvU64; /* 0 to 18446744073709551615 */ -typedef __int64 NvS64; /* -9223372036854775808 to 9223372036854775807 */ -#endif - -// mac os 32-bit still needs this -#if (defined(macintosh) || defined(__APPLE__)) && !defined(__LP64__) -typedef signed long NvS32; /* -2147483648 to 2147483647 */ -#else -typedef signed int NvS32; /* -2147483648 to 2147483647 */ -#endif - -// mac os 32-bit still needs this -#if ( (defined(macintosh) && defined(__LP64__) && (__NVAPI_RESERVED0__)) || \ - (!defined(macintosh) && defined(__NVAPI_RESERVED0__)) ) -typedef unsigned int NvU32; /* 0 to 4294967295 */ -#else -typedef unsigned long NvU32; /* 0 to 4294967295 */ -#endif - -typedef signed short NvS16; -typedef unsigned short NvU16; -typedef unsigned char NvU8; -typedef signed char NvS8; - -#define NV_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name - -NV_DECLARE_HANDLE(NvPhysicalGpuHandle); // A single physical GPU - -#define NVAPI_GENERIC_STRING_MAX 4096 -#define NVAPI_LONG_STRING_MAX 256 -#define NVAPI_SHORT_STRING_MAX 64 - -typedef char NvAPI_String[NVAPI_GENERIC_STRING_MAX]; -typedef char NvAPI_LongString[NVAPI_LONG_STRING_MAX]; -typedef char NvAPI_ShortString[NVAPI_SHORT_STRING_MAX]; - -#define MAKE_NVAPI_VERSION(typeName,ver) (NvU32)(sizeof(typeName) | ((ver)<<16)) -#define GET_NVAPI_VERSION(ver) (NvU32)((ver)>>16) -#define GET_NVAPI_SIZE(ver) (NvU32)((ver) & 0xffff) - -#define NVAPI_MAX_PHYSICAL_GPUS 64 - -typedef enum _NvAPI_Status -{ - NVAPI_OK = 0, // Success. Request is completed. - NVAPI_ERROR = -1, // Generic error - NVAPI_LIBRARY_NOT_FOUND = -2, // NVAPI support library cannot be loaded. - NVAPI_NO_IMPLEMENTATION = -3, // not implemented in current driver installation - NVAPI_API_NOT_INITIALIZED = -4, // NvAPI_Initialize has not been called (successfully) - NVAPI_INVALID_ARGUMENT = -5, // The argument/parameter value is not valid or NULL. - NVAPI_NVIDIA_DEVICE_NOT_FOUND = -6, // No NVIDIA display driver, or NVIDIA GPU driving a display, was found. - NVAPI_END_ENUMERATION = -7, // No more items to enumerate - NVAPI_INVALID_HANDLE = -8, // Invalid handle - NVAPI_INCOMPATIBLE_STRUCT_VERSION = -9, // An argument's structure version is not supported - NVAPI_HANDLE_INVALIDATED = -10, // The handle is no longer valid (likely due to GPU or display re-configuration) - NVAPI_OPENGL_CONTEXT_NOT_CURRENT = -11, // No NVIDIA OpenGL context is current (but needs to be) - NVAPI_INVALID_POINTER = -14, // An invalid pointer, usually NULL, was passed as a parameter - NVAPI_NO_GL_EXPERT = -12, // OpenGL Expert is not supported by the current drivers - NVAPI_INSTRUMENTATION_DISABLED = -13, // OpenGL Expert is supported, but driver instrumentation is currently disabled - NVAPI_NO_GL_NSIGHT = -15, // OpenGL does not support Nsight - - NVAPI_EXPECTED_LOGICAL_GPU_HANDLE = -100, // Expected a logical GPU handle for one or more parameters - NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE = -101, // Expected a physical GPU handle for one or more parameters - NVAPI_EXPECTED_DISPLAY_HANDLE = -102, // Expected an NV display handle for one or more parameters - NVAPI_INVALID_COMBINATION = -103, // The combination of parameters is not valid. - NVAPI_NOT_SUPPORTED = -104, // Requested feature is not supported in the selected GPU - NVAPI_PORTID_NOT_FOUND = -105, // No port ID was found for the I2C transaction - NVAPI_EXPECTED_UNATTACHED_DISPLAY_HANDLE = -106, // Expected an unattached display handle as one of the input parameters. - NVAPI_INVALID_PERF_LEVEL = -107, // Invalid perf level - NVAPI_DEVICE_BUSY = -108, // Device is busy; request not fulfilled - NVAPI_NV_PERSIST_FILE_NOT_FOUND = -109, // NV persist file is not found - NVAPI_PERSIST_DATA_NOT_FOUND = -110, // NV persist data is not found - NVAPI_EXPECTED_TV_DISPLAY = -111, // Expected a TV output display - NVAPI_EXPECTED_TV_DISPLAY_ON_DCONNECTOR = -112, // Expected a TV output on the D Connector - HDTV_EIAJ4120. - NVAPI_NO_ACTIVE_SLI_TOPOLOGY = -113, // SLI is not active on this device. - NVAPI_SLI_RENDERING_MODE_NOTALLOWED = -114, // Setup of SLI rendering mode is not possible right now. - NVAPI_EXPECTED_DIGITAL_FLAT_PANEL = -115, // Expected a digital flat panel. - NVAPI_ARGUMENT_EXCEED_MAX_SIZE = -116, // Argument exceeds the expected size. - NVAPI_DEVICE_SWITCHING_NOT_ALLOWED = -117, // Inhibit is ON due to one of the flags in NV_GPU_DISPLAY_CHANGE_INHIBIT or SLI active. - NVAPI_TESTING_CLOCKS_NOT_SUPPORTED = -118, // Testing of clocks is not supported. - NVAPI_UNKNOWN_UNDERSCAN_CONFIG = -119, // The specified underscan config is from an unknown source (e.g. INF) - NVAPI_TIMEOUT_RECONFIGURING_GPU_TOPO = -120, // Timeout while reconfiguring GPUs - NVAPI_DATA_NOT_FOUND = -121, // Requested data was not found - NVAPI_EXPECTED_ANALOG_DISPLAY = -122, // Expected an analog display - NVAPI_NO_VIDLINK = -123, // No SLI video bridge is present - NVAPI_REQUIRES_REBOOT = -124, // NVAPI requires a reboot for the settings to take effect - NVAPI_INVALID_HYBRID_MODE = -125, // The function is not supported with the current Hybrid mode. - NVAPI_MIXED_TARGET_TYPES = -126, // The target types are not all the same - NVAPI_SYSWOW64_NOT_SUPPORTED = -127, // The function is not supported from 32-bit on a 64-bit system. - NVAPI_IMPLICIT_SET_GPU_TOPOLOGY_CHANGE_NOT_ALLOWED = -128, // There is no implicit GPU topology active. Use NVAPI_SetHybridMode to change topology. - NVAPI_REQUEST_USER_TO_CLOSE_NON_MIGRATABLE_APPS = -129, // Prompt the user to close all non-migratable applications. - NVAPI_OUT_OF_MEMORY = -130, // Could not allocate sufficient memory to complete the call. - NVAPI_WAS_STILL_DRAWING = -131, // The previous operation that is transferring information to or from this surface is incomplete. - NVAPI_FILE_NOT_FOUND = -132, // The file was not found. - NVAPI_TOO_MANY_UNIQUE_STATE_OBJECTS = -133, // There are too many unique instances of a particular type of state object. - NVAPI_INVALID_CALL = -134, // The method call is invalid. For example, a method's parameter may not be a valid pointer. - NVAPI_D3D10_1_LIBRARY_NOT_FOUND = -135, // d3d10_1.dll cannot be loaded. - NVAPI_FUNCTION_NOT_FOUND = -136, // Couldn't find the function in the loaded DLL. - NVAPI_INVALID_USER_PRIVILEGE = -137, // Current User is not Admin. - NVAPI_EXPECTED_NON_PRIMARY_DISPLAY_HANDLE = -138, // The handle corresponds to GDIPrimary. - NVAPI_EXPECTED_COMPUTE_GPU_HANDLE = -139, // Setting Physx GPU requires that the GPU is compute-capable. - NVAPI_STEREO_NOT_INITIALIZED = -140, // The Stereo part of NVAPI failed to initialize completely. Check if the stereo driver is installed. - NVAPI_STEREO_REGISTRY_ACCESS_FAILED = -141, // Access to stereo-related registry keys or values has failed. - NVAPI_STEREO_REGISTRY_PROFILE_TYPE_NOT_SUPPORTED = -142, // The given registry profile type is not supported. - NVAPI_STEREO_REGISTRY_VALUE_NOT_SUPPORTED = -143, // The given registry value is not supported. - NVAPI_STEREO_NOT_ENABLED = -144, // Stereo is not enabled and the function needed it to execute completely. - NVAPI_STEREO_NOT_TURNED_ON = -145, // Stereo is not turned on and the function needed it to execute completely. - NVAPI_STEREO_INVALID_DEVICE_INTERFACE = -146, // Invalid device interface. - NVAPI_STEREO_PARAMETER_OUT_OF_RANGE = -147, // Separation percentage or JPEG image capture quality is out of [0-100] range. - NVAPI_STEREO_FRUSTUM_ADJUST_MODE_NOT_SUPPORTED = -148, // The given frustum adjust mode is not supported. - NVAPI_TOPO_NOT_POSSIBLE = -149, // The mosaic topology is not possible given the current state of the hardware. - NVAPI_MODE_CHANGE_FAILED = -150, // An attempt to do a display resolution mode change has failed. - NVAPI_D3D11_LIBRARY_NOT_FOUND = -151, // d3d11.dll/d3d11_beta.dll cannot be loaded. - NVAPI_INVALID_ADDRESS = -152, // Address is outside of valid range. - NVAPI_STRING_TOO_SMALL = -153, // The pre-allocated string is too small to hold the result. - NVAPI_MATCHING_DEVICE_NOT_FOUND = -154, // The input does not match any of the available devices. - NVAPI_DRIVER_RUNNING = -155, // Driver is running. - NVAPI_DRIVER_NOTRUNNING = -156, // Driver is not running. - NVAPI_ERROR_DRIVER_RELOAD_REQUIRED = -157, // A driver reload is required to apply these settings. - NVAPI_SET_NOT_ALLOWED = -158, // Intended setting is not allowed. - NVAPI_ADVANCED_DISPLAY_TOPOLOGY_REQUIRED = -159, // Information can't be returned due to "advanced display topology". - NVAPI_SETTING_NOT_FOUND = -160, // Setting is not found. - NVAPI_SETTING_SIZE_TOO_LARGE = -161, // Setting size is too large. - NVAPI_TOO_MANY_SETTINGS_IN_PROFILE = -162, // There are too many settings for a profile. - NVAPI_PROFILE_NOT_FOUND = -163, // Profile is not found. - NVAPI_PROFILE_NAME_IN_USE = -164, // Profile name is duplicated. - NVAPI_PROFILE_NAME_EMPTY = -165, // Profile name is empty. - NVAPI_EXECUTABLE_NOT_FOUND = -166, // Application not found in the Profile. - NVAPI_EXECUTABLE_ALREADY_IN_USE = -167, // Application already exists in the other profile. - NVAPI_DATATYPE_MISMATCH = -168, // Data Type mismatch - NVAPI_PROFILE_REMOVED = -169, // The profile passed as parameter has been removed and is no longer valid. - NVAPI_UNREGISTERED_RESOURCE = -170, // An unregistered resource was passed as a parameter. - NVAPI_ID_OUT_OF_RANGE = -171, // The DisplayId corresponds to a display which is not within the normal outputId range. - NVAPI_DISPLAYCONFIG_VALIDATION_FAILED = -172, // Display topology is not valid so the driver cannot do a mode set on this configuration. - NVAPI_DPMST_CHANGED = -173, // Display Port Multi-Stream topology has been changed. - NVAPI_INSUFFICIENT_BUFFER = -174, // Input buffer is insufficient to hold the contents. - NVAPI_ACCESS_DENIED = -175, // No access to the caller. - NVAPI_MOSAIC_NOT_ACTIVE = -176, // The requested action cannot be performed without Mosaic being enabled. - NVAPI_SHARE_RESOURCE_RELOCATED = -177, // The surface is relocated away from video memory. - NVAPI_REQUEST_USER_TO_DISABLE_DWM = -178, // The user should disable DWM before calling NvAPI. - NVAPI_D3D_DEVICE_LOST = -179, // D3D device status is D3DERR_DEVICELOST or D3DERR_DEVICENOTRESET - the user has to reset the device. - NVAPI_INVALID_CONFIGURATION = -180, // The requested action cannot be performed in the current state. - NVAPI_STEREO_HANDSHAKE_NOT_DONE = -181, // Call failed as stereo handshake not completed. - NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS = -182, // The path provided was too short to determine the correct NVDRS_APPLICATION - NVAPI_DEFAULT_STEREO_PROFILE_IS_NOT_DEFINED = -183, // Default stereo profile is not currently defined - NVAPI_DEFAULT_STEREO_PROFILE_DOES_NOT_EXIST = -184, // Default stereo profile does not exist - NVAPI_CLUSTER_ALREADY_EXISTS = -185, // A cluster is already defined with the given configuration. - NVAPI_DPMST_DISPLAY_ID_EXPECTED = -186, // The input display id is not that of a multi stream enabled connector or a display device in a multi stream topology - NVAPI_INVALID_DISPLAY_ID = -187, // The input display id is not valid or the monitor associated to it does not support the current operation - NVAPI_STREAM_IS_OUT_OF_SYNC = -188, // While playing secure audio stream, stream goes out of sync - NVAPI_INCOMPATIBLE_AUDIO_DRIVER = -189, // Older audio driver version than required - NVAPI_VALUE_ALREADY_SET = -190, // Value already set, setting again not allowed. - NVAPI_TIMEOUT = -191, // Requested operation timed out - NVAPI_GPU_WORKSTATION_FEATURE_INCOMPLETE = -192, // The requested workstation feature set has incomplete driver internal allocation resources - NVAPI_STEREO_INIT_ACTIVATION_NOT_DONE = -193, // Call failed because InitActivation was not called. - NVAPI_SYNC_NOT_ACTIVE = -194, // The requested action cannot be performed without Sync being enabled. - NVAPI_SYNC_MASTER_NOT_FOUND = -195, // The requested action cannot be performed without Sync Master being enabled. - NVAPI_INVALID_SYNC_TOPOLOGY = -196, // Invalid displays passed in the NV_GSYNC_DISPLAY pointer. - NVAPI_ECID_SIGN_ALGO_UNSUPPORTED = -197, // The specified signing algorithm is not supported. Either an incorrect value was entered or the current installed driver/hardware does not support the input value. - NVAPI_ECID_KEY_VERIFICATION_FAILED = -198, // The encrypted public key verification has failed. - NVAPI_FIRMWARE_OUT_OF_DATE = -199, // The device's firmware is out of date. - NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED = -200, // The device's firmware is not supported. -} NvAPI_Status; - -/* - * Declarations from from nvapi.h - */ - -#define NVAPI_MAX_THERMAL_SENSORS_PER_GPU 3 - -// Used in NV_GPU_THERMAL_SETTINGS -typedef enum -{ - NVAPI_THERMAL_TARGET_NONE = 0, - NVAPI_THERMAL_TARGET_GPU = 1, // GPU core temperature requires NvPhysicalGpuHandle - NVAPI_THERMAL_TARGET_MEMORY = 2, // GPU memory temperature requires NvPhysicalGpuHandle - NVAPI_THERMAL_TARGET_POWER_SUPPLY = 4, // GPU power supply temperature requires NvPhysicalGpuHandle - NVAPI_THERMAL_TARGET_BOARD = 8, // GPU board ambient temperature requires NvPhysicalGpuHandle - NVAPI_THERMAL_TARGET_VCD_BOARD = 9, // Visual Computing Device Board temperature requires NvVisualComputingDeviceHandle - NVAPI_THERMAL_TARGET_VCD_INLET = 10, // Visual Computing Device Inlet temperature requires NvVisualComputingDeviceHandle - NVAPI_THERMAL_TARGET_VCD_OUTLET = 11, // Visual Computing Device Outlet temperature requires NvVisualComputingDeviceHandle - - NVAPI_THERMAL_TARGET_ALL = 15, - NVAPI_THERMAL_TARGET_UNKNOWN = -1, -} NV_THERMAL_TARGET; - -// Used in NV_GPU_THERMAL_SETTINGS -typedef enum -{ - NVAPI_THERMAL_CONTROLLER_NONE = 0, - NVAPI_THERMAL_CONTROLLER_GPU_INTERNAL, - NVAPI_THERMAL_CONTROLLER_ADM1032, - NVAPI_THERMAL_CONTROLLER_MAX6649, - NVAPI_THERMAL_CONTROLLER_MAX1617, - NVAPI_THERMAL_CONTROLLER_LM99, - NVAPI_THERMAL_CONTROLLER_LM89, - NVAPI_THERMAL_CONTROLLER_LM64, - NVAPI_THERMAL_CONTROLLER_ADT7473, - NVAPI_THERMAL_CONTROLLER_SBMAX6649, - NVAPI_THERMAL_CONTROLLER_VBIOSEVT, - NVAPI_THERMAL_CONTROLLER_OS, - NVAPI_THERMAL_CONTROLLER_UNKNOWN = -1, -} NV_THERMAL_CONTROLLER; - -// Used in NvAPI_GPU_GetThermalSettings() -typedef struct -{ - NvU32 version; // structure version - NvU32 count; // number of associated thermal sensors - struct - { - NV_THERMAL_CONTROLLER controller; // internal, ADM1032, MAX6649... - NvU32 defaultMinTemp; // The min default temperature value of the thermal sensor in degree Celsius - NvU32 defaultMaxTemp; // The max default temperature value of the thermal sensor in degree Celsius - NvU32 currentTemp; // The current temperature value of the thermal sensor in degree Celsius - NV_THERMAL_TARGET target; // Thermal sensor targeted @ GPU, memory, chipset, powersupply, Visual Computing Device, etc. - } sensor[NVAPI_MAX_THERMAL_SENSORS_PER_GPU]; - -} NV_GPU_THERMAL_SETTINGS_V1; - -typedef struct -{ - NvU32 version; // structure version - NvU32 count; // number of associated thermal sensors - struct - { - NV_THERMAL_CONTROLLER controller; // internal, ADM1032, MAX6649... - NvS32 defaultMinTemp; // Minimum default temperature value of the thermal sensor in degree Celsius - NvS32 defaultMaxTemp; // Maximum default temperature value of the thermal sensor in degree Celsius - NvS32 currentTemp; // Current temperature value of the thermal sensor in degree Celsius - NV_THERMAL_TARGET target; // Thermal sensor targeted - GPU, memory, chipset, powersupply, Visual Computing Device, etc - } sensor[NVAPI_MAX_THERMAL_SENSORS_PER_GPU]; - -} NV_GPU_THERMAL_SETTINGS_V2; - -typedef NV_GPU_THERMAL_SETTINGS_V2 NV_GPU_THERMAL_SETTINGS; - -// Macro for constructing the version field of NV_GPU_THERMAL_SETTINGS_V1 -#define NV_GPU_THERMAL_SETTINGS_VER_1 MAKE_NVAPI_VERSION(NV_GPU_THERMAL_SETTINGS_V1,1) - -// Macro for constructing the version field of NV_GPU_THERMAL_SETTINGS_V2 -#define NV_GPU_THERMAL_SETTINGS_VER_2 MAKE_NVAPI_VERSION(NV_GPU_THERMAL_SETTINGS_V2,2) - -// Macro for constructing the version field of NV_GPU_THERMAL_SETTINGS -#define NV_GPU_THERMAL_SETTINGS_VER NV_GPU_THERMAL_SETTINGS_VER_2 - -#define NVAPI_MAX_GPU_UTILIZATIONS 8 - -// Used in NvAPI_GPU_GetDynamicPstatesInfoEx(). -typedef struct -{ - NvU32 version; // Structure version - NvU32 flags; // bit 0 indicates if the dynamic Pstate is enabled or not - struct - { - NvU32 bIsPresent:1; // Set if this utilization domain is present on this GPU - NvU32 percentage; // Percentage of time where the domain is considered busy in the last 1 second interval - } utilization[NVAPI_MAX_GPU_UTILIZATIONS]; -} NV_GPU_DYNAMIC_PSTATES_INFO_EX; - -// Macro for constructing the version field of NV_GPU_DYNAMIC_PSTATES_INFO_EX -#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 GPU_COOLER_SETTINGS_VER 0x20000 -#define GPU_COOLER_LEVELS_VER 0x10000 - -// Used in NV_GPU_COOLER_SETTINGS -typedef struct -{ - NvS32 Type; - NvS32 Controller; - NvS32 DefaultMin; - NvS32 DefaultMax; - NvS32 CurrentMin; - NvS32 CurrentMax; - NvS32 CurrentLevel; - NvS32 DefaultPolicy; - NvS32 CurrentPolicy; - NvS32 Target; - NvS32 ControlType; - NvS32 Active; - -} NvCooler; - -// Used in NvAPI_GPU_GetCoolerSettings(). -typedef struct -{ - NvU32 Version; - NvU32 Count; - NvCooler Cooler[NVAPI_MAX_COOLER_PER_GPU]; - -} 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 - -typedef enum _NV_GPU_PUBLIC_CLOCK_ID -{ - NVAPI_GPU_PUBLIC_CLOCK_GRAPHICS = 0, - NVAPI_GPU_PUBLIC_CLOCK_MEMORY = 4, - NVAPI_GPU_PUBLIC_CLOCK_PROCESSOR = 7, - NVAPI_GPU_PUBLIC_CLOCK_VIDEO = 8, - NVAPI_GPU_PUBLIC_CLOCK_UNDEFINED = NVAPI_MAX_GPU_PUBLIC_CLOCKS, -} NV_GPU_PUBLIC_CLOCK_ID; - -//! Used in NvAPI_GPU_GetAllClockFrequencies() -typedef struct -{ - NvU32 version; //!< Structure version - NvU32 reserved; //!< These bits are reserved for future use. - struct - { - NvU32 bIsPresent:1; //!< Set if this domain is present on this GPU - NvU32 reserved:31; //!< These bits are reserved for future use. - NvU32 frequency; //!< Clock frequency (kHz) - }domain[NVAPI_MAX_GPU_PUBLIC_CLOCKS]; -} NV_GPU_CLOCK_FREQUENCIES_V1; - -//! Used in NvAPI_GPU_GetAllClockFrequencies() -typedef enum -{ - NV_GPU_CLOCK_FREQUENCIES_CURRENT_FREQ = 0, - NV_GPU_CLOCK_FREQUENCIES_BASE_CLOCK = 1, - NV_GPU_CLOCK_FREQUENCIES_BOOST_CLOCK = 2, - NV_GPU_CLOCK_FREQUENCIES_CLOCK_TYPE_NUM = 3 -} NV_GPU_CLOCK_FREQUENCIES_CLOCK_TYPE; - -//! Used in NvAPI_GPU_GetAllClockFrequencies() -typedef struct -{ - NvU32 version; //!< Structure version - NvU32 ClockType:2; //!< One of NV_GPU_CLOCK_FREQUENCIES_CLOCK_TYPE. Used to specify the type of clock to be returned. - NvU32 reserved:22; //!< These bits are reserved for future use. Must be set to 0. - NvU32 reserved1:8; //!< These bits are reserved. - struct - { - NvU32 bIsPresent:1; //!< Set if this domain is present on this GPU - NvU32 reserved:31; //!< These bits are reserved for future use. - NvU32 frequency; //!< Clock frequency (kHz) - }domain[NVAPI_MAX_GPU_PUBLIC_CLOCKS]; -} NV_GPU_CLOCK_FREQUENCIES_V2; - -//! \ingroup gpuclock -//! Used in NvAPI_GPU_GetAllClockFrequencies() -typedef NV_GPU_CLOCK_FREQUENCIES_V2 NV_GPU_CLOCK_FREQUENCIES; - -//! \addtogroup gpuclock -//! @{ -#define NV_GPU_CLOCK_FREQUENCIES_VER_1 MAKE_NVAPI_VERSION(NV_GPU_CLOCK_FREQUENCIES_V1,1) -#define NV_GPU_CLOCK_FREQUENCIES_VER_2 MAKE_NVAPI_VERSION(NV_GPU_CLOCK_FREQUENCIES_V2,2) -#define NV_GPU_CLOCK_FREQUENCIES_VER_3 MAKE_NVAPI_VERSION(NV_GPU_CLOCK_FREQUENCIES_V2,3) -#define NV_GPU_CLOCK_FREQUENCIES_VER NV_GPU_CLOCK_FREQUENCIES_VER_3 -//! @} - -//! Used in NvAPI_GPU_GetPerfDecreaseInfo. -//! Bit masks for knowing the exact reason for performance decrease -typedef enum _NVAPI_GPU_PERF_DECREASE -{ - NV_GPU_PERF_DECREASE_NONE = 0, //!< No Slowdown detected - NV_GPU_PERF_DECREASE_REASON_THERMAL_PROTECTION = 0x00000001, //!< Thermal slowdown/shutdown/POR thermal protection - NV_GPU_PERF_DECREASE_REASON_POWER_CONTROL = 0x00000002, //!< Power capping / pstate cap - NV_GPU_PERF_DECREASE_REASON_AC_BATT = 0x00000004, //!< AC->BATT event - NV_GPU_PERF_DECREASE_REASON_API_TRIGGERED = 0x00000008, //!< API triggered slowdown - NV_GPU_PERF_DECREASE_REASON_INSUFFICIENT_POWER = 0x00000010, //!< Power connector missing - NV_GPU_PERF_DECREASE_REASON_UNKNOWN = 0x80000000, //!< Unknown reason -} NVAPI_GPU_PERF_DECREASE; - - -NVAPI_INTERFACE NvAPI_QueryInterface(uint offset); -NVAPI_INTERFACE NvAPI_Initialize(); -NVAPI_INTERFACE NvAPI_Unload(); -NVAPI_INTERFACE NvAPI_GetErrorMessage(NvAPI_Status nr,NvAPI_ShortString szDesc); -NVAPI_INTERFACE NvAPI_EnumPhysicalGPUs(NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); -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_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_GetAllClockFrequencies(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_CLOCK_FREQUENCIES *pClkFreqs); -NVAPI_INTERFACE NvAPI_GPU_GetCurrentPCIEDownstreamWidth(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pWidth); -NVAPI_INTERFACE NvAPI_GPU_GetPerfDecreaseInfo(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pPerfDecrInfo); - -#ifdef __nvapi_success - #undef __success - #undef __nvapi_success -#endif - -/* - * End of declarations from nvapi.h and subheaders - **/ - -// Just annotations (they do nothing special) - -#ifndef __success -#define __success(x) -#endif -#ifndef __in -#define __in -#endif -#ifndef __out -#define __out -#endif -#ifndef __in_ecount -#define __in_ecount(x) -#endif -#ifndef __out_ecount -#define __out_ecount(x) -#endif -#ifndef __in_opt -#define __in_opt -#endif -#ifndef __out_opt -#define __out_opt -#endif -#ifndef __inout -#define __inout -#endif -#ifndef __inout_opt -#define __inout_opt -#endif -#ifndef __inout_ecount -#define __inout_ecount(x) -#endif -#ifndef __inout_ecount_full -#define __inout_ecount_full(x) -#endif -#ifndef __inout_ecount_part_opt -#define __inout_ecount_part_opt(x,y) -#endif -#ifndef __inout_ecount_full_opt -#define __inout_ecount_full_opt(x,y) -#endif -#ifndef __out_ecount_full_opt -#define __out_ecount_full_opt(x) -#endif - -typedef NvPhysicalGpuHandle HM_ADAPTER_NV; - -#include - -typedef int *(*NVAPI_QUERYINTERFACE) (uint); -typedef int (*NVAPI_INITIALIZE) (void); -typedef int (*NVAPI_UNLOAD) (void); -typedef int (*NVAPI_GETERRORMESSAGE) (NvAPI_Status, NvAPI_ShortString); -typedef int (*NVAPI_ENUMPHYSICALGPUS) (NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *); -typedef int (*NVAPI_GPU_GETTHERMALSETTINGS) (NvPhysicalGpuHandle, NvU32, NV_GPU_THERMAL_SETTINGS *); -typedef int (*NVAPI_GPU_GETTACHREADING) (NvPhysicalGpuHandle, NvU32 *); -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_GETALLCLOCKFREQUENCIES) (NvPhysicalGpuHandle, NV_GPU_CLOCK_FREQUENCIES *); -typedef int (*NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH) (NvPhysicalGpuHandle, NvU32 *); -typedef int (*NVAPI_GPU_GETPERFDECREASEINFO) (NvPhysicalGpuHandle, NvU32 *); - -typedef struct -{ - NV_LIB lib; - - NVAPI_QUERYINTERFACE nvapi_QueryInterface; - NVAPI_INITIALIZE NvAPI_Initialize; - NVAPI_UNLOAD NvAPI_Unload; - NVAPI_GETERRORMESSAGE NvAPI_GetErrorMessage; - NVAPI_ENUMPHYSICALGPUS NvAPI_EnumPhysicalGPUs; - NVAPI_GPU_GETTHERMALSETTINGS NvAPI_GPU_GetThermalSettings; - NVAPI_GPU_GETTACHREADING NvAPI_GPU_GetTachReading; - NVAPI_GPU_GETCOOLERSETTINGS NvAPI_GPU_GetCoolerSettings; - NVAPI_GPU_SETCOOLERLEVELS NvAPI_GPU_SetCoolerLevels; - NVAPI_GPU_GETDYNAMICPSTATESINFOEX NvAPI_GPU_GetDynamicPstatesInfoEx; - NVAPI_GPU_GETALLCLOCKFREQUENCIES NvAPI_GPU_GetAllClockFrequencies; - NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH NvAPI_GPU_GetCurrentPCIEDownstreamWidth; - NVAPI_GPU_GETPERFDECREASEINFO NvAPI_GPU_GetPerfDecreaseInfo; - -} hm_nvapi_lib_t; - -#define NVAPI_PTR hm_nvapi_lib_t - -int nvapi_init (NVAPI_PTR *nvapi); -void nvapi_close (NVAPI_PTR *nvapi); - -int hm_NvAPI_QueryInterface (NVAPI_PTR *nvapi, uint offset); -int hm_NvAPI_Initialize (NVAPI_PTR *nvapi); -int hm_NvAPI_Unload (NVAPI_PTR *nvapi); -int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status nr, NvAPI_ShortString szDesc); -int hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); -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_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_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_GetPerfDecreaseInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pPerfDecrInfo); - -#endif // HAVE_HWMON - -#endif // EXT_NVAPI_H diff --git a/include/shared.h b/include/shared.h index 0e7d55c..4b72571 100644 --- a/include/shared.h +++ b/include/shared.h @@ -114,13 +114,8 @@ static inline int CPU_ISSET (int num, cpu_set_t *cs) { return (cs->count & (1 < * temperature management */ -#if _WIN -#include "ext_ADL.h" -#include "ext_nvapi.h" -#else #include "ext_ADL.h" #include "ext_nvml.h" -#endif /** * shared stuff @@ -1461,14 +1456,7 @@ 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_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); #endif // HAVE_HWMON diff --git a/src/Makefile b/src/Makefile index 3b8d055..94dc033 100644 --- a/src/Makefile +++ b/src/Makefile @@ -158,8 +158,8 @@ endif 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 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 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 +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_nvml.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_nvml.WIN.64.o ## ## Targets: Global diff --git a/src/ext_ADL.c b/src/ext_ADL.c index e6e167f..b99721f 100644 --- a/src/ext_ADL.c +++ b/src/ext_ADL.c @@ -12,7 +12,9 @@ int adl_init (ADL_PTR *adl) memset (adl, 0, sizeof (ADL_PTR)); #ifdef _WIN - if (!(adl->lib = hc_dlopen ("atiadlxx.dll"))) + adl->lib = hc_dlopen ("atiadlxx.dll"); + + if (!adl->lib) { adl->lib = hc_dlopen ("atiadlxy.dll"); } diff --git a/src/ext_nvapi.c b/src/ext_nvapi.c deleted file mode 100644 index e338650..0000000 --- a/src/ext_nvapi.c +++ /dev/null @@ -1,276 +0,0 @@ -/** - * Authors.....: Jens Steube - * Gabriele Gristina - * - * License.....: MIT - */ - -#include - -int nvapi_init (NVAPI_PTR *nvapi) -{ - if (!nvapi) return (-1); - - memset (nvapi, 0, sizeof (NVAPI_PTR)); - - #if __x86_64__ - nvapi->lib = hc_dlopen ("nvapi64.dll"); - #elif __x86__ - nvapi->lib = hc_dlopen ("nvapi.dll"); - #endif - - if (!nvapi->lib) - { - //if (data.quiet == 0) - // log_info ("WARNING: load NVAPI library failed, proceed without NVAPI HWMon enabled."); - - return (-1); - } - - HC_LOAD_FUNC(nvapi, nvapi_QueryInterface, NVAPI_QUERYINTERFACE, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_Initialize, NVAPI_INITIALIZE, nvapi_QueryInterface, 0x0150E828, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_Unload, NVAPI_UNLOAD, nvapi_QueryInterface, 0xD22BDD7E, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GetErrorMessage, NVAPI_GETERRORMESSAGE, nvapi_QueryInterface, 0x6C2D048C, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_EnumPhysicalGPUs, NVAPI_ENUMPHYSICALGPUS, nvapi_QueryInterface, 0xE5AC921F, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetDynamicPstatesInfoEx, NVAPI_GPU_GETDYNAMICPSTATESINFOEX, nvapi_QueryInterface, 0x60DED2ED, 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_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_GetCurrentPCIEDownstreamWidth, NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH, nvapi_QueryInterface, 0xD048C3B1, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfDecreaseInfo, NVAPI_GPU_GETPERFDECREASEINFO, nvapi_QueryInterface, 0x7F7F4600, NVAPI, 0) - - return 0; -} - -void nvapi_close (NVAPI_PTR *nvapi) -{ - if (nvapi) - { - if (nvapi->lib) - hc_dlclose (nvapi->lib); - - myfree (nvapi); - } -} - -int hm_NvAPI_Initialize (NVAPI_PTR *nvapi) -{ - if (!nvapi) return (-1); - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_Initialize (); - - if (NvAPI_rc == NVAPI_LIBRARY_NOT_FOUND) NvAPI_rc = NVAPI_OK; // not a bug - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - log_info ("WARN: %s %d %s\n", "NvAPI_Initialize()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -int hm_NvAPI_Unload (NVAPI_PTR *nvapi) -{ - if (!nvapi) return (-1); - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_Unload (); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - log_info ("WARN: %s %d %s\n", "NvAPI_Unload()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status NvAPI_rc, NvAPI_ShortString string) -{ - if (!nvapi) return (-1); - - return nvapi->NvAPI_GetErrorMessage (NvAPI_rc, string); -} - -int hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) -{ - if (!nvapi) return (-1); - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_EnumPhysicalGPUs (nvGPUHandle, pGpuCount); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - log_info ("WARN: %s %d %s\n", "NvAPI_EnumPhysicalGPUs()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -int hm_NvAPI_GPU_GetThermalSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 sensorIndex, NV_GPU_THERMAL_SETTINGS *pThermalSettings) -{ - if (!nvapi) return (-1); - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetThermalSettings (hPhysicalGpu, sensorIndex, pThermalSettings); - - 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_GetThermalSettings()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -int hm_NvAPI_GPU_GetTachReading (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGPU, NvU32 *pValue) -{ - if (!nvapi) return (-1); - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetTachReading (hPhysicalGPU, pValue); - - 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_GetTachReading()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -int hm_NvAPI_GPU_GetCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_SETTINGS *pCoolerSettings) -{ - if (!nvapi) return (-1); - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetCoolerSettings (hPhysicalGpu, coolerIndex, pCoolerSettings); - - 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_GetCoolerSettings()", NvAPI_rc, string); - } - - 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) -{ - if (!nvapi) return (-1); - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetDynamicPstatesInfoEx (hPhysicalGpu, pDynamicPstatesInfoEx); - - 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_GetDynamicPstatesInfoEx()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -int hm_NvAPI_GPU_GetAllClockFrequencies (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_CLOCK_FREQUENCIES *pClkFreqs) -{ - if (!nvapi) return (-1); - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetAllClockFrequencies (hPhysicalGpu, pClkFreqs); - - 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_GetAllClockFrequencies()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -int hm_NvAPI_GPU_GetCurrentPCIEDownstreamWidth (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pWidth) -{ - if (!nvapi) return (-1); - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetCurrentPCIEDownstreamWidth (hPhysicalGpu, pWidth); - - 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_GetCurrentPCIEDownstreamWidth()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -int hm_NvAPI_GPU_GetPerfDecreaseInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pPerfDecrInfo) -{ - if (!nvapi) return (-1); - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfDecreaseInfo (hPhysicalGpu, pPerfDecrInfo); - - 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_GetPerfDecreaseInfo()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -#ifdef __MINGW64__ - -void __security_check_cookie (uintptr_t _StackCookie) -{ - (void) _StackCookie; -} - -void __GSHandlerCheck () -{ -} - -#endif diff --git a/src/ext_nvml.c b/src/ext_nvml.c index c223d0a..e06bbb1 100644 --- a/src/ext_nvml.c +++ b/src/ext_nvml.c @@ -13,12 +13,32 @@ int nvml_init (NVML_PTR *nvml) memset (nvml, 0, sizeof (NVML_PTR)); + #ifdef _WIN + nvml->lib = hc_dlopen ("nvml.dll"); + + if (!nvml->lib) + { + DWORD BufferSize = 1024; + + char *Buffer = (char *) mymalloc (BufferSize); + + RegGetValue (HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\NVSMI", "NVSMIPATH", RRF_RT_ANY, NULL, (PVOID) Buffer, &BufferSize); + + strcat (Buffer, "\\nvml.dll"); + + nvml->lib = hc_dlopen (Buffer); + + myfree (Buffer); + } + + #elif _POSIX nvml->lib = hc_dlopen ("libnvidia-ml.so", RTLD_NOW); + #endif if (!nvml->lib) { - //if (data.quiet == 0) - // log_info ("WARNING: load NVML library failed, proceed without NVML HWMon enabled."); + if (data.quiet == 0) + log_info ("WARNING: load NVML library failed, proceed without NVML HWMon enabled."); return (-1); } diff --git a/src/hashcat.c b/src/hashcat.c index 7fc6839..00d6f95 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -4010,9 +4010,7 @@ static void *thread_monitor (void *p) } 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; @@ -13990,40 +13988,6 @@ int main (int argc, char **argv) if (gpu_temp_disable == 0) { - #if defined(WIN) - NVAPI_PTR *nvapi = (NVAPI_PTR *) mymalloc (sizeof (NVAPI_PTR)); - - if (nvapi_init (nvapi) == 0) - data.hm_nv = nvapi; - - if (data.hm_nv) - { - if (hm_NvAPI_Initialize (data.hm_nv) == NVAPI_OK) - { - HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX] = { 0 }; - - int tmp_in = hm_get_adapter_index_nv (nvGPUHandle); - - int tmp_out = 0; - - for (int i = 0; i < tmp_in; i++) - { - hm_adapters_nv[tmp_out++].adapter_index.nv = nvGPUHandle[i]; - } - - for (int i = 0; i < tmp_out; i++) - { - NV_GPU_COOLER_SETTINGS pCoolerSettings; - - 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_get_supported = 1; - } - } - } - #endif // WIN - - #if defined(LINUX) NVML_PTR *nvml = (NVML_PTR *) mymalloc (sizeof (NVML_PTR)); if (nvml_init (nvml) == 0) @@ -14052,7 +14016,6 @@ int main (int argc, char **argv) } } } - #endif // LINUX data.hm_amd = NULL; @@ -15637,9 +15600,7 @@ int main (int argc, char **argv) } 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 + } if (rc == 0) @@ -17917,9 +17878,7 @@ int main (int argc, char **argv) } 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 and policy for device #%", device_id + 1); @@ -17997,20 +17956,10 @@ int main (int argc, char **argv) { if (data.hm_nv) { - #if defined(LINUX) - hm_NVML_nvmlShutdown (data.hm_nv); nvml_close (data.hm_nv); - #elif defined(WIN) - - hm_NvAPI_Unload (data.hm_nv); - - nvapi_close (data.hm_nv); - - #endif - data.hm_nv = NULL; } diff --git a/src/shared.c b/src/shared.c index e48fdc5..cadae65 100644 --- a/src/shared.c +++ b/src/shared.c @@ -2672,25 +2672,6 @@ void fsync (int fd) #ifdef HAVE_HWMON -#if defined(_WIN) -int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]) -{ - NvU32 pGpuCount; - - if (hm_NvAPI_EnumPhysicalGPUs (data.hm_nv, nvGPUHandle, &pGpuCount) != NVAPI_OK) return (0); - - if (pGpuCount == 0) - { - log_info ("WARN: No NvAPI adapters found"); - - return (0); - } - - return (pGpuCount); -} -#endif // _WIN - -#if defined(LINUX) int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]) { int pGpuCount = 0; @@ -2715,7 +2696,6 @@ int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]) return (pGpuCount); } -#endif int get_adapters_num_amd (void *adl, int *iNumberAdapters) { @@ -3084,17 +3064,11 @@ int hm_get_threshold_slowdown_with_device_id (const uint device_id) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { - #if defined(LINUX) int target = 0; hm_NVML_nvmlDeviceGetTemperatureThreshold (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target); return target; - #endif - - #if defined(WIN) - - #endif // WIN } return -1; @@ -3131,26 +3105,11 @@ int hm_get_temperature_with_device_id (const uint device_id) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { - #if defined(LINUX) int temperature = 0; hm_NVML_nvmlDeviceGetTemperature (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_GPU, (uint *) &temperature); return temperature; - #endif - - #if defined(WIN) - NV_GPU_THERMAL_SETTINGS pThermalSettings; - - pThermalSettings.version = NV_GPU_THERMAL_SETTINGS_VER; - pThermalSettings.count = NVAPI_MAX_THERMAL_SENSORS_PER_GPU; - pThermalSettings.sensor[0].controller = NVAPI_THERMAL_CONTROLLER_UNKNOWN; - pThermalSettings.sensor[0].target = NVAPI_THERMAL_TARGET_GPU; - - 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; - #endif // WIN } return -1; @@ -3240,23 +3199,11 @@ int hm_get_fanspeed_with_device_id (const uint device_id) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { - #if defined(LINUX) int speed = 0; hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nv, 1, data.hm_device[device_id].adapter_index.nv, (uint *) &speed); return speed; - #endif - - #if defined(WIN) - NV_GPU_COOLER_SETTINGS pCoolerSettings; - - pCoolerSettings.Version = GPU_COOLER_SETTINGS_VER | sizeof (NV_GPU_COOLER_SETTINGS); - - 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; - #endif } } @@ -3283,21 +3230,11 @@ int hm_get_buslanes_with_device_id (const uint device_id) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { - #if defined(LINUX) unsigned int currLinkWidth; hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &currLinkWidth); return currLinkWidth; - #endif - - #if defined(WIN) - int Width; - - if (hm_NvAPI_GPU_GetCurrentPCIEDownstreamWidth (data.hm_nv, data.hm_device[device_id].adapter_index.nv, (NvU32 *) &Width) != NVAPI_OK) return -1; - - return Width; - #endif } return -1; @@ -3323,23 +3260,11 @@ int hm_get_utilization_with_device_id (const uint device_id) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { - #if defined(LINUX) nvmlUtilization_t utilization; hm_NVML_nvmlDeviceGetUtilizationRates (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &utilization); return utilization.gpu; - #endif - - #if defined(WIN) - NV_GPU_DYNAMIC_PSTATES_INFO_EX pDynamicPstatesInfoEx; - - pDynamicPstatesInfoEx.version = NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER; - - if (hm_NvAPI_GPU_GetDynamicPstatesInfoEx (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &pDynamicPstatesInfoEx) != NVAPI_OK) return -1; - - return pDynamicPstatesInfoEx.utilization[0].percentage; - #endif } return -1; @@ -3365,24 +3290,11 @@ int hm_get_memoryspeed_with_device_id (const uint device_id) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { - #if defined(LINUX) unsigned int clock; hm_NVML_nvmlDeviceGetClockInfo (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_CLOCK_MEM, &clock); return clock; - #endif - - #if defined(WIN) - NV_GPU_CLOCK_FREQUENCIES pClkFreqs = { 0 }; - - pClkFreqs.version = NV_GPU_CLOCK_FREQUENCIES_VER; - pClkFreqs.ClockType = NV_GPU_CLOCK_FREQUENCIES_CURRENT_FREQ; - - if (hm_NvAPI_GPU_GetAllClockFrequencies (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &pClkFreqs) != NVAPI_OK) return -1; - - return pClkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_MEMORY].frequency / 1000; - #endif } return -1; @@ -3408,24 +3320,11 @@ int hm_get_corespeed_with_device_id (const uint device_id) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { - #if defined(LINUX) unsigned int clock; hm_NVML_nvmlDeviceGetClockInfo (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_CLOCK_SM, &clock); return clock; - #endif - - #if defined(WIN) - NV_GPU_CLOCK_FREQUENCIES pClkFreqs = { 0 }; - - pClkFreqs.version = NV_GPU_CLOCK_FREQUENCIES_VER; - pClkFreqs.ClockType = NV_GPU_CLOCK_FREQUENCIES_CURRENT_FREQ; - - if (hm_NvAPI_GPU_GetAllClockFrequencies (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &pClkFreqs) != NVAPI_OK) return -1; - - return pClkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_GRAPHICS].frequency / 1000; - #endif } return -1; @@ -3442,17 +3341,7 @@ int hm_get_throttle_with_device_id (const uint device_id) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { - #if defined(LINUX) - - #endif - - #if defined(WIN) - NvU32 throttle = 0; - - if (hm_NvAPI_GPU_GetPerfDecreaseInfo (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &throttle) != NVAPI_OK) return -1; - return throttle; - #endif } return -1; @@ -3498,31 +3387,6 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed 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 - -#if defined(LINUX) int hm_set_fanspeed_with_device_id_nvml (const uint device_id, const int fanspeed, const int fanpolicy) { if (data.hm_device[device_id].fan_set_supported == 1) @@ -3537,7 +3401,6 @@ int hm_set_fanspeed_with_device_id_nvml (const uint device_id, const int fanspee return -1; } -#endif #endif // HAVE_HWMON -- 2.25.1