From: philsmd Date: Tue, 15 Dec 2015 17:41:11 +0000 (+0100) Subject: fixed hardware monitor for amd/nv (one problem that is still there since last commit... X-Git-Tag: v3.00-beta~584^2~90^2 X-Git-Url: https://www.flypig.org.uk/git/?a=commitdiff_plain;h=3ab7a23cd5bb04c2e0605e46aa0978da1432fe23;p=hashcat.git fixed hardware monitor for amd/nv (one problem that is still there since last commit: dynamic loading of libnvidia-ml) --- diff --git a/include/common.h b/include/common.h index ff17c2a..d62fadf 100644 --- a/include/common.h +++ b/include/common.h @@ -90,7 +90,7 @@ void log_out (FILE *fp, const char *fmt, ...); void log_info (const char *fmt, ...); void log_error (const char *fmt, ...); -#endif - typedef uint32_t uint; // we should rename to u32, sooner or later, for consistency typedef uint64_t u64; + +#endif diff --git a/include/ext_ADL.h b/include/ext_ADL.h index 43a4aa0..ae13434 100644 --- a/include/ext_ADL.h +++ b/include/ext_ADL.h @@ -14,7 +14,7 @@ typedef int bool; #include -//typedef int HM_ADAPTER; +typedef int HM_ADAPTER_AMD; #ifdef _POSIX void *GetProcAddress (void *pLibrary, const char *name); diff --git a/include/ext_dummy.h b/include/ext_dummy.h index fd92323..d2939b6 100644 --- a/include/ext_dummy.h +++ b/include/ext_dummy.h @@ -8,6 +8,4 @@ #include -typedef int HM_ADAPTER; - #endif diff --git a/include/ext_nvapi.h b/include/ext_nvapi.h index 7d7df11..2278394 100644 --- a/include/ext_nvapi.h +++ b/include/ext_nvapi.h @@ -54,7 +54,7 @@ #include -//typedef NvPhysicalGpuHandle HM_ADAPTER; +typedef NvPhysicalGpuHandle HM_ADAPTER_NV; int hc_NvAPI_EnumPhysicalGPUs (NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); int hc_NvAPI_GPU_GetThermalSettings (NvPhysicalGpuHandle hPhysicalGpu, NvU32 sensorIndex, NV_GPU_THERMAL_SETTINGS *pThermalSettings); diff --git a/include/ext_nvml.h b/include/ext_nvml.h index 674754a..8f89f1c 100644 --- a/include/ext_nvml.h +++ b/include/ext_nvml.h @@ -10,7 +10,7 @@ #include -//typedef nvmlDevice_t HM_ADAPTER; +typedef nvmlDevice_t HM_ADAPTER_NV; nvmlReturn_t hc_NVML_nvmlInit (void); nvmlReturn_t hc_NVML_nvmlShutdown (void); diff --git a/include/ext_smi.h b/include/ext_smi.h index 4afaa8a..5ca5abf 100644 --- a/include/ext_smi.h +++ b/include/ext_smi.h @@ -11,8 +11,6 @@ #define SMI_OK 0 #define SMI_NOBIN 1 -typedef int HM_ADAPTER; - int hc_nvidia_smi (int dev, int *temperature, int *gpu); #endif diff --git a/include/shared.h b/include/shared.h index 4942091..2e4124c 100644 --- a/include/shared.h +++ b/include/shared.h @@ -2009,34 +2009,32 @@ void logfile_append (const char *fmt, ...); void fsync (int fd); #endif -/* -int hm_get_adapter_index (HM_ADAPTER nvGPUHandle[DEVICES_MAX]); +int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]); -int get_adapters_num (HM_LIB hm_dll, int *iNumberAdapters); +int get_adapters_num_amd (HM_LIB hm_dll, int *iNumberAdapters); -int hm_get_device_num (HM_LIB hm_dll, HM_ADAPTER hm_adapter_index, int *hm_device_num); +int hm_get_device_num (HM_LIB hm_dll, 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); -int hm_get_adapter_index (hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo); +int hm_get_adapter_index_amd (hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo); -LPAdapterInfo hm_get_adapter_info (HM_LIB hm_dll, int iNumberAdapters); +LPAdapterInfo hm_get_adapter_info_amd (HM_LIB hm_dll, int iNumberAdapters); uint32_t *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo); int hm_get_overdrive_version (HM_LIB hm_dll, hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo); int hm_check_fanspeed_control (HM_LIB hm_dll, hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo); -void hm_close (HM_LIB hm_dll); +void hm_close_amd (HM_LIB hm_dll); -HM_LIB hm_init (); +HM_LIB hm_init_amd (); 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_utilization_with_device_id (const uint device_id); -int hm_set_fanspeed_with_device_id (const uint device_id, const int fanspeed); -*/ +int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed); void myabort (); void myquit (); diff --git a/include/types.h b/include/types.h index ba5d462..36de62d 100644 --- a/include/types.h +++ b/include/types.h @@ -957,7 +957,10 @@ typedef struct __hc_device_param hc_device_param_t; typedef struct { -// HM_ADAPTER adapter_index; + union { + HM_ADAPTER_AMD amd; + HM_ADAPTER_NV nv; + } adapter_index; int od_version; diff --git a/src/oclHashcat.c b/src/oclHashcat.c index c0f1908..2ac9e4f 100644 --- a/src/oclHashcat.c +++ b/src/oclHashcat.c @@ -831,7 +831,6 @@ void status_display_automat () * temperature */ -/* if (data.gpu_temp_disable == 0) { fprintf (out, "TEMP\t"); @@ -847,7 +846,6 @@ void status_display_automat () hc_thread_mutex_unlock (mux_adl); } -*/ #ifdef _WIN fputc ('\r', out); @@ -1487,7 +1485,6 @@ void status_display () } } -/* if (data.gpu_temp_disable == 0) { hc_thread_mutex_lock (mux_adl); @@ -1498,14 +1495,14 @@ void status_display () { const int temperature = hm_get_temperature_with_device_id (i); const int utilization = hm_get_utilization_with_device_id (i); - const int fanspeed = hm_get_fanspeed_with_device_id (i); + const int fanspeed = hm_get_fanspeed_with_device_id (i); - if (vendor_id == VENDOR_ID_AMD) + if (data.vendor_id == VENDOR_ID_AMD) { log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2d%% Fan", i + 1, utilization, temperature, fanspeed); } - if (vendor_id == VENDOR_ID_NV) + if (data.vendor_id == VENDOR_ID_NV) { #ifdef LINUX log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2d%% Fan", i + 1, utilization, temperature, fanspeed); @@ -1525,7 +1522,6 @@ void status_display () hc_thread_mutex_unlock (mux_adl); } -*/ } static void status_benchmark () @@ -3273,6 +3269,8 @@ static void *thread_monitor (void *p) uint remove_left = data.remove_timer; uint status_left = data.status_timer; + // these variables are mainly used for fan control (AMD only) + int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int)); // temperature controller "loopback" values @@ -3290,16 +3288,24 @@ static void *thread_monitor (void *p) uint sleep_time = 1; if (data.runtime) + { runtime_check = 1; + } if (data.restore_timer) + { restore_check = 1; + } if ((data.remove == 1) && (data.hashlist_mode == HL_MODE_FILE)) + { remove_check = 1; + } if (data.status == 1) + { status_check = 1; + } if (data.gpu_temp_disable == 0) { @@ -3319,7 +3325,6 @@ static void *thread_monitor (void *p) if (data.devices_status != STATUS_RUNNING) continue; - /* if (hwmon_check == 1) { hc_thread_mutex_lock (mux_adl); @@ -3347,7 +3352,7 @@ static void *thread_monitor (void *p) const int gpu_temp_retain = data.gpu_temp_retain; - if (gpu_temp_retain) + if (gpu_temp_retain) // VENDOR_ID_AMD implied { if (data.hm_device[i].fan_supported == 1) { @@ -3389,7 +3394,7 @@ static void *thread_monitor (void *p) if ((freely_change_fan_speed == 1) || (fan_speed_must_change == 1)) { - hm_set_fanspeed_with_device_id (i, fan_speed_new); + hm_set_fanspeed_with_device_id_amd (i, fan_speed_new); fan_speed_chgd[i] = 1; } @@ -3403,7 +3408,6 @@ static void *thread_monitor (void *p) hc_thread_mutex_unlock (mux_adl); } - */ if (restore_check == 1) { @@ -4831,10 +4835,11 @@ static uint hlfmt_detect (FILE *fp, uint max_check) } /** - * main + * some further helper function */ -// temp ? +// wrapper around mymalloc for ADL + void *__stdcall ADL_Main_Memory_Alloc (const int iSize) { return mymalloc (iSize); @@ -4886,6 +4891,10 @@ static uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, cons return collisions; } +/** + * main + */ + int main (int argc, char **argv) { /** @@ -12201,12 +12210,24 @@ int main (int argc, char **argv) else if (strcmp (CL_platform_vendor, CL_VENDOR_NV) == 0) { vendor_id = VENDOR_ID_NV; + + // make sure that we do not directly control the fan for NVidia + + gpu_temp_retain = 0; + data.gpu_temp_retain = gpu_temp_retain; } else { vendor_id = VENDOR_ID_UNKNOWN; } + if (vendor_id == VENDOR_ID_UNKNOWN) + { + log_error ("Warning: unknown OpenCL vendor '%s' detected", CL_platform_vendor); + + gpu_temp_disable = 1; + } + data.vendor_id = vendor_id; /** @@ -12226,7 +12247,6 @@ int main (int argc, char **argv) memset (hm_adapter_all, 0, sizeof (hm_adapter_all)); - /* if (gpu_temp_disable == 0) { if (vendor_id == VENDOR_ID_NV) @@ -12234,15 +12254,15 @@ int main (int argc, char **argv) #ifdef LINUX if (hc_NVML_nvmlInit () == NVML_SUCCESS) { - HM_ADAPTER nvGPUHandle[DEVICES_MAX]; + HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]; - int tmp_in = hm_get_adapter_index (nvGPUHandle); + int tmp_in = hm_get_adapter_index_nv (nvGPUHandle); int tmp_out = 0; for (int i = 0; i < tmp_in; i++) { - hm_adapter_all[tmp_out++].adapter_index = nvGPUHandle[i]; + hm_adapter_all[tmp_out++].adapter_index.nv = nvGPUHandle[i]; } hm_adapters_all = tmp_out; @@ -12251,7 +12271,7 @@ int main (int argc, char **argv) { unsigned int speed; - if (nvmlDeviceGetFanSpeed (hm_adapter_all[i].adapter_index, &speed) != NVML_ERROR_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1; + if (nvmlDeviceGetFanSpeed (hm_adapter_all[i].adapter_index.nv, &speed) != NVML_ERROR_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1; } } #endif @@ -12259,15 +12279,15 @@ int main (int argc, char **argv) #ifdef WIN if (NvAPI_Initialize () == NVAPI_OK) { - HM_ADAPTER nvGPUHandle[DEVICES_MAX]; + HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]; - int tmp_in = hm_get_adapter_index (nvGPUHandle); + int tmp_in = hm_get_adapter_index_nv (nvGPUHandle); int tmp_out = 0; for (int i = 0; i < tmp_in; i++) { - hm_adapter_all[tmp_out++].adapter_index = nvGPUHandle[i]; + hm_adapter_all[tmp_out++].adapter_index.nv = nvGPUHandle[i]; } hm_adapters_all = tmp_out; @@ -12276,7 +12296,7 @@ int main (int argc, char **argv) { NvU32 speed; - if (NvAPI_GPU_GetTachReading (hm_adapter_all[i].adapter_index, &speed) != NVAPI_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1; + if (NvAPI_GPU_GetTachReading (hm_adapter_all[i].adapter_index.nv, &speed) != NVAPI_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1; } } #endif @@ -12284,7 +12304,7 @@ int main (int argc, char **argv) if (vendor_id == VENDOR_ID_AMD) { - HM_LIB hm_dll = hm_init (); + HM_LIB hm_dll = hm_init_amd (); data.hm_dll = hm_dll; @@ -12294,11 +12314,11 @@ int main (int argc, char **argv) int hm_adapters_num; - if (get_adapters_num (hm_dll, &hm_adapters_num) != 0) return (-1); + if (get_adapters_num_amd (hm_dll, &hm_adapters_num) != 0) return (-1); // adapter info - LPAdapterInfo lpAdapterInfo = hm_get_adapter_info (hm_dll, hm_adapters_num); + LPAdapterInfo lpAdapterInfo = hm_get_adapter_info_amd (hm_dll, hm_adapters_num); if (lpAdapterInfo == NULL) return (-1); @@ -12314,7 +12334,7 @@ int main (int argc, char **argv) // hm_get_opencl_busid_devid (hm_adapter_all, devices_all_cnt, devices_all); - hm_get_adapter_index (hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); + hm_get_adapter_index_amd (hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); hm_get_overdrive_version (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); hm_check_fanspeed_control (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); @@ -12340,7 +12360,6 @@ int main (int argc, char **argv) gpu_temp_abort = 0; gpu_temp_retain = 0; } - */ /** * enable custom signal handler(s) @@ -12651,13 +12670,12 @@ int main (int argc, char **argv) } /* - * Temporary fix: - * with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff - * otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately - * were not working @ full speed (setting hc_ADL_Overdrive_PowerControl_Set () here seems to fix the problem) - * Driver / ADL bug? - * - + * Temporary fix: + * with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff + * otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately + * were not working @ full speed (setting hc_ADL_Overdrive_PowerControl_Set () here seems to fix the problem) + * Driver / ADL bug? + */ if (vendor_id == VENDOR_ID_AMD) { @@ -12675,7 +12693,7 @@ int main (int argc, char **argv) int ADL_rc = 0; - if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index, &powertune_supported)) != ADL_OK) + if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune_supported)) != ADL_OK) { log_error ("ERROR: Failed to get ADL PowerControl Capabilities"); @@ -12687,14 +12705,14 @@ int main (int argc, char **argv) // powertune set ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0}; - if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[i].adapter_index, &powertune)) != ADL_OK) + if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune)) != ADL_OK) { log_error ("ERROR: Failed to get current ADL PowerControl settings"); return (-1); } - if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index, powertune.iMaxValue)) != ADL_OK) + if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, powertune.iMaxValue)) != ADL_OK) { log_error ("ERROR: Failed to set new ADL PowerControl values"); @@ -12707,7 +12725,6 @@ int main (int argc, char **argv) hc_thread_mutex_unlock (mux_adl); } } - */ uint gpu_blocks_all = 0; @@ -13696,10 +13713,9 @@ int main (int argc, char **argv) int gpu_temp_retain_set = 0; - /* if (gpu_temp_disable == 0) { - if (gpu_temp_retain != 0) + if (gpu_temp_retain != 0) // VENDOR_ID_AMD implied { hc_thread_mutex_lock (mux_adl); @@ -13710,7 +13726,7 @@ int main (int argc, char **argv) uint cur_temp = 0; uint default_temp = 0; - int ADL_rc = hc_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_dll, data.hm_device[device_id].adapter_index, (int *) &cur_temp, (int *) &default_temp); + int ADL_rc = hc_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, (int *) &cur_temp, (int *) &default_temp); if (ADL_rc == ADL_OK) { @@ -13749,14 +13765,12 @@ int main (int argc, char **argv) hc_thread_mutex_unlock (mux_adl); } } - */ /** * Store original powercontrol/clocks settings, set overdrive 6 performance tuning settings */ - /* - if (powertune_enable == 1) + if (powertune_enable == 1) // VENDOR_ID_AMD implied { hc_thread_mutex_lock (mux_adl); @@ -13768,7 +13782,7 @@ int main (int argc, char **argv) int powertune_supported = 0; - if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[device_id].adapter_index, &powertune_supported)) != ADL_OK) + if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &powertune_supported)) != ADL_OK) { log_error ("ERROR: Failed to get ADL PowerControl Capabilities"); @@ -13781,9 +13795,9 @@ int main (int argc, char **argv) ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0}; - if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &powertune)) == ADL_OK) + if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &powertune)) == ADL_OK) { - ADL_rc = hc_ADL_Overdrive_PowerControl_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &od_power_control_status[device_id]); + ADL_rc = hc_ADL_Overdrive_PowerControl_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &od_power_control_status[device_id]); } if (ADL_rc != ADL_OK) @@ -13793,7 +13807,7 @@ int main (int argc, char **argv) return (-1); } - if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[device_id].adapter_index, powertune.iMaxValue)) != ADL_OK) + if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[device_id].adapter_index.amd, powertune.iMaxValue)) != ADL_OK) { log_error ("ERROR: Failed to set new ADL PowerControl values"); @@ -13806,7 +13820,7 @@ int main (int argc, char **argv) od_clock_mem_status[device_id].state.iNumberOfPerformanceLevels = 2; - if ((ADL_rc = hc_ADL_Overdrive_StateInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, &od_clock_mem_status[device_id])) != ADL_OK) + if ((ADL_rc = hc_ADL_Overdrive_StateInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, &od_clock_mem_status[device_id])) != ADL_OK) { log_error ("ERROR: Failed to get ADL memory and engine clock frequency"); @@ -13817,7 +13831,7 @@ int main (int argc, char **argv) ADLOD6Capabilities caps = {0, 0, 0, {0, 0, 0}, {0, 0, 0}, 0, 0}; - if ((ADL_rc = hc_ADL_Overdrive_Capabilities_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &caps)) != ADL_OK) + if ((ADL_rc = hc_ADL_Overdrive_Capabilities_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &caps)) != ADL_OK) { log_error ("ERROR: Failed to get ADL device capabilities"); @@ -13854,7 +13868,7 @@ int main (int argc, char **argv) performance_state->aLevels[0].iMemoryClock = memory_clock_profile_max; performance_state->aLevels[1].iMemoryClock = memory_clock_profile_max; - if ((ADL_rc = hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[device_id].adapter_index, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK) + if ((ADL_rc = hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[device_id].adapter_index.amd, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK) { log_info ("ERROR: Failed to set ADL performance state"); @@ -13867,7 +13881,6 @@ int main (int argc, char **argv) hc_thread_mutex_unlock (mux_adl); } - */ } data.gpu_blocks_all = gpu_blocks_all; @@ -15948,10 +15961,9 @@ int main (int argc, char **argv) // reset default fan speed -/* if (gpu_temp_disable == 0) { - if (gpu_temp_retain != 0) + if (gpu_temp_retain != 0) // VENDOR_ID_AMD is implied here { hc_thread_mutex_lock (mux_adl); @@ -15963,7 +15975,7 @@ int main (int argc, char **argv) if (fanspeed == -1) continue; - int rc = hm_set_fanspeed_with_device_id (i, fanspeed); + int rc = hm_set_fanspeed_with_device_id_amd (i, fanspeed); if (rc == -1) log_info ("WARNING: Failed to restore default fan speed for gpu number: %i:", i); } @@ -15975,7 +15987,7 @@ int main (int argc, char **argv) // reset power tuning - if (powertune_enable == 1) + if (powertune_enable == 1) // VENDOR_ID_AMD is implied here { hc_thread_mutex_lock (mux_adl); @@ -15987,7 +15999,7 @@ int main (int argc, char **argv) int powertune_supported = 0; - if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index, &powertune_supported)) != ADL_OK) + if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune_supported)) != ADL_OK) { log_error ("ERROR: Failed to get ADL PowerControl Capabilities"); @@ -15998,7 +16010,7 @@ int main (int argc, char **argv) { // powercontrol settings - if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index, od_power_control_status[i])) != ADL_OK) + if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, od_power_control_status[i])) != ADL_OK) { log_info ("ERROR: Failed to restore the ADL PowerControl values"); @@ -16016,7 +16028,7 @@ int main (int argc, char **argv) performance_state->aLevels[0].iMemoryClock = od_clock_mem_status[i].state.aLevels[0].iMemoryClock; performance_state->aLevels[1].iMemoryClock = od_clock_mem_status[i].state.aLevels[1].iMemoryClock; - if ((hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[i].adapter_index, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK) + if ((hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK) { log_info ("ERROR: Failed to restore ADL performance state"); @@ -16048,10 +16060,9 @@ int main (int argc, char **argv) { hc_ADL_Main_Control_Destroy (data.hm_dll); - hm_close (data.hm_dll); + hm_close_amd (data.hm_dll); } } -*/ // free memory diff --git a/src/shared.c b/src/shared.c index ce440cf..10b1963 100644 --- a/src/shared.c +++ b/src/shared.c @@ -2633,9 +2633,8 @@ void fsync (int fd) * thermal */ -/* #ifdef _WIN -int hm_get_adapter_index (HM_ADAPTER nvGPUHandle[DEVICES_MAX]) +int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]) { NvU32 pGpuCount; @@ -2653,7 +2652,7 @@ int hm_get_adapter_index (HM_ADAPTER nvGPUHandle[DEVICES_MAX]) #endif #ifdef LINUX -int hm_get_adapter_index (HM_ADAPTER nvGPUHandle[DEVICES_MAX]) +int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]) { int pGpuCount = 0; @@ -2680,7 +2679,7 @@ int hm_get_adapter_index (HM_ADAPTER nvGPUHandle[DEVICES_MAX]) } #endif -void hm_close (HM_LIB hm_dll) +void hm_close_amd (HM_LIB hm_dll) { #ifdef _POSIX dlclose (hm_dll); @@ -2691,7 +2690,7 @@ void hm_close (HM_LIB hm_dll) #endif } -HM_LIB hm_init () +HM_LIB hm_init_amd () { #ifdef _POSIX HM_LIB hm_dll = dlopen ("libatiadlxx.so", RTLD_LAZY | RTLD_GLOBAL); @@ -2707,7 +2706,7 @@ HM_LIB hm_init () return hm_dll; } -int get_adapters_num (HM_LIB hm_dll, int *iNumberAdapters) +int get_adapters_num_amd (HM_LIB hm_dll, int *iNumberAdapters) { if (hc_ADL_Adapter_NumberOfAdapters_Get (hm_dll, iNumberAdapters) != ADL_OK) return -1; @@ -2721,6 +2720,7 @@ int get_adapters_num (HM_LIB hm_dll, int *iNumberAdapters) return 0; } +/* int hm_show_performance_level (HM_LIB hm_dll, int iAdapterIndex) { ADLODPerformanceLevels *lpOdPerformanceLevels = NULL; @@ -2754,8 +2754,9 @@ int hm_show_performance_level (HM_LIB hm_dll, int iAdapterIndex) return 0; } +*/ -LPAdapterInfo hm_get_adapter_info (HM_LIB hm_dll, int iNumberAdapters) +LPAdapterInfo hm_get_adapter_info_amd (HM_LIB hm_dll, int iNumberAdapters) { size_t AdapterInfoSize = iNumberAdapters * sizeof (AdapterInfo); @@ -2766,6 +2767,7 @@ LPAdapterInfo hm_get_adapter_info (HM_LIB hm_dll, int iNumberAdapters) return lpAdapterInfo; } +/* // // does not help at all, since AMD does not assign different bus id, device id when we have multi GPU setups // @@ -2804,6 +2806,7 @@ void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices, hm_device[i].devid = device_topology.pcie.device; } } +*/ void hm_sort_adl_adapters_by_busid_devid (uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo) { @@ -3018,7 +3021,7 @@ int hm_get_overdrive_version (HM_LIB hm_dll, hm_attrs_t *hm_device, uint32_t *va return 0; } -int hm_get_adapter_index (hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo) +int hm_get_adapter_index_amd (hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo) { for (int i = 0; i < num_adl_adapters; i++) { @@ -3036,7 +3039,7 @@ int hm_get_adapter_index (hm_attrs_t *hm_device, uint32_t *valid_adl_device_list int opencl_device_index = i; - hm_device[opencl_device_index].adapter_index = info.iAdapterIndex; + hm_device[opencl_device_index].adapter_index.amd = info.iAdapterIndex; } return num_adl_adapters; @@ -3054,7 +3057,7 @@ int hm_get_temperature_with_device_id (const uint device_id) Temperature.iSize = sizeof (ADLTemperature); - if (hc_ADL_Overdrive5_Temperature_Get (data.hm_dll, data.hm_device[device_id].adapter_index, 0, &Temperature) != ADL_OK) return -1; + if (hc_ADL_Overdrive5_Temperature_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, 0, &Temperature) != ADL_OK) return -1; return Temperature.iTemperature / 1000; } @@ -3062,7 +3065,7 @@ int hm_get_temperature_with_device_id (const uint device_id) { int Temperature = 0; - if (hc_ADL_Overdrive6_Temperature_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &Temperature) != ADL_OK) return -1; + if (hc_ADL_Overdrive6_Temperature_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &Temperature) != ADL_OK) return -1; return Temperature / 1000; } @@ -3074,7 +3077,7 @@ int hm_get_temperature_with_device_id (const uint device_id) #ifdef LINUX int temperature = 0; - hc_NVML_nvmlDeviceGetTemperature (data.hm_device[device_id].adapter_index, NVML_TEMPERATURE_GPU, (unsigned int *) &temperature); + hc_NVML_nvmlDeviceGetTemperature (data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_GPU, (unsigned int *) &temperature); return temperature; #endif @@ -3087,7 +3090,7 @@ int hm_get_temperature_with_device_id (const uint device_id) pThermalSettings.sensor[0].controller = NVAPI_THERMAL_CONTROLLER_UNKNOWN; pThermalSettings.sensor[0].target = NVAPI_THERMAL_TARGET_GPU; - if (hc_NvAPI_GPU_GetThermalSettings (data.hm_device[device_id].adapter_index, 0, &pThermalSettings) != NVAPI_OK) return -1; + if (hc_NvAPI_GPU_GetThermalSettings (data.hm_device[device_id].adapter_index.nv, 0, &pThermalSettings) != NVAPI_OK) return -1; return pThermalSettings.sensor[0].currentTemp; #endif @@ -3114,7 +3117,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id) lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED; - if (hc_ADL_Overdrive5_FanSpeed_Get (data.hm_dll, data.hm_device[device_id].adapter_index, 0, &lpFanSpeedValue) != ADL_OK) return -1; + if (hc_ADL_Overdrive5_FanSpeed_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1; return lpFanSpeedValue.iFanSpeed; } @@ -3124,7 +3127,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id) memset (&faninfo, 0, sizeof (faninfo)); - if (hc_ADL_Overdrive6_FanSpeed_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &faninfo) != ADL_OK) return -1; + if (hc_ADL_Overdrive6_FanSpeed_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &faninfo) != ADL_OK) return -1; return faninfo.iFanSpeedPercent; } @@ -3136,7 +3139,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id) #ifdef LINUX int speed = 0; - hc_NVML_nvmlDeviceGetFanSpeed (data.hm_device[device_id].adapter_index, (unsigned int *) &speed); + hc_NVML_nvmlDeviceGetFanSpeed (data.hm_device[device_id].adapter_index.nv, (unsigned int *) &speed); return speed; #endif @@ -3144,7 +3147,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id) #ifdef WIN NvU32 speed = 0; - hc_NvAPI_GPU_GetTachReading (data.hm_device[device_id].adapter_index, &speed); + hc_NvAPI_GPU_GetTachReading (data.hm_device[device_id].adapter_index.nv, &speed); return speed; #endif @@ -3164,18 +3167,18 @@ int hm_get_utilization_with_device_id (const uint device_id) PMActivity.iSize = sizeof (ADLPMActivity); - if (hc_ADL_Overdrive_CurrentActivity_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &PMActivity) != ADL_OK) return -1; + if (hc_ADL_Overdrive_CurrentActivity_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &PMActivity) != ADL_OK) return -1; return PMActivity.iActivityPercent; } } - if (data.vendor_id == VENDOR_ID_AMD) + if (data.vendor_id == VENDOR_ID_NV) { #ifdef LINUX nvmlUtilization_t utilization; - hc_NVML_nvmlDeviceGetUtilizationRates (data.hm_device[device_id].adapter_index, &utilization); + hc_NVML_nvmlDeviceGetUtilizationRates (data.hm_device[device_id].adapter_index.nv, &utilization); return utilization.gpu; #endif @@ -3185,7 +3188,7 @@ int hm_get_utilization_with_device_id (const uint device_id) pDynamicPstatesInfoEx.version = NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER; - if (hc_NvAPI_GPU_GetDynamicPstatesInfoEx (data.hm_device[device_id].adapter_index, &pDynamicPstatesInfoEx) != NVAPI_OK) return -1; + if (hc_NvAPI_GPU_GetDynamicPstatesInfoEx (data.hm_device[device_id].adapter_index.nv, &pDynamicPstatesInfoEx) != NVAPI_OK) return -1; return pDynamicPstatesInfoEx.utilization[0].percentage; #endif @@ -3194,7 +3197,7 @@ int hm_get_utilization_with_device_id (const uint device_id) return -1; } -int hm_set_fanspeed_with_device_id (const uint device_id, const int fanspeed) +int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed) { if (data.hm_device[device_id].fan_supported == 1) { @@ -3211,7 +3214,7 @@ int hm_set_fanspeed_with_device_id (const uint device_id, const int fanspeed) lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED; lpFanSpeedValue.iFanSpeed = fanspeed; - if (hc_ADL_Overdrive5_FanSpeed_Set (data.hm_dll, data.hm_device[device_id].adapter_index, 0, &lpFanSpeedValue) != ADL_OK) return -1; + if (hc_ADL_Overdrive5_FanSpeed_Set (data.hm_dll, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1; return 0; } @@ -3224,7 +3227,7 @@ int hm_set_fanspeed_with_device_id (const uint device_id, const int fanspeed) fan_speed_value.iSpeedType = ADL_OD6_FANSPEED_TYPE_PERCENT; fan_speed_value.iFanSpeed = fanspeed; - if (hc_ADL_Overdrive6_FanSpeed_Set (data.hm_dll, data.hm_device[device_id].adapter_index, &fan_speed_value) != ADL_OK) return -1; + if (hc_ADL_Overdrive6_FanSpeed_Set (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &fan_speed_value) != ADL_OK) return -1; return 0; } @@ -3233,7 +3236,6 @@ int hm_set_fanspeed_with_device_id (const uint device_id, const int fanspeed) return -1; } -*/ /** * maskprocessor