mirror of
https://github.com/hashcat/hashcat
synced 2024-12-27 05:13:45 +01:00
Added NVML support for querying current engine clock and current memory clock
This commit is contained in:
parent
e97fa06a7a
commit
36def60bfa
@ -52,6 +52,12 @@ typedef enum nvmlReturn_enum {
|
||||
NVML_ERROR_UNKNOWN = 999 // An internal driver error occurred
|
||||
} nvmlReturn_t;
|
||||
|
||||
typedef enum nvmlClockType_enum {
|
||||
NVML_CLOCK_GRAPHICS = 0,
|
||||
NVML_CLOCK_SM = 1,
|
||||
NVML_CLOCK_MEM = 2
|
||||
} nvmlClockType_t;
|
||||
|
||||
/*
|
||||
* End of declarations from nvml.h
|
||||
**/
|
||||
@ -69,6 +75,7 @@ typedef nvmlReturn_t (*NVML_DEVICE_GET_TEMPERATURE) (nvmlDevice_t, nvmlTemperatu
|
||||
typedef nvmlReturn_t (*NVML_DEVICE_GET_FAN_SPEED) (nvmlDevice_t, unsigned int *);
|
||||
typedef nvmlReturn_t (*NVML_DEVICE_GET_POWER_USAGE) (nvmlDevice_t, unsigned int *);
|
||||
typedef nvmlReturn_t (*NVML_DEVICE_GET_UTILIZATION_RATES) (nvmlDevice_t, nvmlUtilization_t *);
|
||||
typedef nvmlReturn_t (*NVML_DEVICE_GET_CLOCKINFO) (nvmlDevice_t, nvmlClockType_t, unsigned int *);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -83,6 +90,7 @@ typedef struct
|
||||
NVML_DEVICE_GET_FAN_SPEED nvmlDeviceGetFanSpeed;
|
||||
NVML_DEVICE_GET_POWER_USAGE nvmlDeviceGetPowerUsage;
|
||||
NVML_DEVICE_GET_UTILIZATION_RATES nvmlDeviceGetUtilizationRates;
|
||||
NVML_DEVICE_GET_CLOCKINFO nvmlDeviceGetClockInfo;
|
||||
|
||||
} hm_nvml_lib_t;
|
||||
|
||||
@ -100,6 +108,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetTemperature (NVML_PTR *nvml, nvmlDevice_t devi
|
||||
nvmlReturn_t hm_NVML_nvmlDeviceGetFanSpeed (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *speed);
|
||||
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerUsage (NVML_PTR *nvml, nvmlDevice_t device, unsigned int *power);
|
||||
nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, nvmlDevice_t device, nvmlUtilization_t *utilization);
|
||||
nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock);
|
||||
|
||||
#endif // HAVE_HWMON && HAVE_NVML
|
||||
|
||||
|
@ -32,6 +32,7 @@ int nvml_init (NVML_PTR *nvml)
|
||||
HC_LOAD_FUNC(nvml, nvmlDeviceGetFanSpeed, NVML_DEVICE_GET_FAN_SPEED, NVML, 0)
|
||||
HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerUsage, NVML_DEVICE_GET_POWER_USAGE, NVML, 0)
|
||||
HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0)
|
||||
HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0)
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -198,3 +199,22 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, nvmlDevice_t
|
||||
|
||||
return nvml_rc;
|
||||
}
|
||||
|
||||
nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock)
|
||||
{
|
||||
if (!nvml) return -1;
|
||||
|
||||
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetClockInfo (device, type, clock);
|
||||
|
||||
if (nvml_rc != NVML_SUCCESS)
|
||||
{
|
||||
*clock = -1;
|
||||
|
||||
//const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
||||
|
||||
//log_info ("WARN: %s %d %s\n", "nvmlDeviceGetUtilizationRates()", nvml_rc, string);
|
||||
}
|
||||
|
||||
return nvml_rc;
|
||||
}
|
||||
|
||||
|
34
src/shared.c
34
src/shared.c
@ -3251,6 +3251,23 @@ int hm_get_memoryspeed_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 defined(LINUX) && defined(HAVE_NVML)
|
||||
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) && defined(HAVE_NVAPI)
|
||||
|
||||
#endif
|
||||
}
|
||||
#endif // HAVE_NVML || HAVE_NVAPI
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -3274,6 +3291,23 @@ int hm_get_corespeed_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 defined(LINUX) && defined(HAVE_NVML)
|
||||
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) && defined(HAVE_NVAPI)
|
||||
|
||||
#endif
|
||||
}
|
||||
#endif // HAVE_NVML || HAVE_NVAPI
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user