From: jsteube Date: Fri, 15 Jan 2016 16:23:07 +0000 (+0100) Subject: Reorder device mapping X-Git-Tag: v3.00-beta~502 X-Git-Url: https://www.flypig.org.uk/git/?a=commitdiff_plain;h=5ae5a4bc25cd0f6bb8928684536cf6b234f907a3;p=hashcat.git Reorder device mapping --- diff --git a/include/shared.h b/include/shared.h index 9e4adeb..f3b1e27 100644 --- a/include/shared.h +++ b/include/shared.h @@ -1630,9 +1630,9 @@ void handle_left_request (pot_t *pot, uint pot_cnt, char *input_buf, int input_l void handle_show_request_lm (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *), FILE *out_fp); void handle_left_request_lm (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *), FILE *out_fp); -uint setup_opencl_platforms_filter (char *opencl_platforms); -uint devices_to_devicemask (char *opencl_devices); -cl_device_type setup_device_types_filter (char *opencl_device_types); +u32 setup_opencl_platforms_filter (char *opencl_platforms); +u32 setup_devices_filter (char *opencl_devices); +cl_device_type setup_device_types_filter (char *opencl_device_types); u32 get_random_num (const u32 min, const u32 max); diff --git a/include/types.h b/include/types.h index 737bbfe..fac4cff 100644 --- a/include/types.h +++ b/include/types.h @@ -818,7 +818,13 @@ typedef struct struct __hc_device_param { + cl_device_id device; + cl_device_type device_type; + uint device_id; + uint platform_devices_id; // for mapping with hms devices + + uint skipped; uint sm_major; uint sm_minor; @@ -826,7 +832,9 @@ struct __hc_device_param uint device_processors; uint device_processor_cores; - u64 device_maxmem_alloc; + u64 device_maxmem_alloc; + u64 device_global_mem; + u32 device_maxclock_frequency; uint kernel_threads; uint kernel_accel; @@ -859,10 +867,10 @@ struct __hc_device_param pw_t *pws_buf; uint pws_cnt; - u64 pw_cnt; + u64 pw_cnt; - u64 words_off; - u64 words_done; + u64 words_off; + u64 words_done; uint *result; @@ -873,7 +881,7 @@ struct __hc_device_param uint innerloop_left; uint speed_pos; - u64 speed_cnt[SPEED_CACHE]; + u64 speed_cnt[SPEED_CACHE]; float speed_ms[SPEED_CACHE]; hc_timer_t speed_rec[SPEED_CACHE]; @@ -888,9 +896,6 @@ struct __hc_device_param cl_uint vendor_id; - cl_device_id device; - cl_device_type device_type; - cl_kernel kernel1; cl_kernel kernel12; cl_kernel kernel2; @@ -997,6 +1002,7 @@ typedef struct uint devices_status; uint devices_cnt; + uint devices_active; hc_device_param_t *devices_param; uint kernel_blocks_all; diff --git a/src/oclHashcat.c b/src/oclHashcat.c index a8d48e9..faa6948 100644 --- a/src/oclHashcat.c +++ b/src/oclHashcat.c @@ -743,6 +743,8 @@ void status_display_automat () { hc_device_param_t *device_param = &data.devices_param[device_id]; + if (device_param->skipped) continue; + u64 speed_cnt = 0; float speed_ms = 0; @@ -845,9 +847,13 @@ void status_display_automat () hc_thread_mutex_lock (mux_adl); - for (uint i = 0; i < data.devices_cnt; i++) + for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { - int temp = hm_get_temperature_with_device_id (i); + hc_device_param_t *device_param = &data.devices_param[device_id]; + + if (device_param->skipped) continue; + + int temp = hm_get_temperature_with_device_id (device_id); fprintf (out, "%d\t", temp); } @@ -1089,6 +1095,8 @@ void status_display () { hc_device_param_t *device_param = &data.devices_param[device_id]; + if (device_param->skipped) continue; + // we need to clear values (set to 0) because in case the device does // not get new candidates it idles around but speed display would // show it as working. @@ -1122,6 +1130,10 @@ void status_display () for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { + hc_device_param_t *device_param = &data.devices_param[device_id]; + + if (device_param->skipped) continue; + hashes_dev_ms[device_id] = 0; if (speed_ms[device_id]) @@ -1336,6 +1348,10 @@ void status_display () for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { + hc_device_param_t *device_param = &data.devices_param[device_id]; + + if (device_param->skipped) continue; + char display_dev_cur[16]; memset (display_dev_cur, 0, sizeof (display_dev_cur)); @@ -1355,7 +1371,7 @@ void status_display () format_speed_display (hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (data.devices_cnt > 1) log_info ("Speed.Dev.#*...: %9sH/s", display_all_cur); + if (data.devices_active > 1) log_info ("Speed.Dev.#*...: %9sH/s", display_all_cur); const float digests_percent = (float) data.digests_done / data.digests_cnt; const float salts_percent = (float) data.salts_done / data.salts_cnt; @@ -1501,6 +1517,8 @@ void status_display () { hc_device_param_t *device_param = &data.devices_param[device_id]; + if (device_param->skipped) continue; + #define HM_STR_BUF_SIZE 255 if (data.hm_device[device_id].fan_supported == 1) @@ -1559,6 +1577,8 @@ static void status_benchmark () { hc_device_param_t *device_param = &data.devices_param[device_id]; + if (device_param->skipped) continue; + speed_cnt[device_id] = 0; speed_ms[device_id] = 0; @@ -1578,6 +1598,10 @@ static void status_benchmark () for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { + hc_device_param_t *device_param = &data.devices_param[device_id]; + + if (device_param->skipped) continue; + hashes_dev_ms[device_id] = 0; if (speed_ms[device_id]) @@ -1590,6 +1614,10 @@ static void status_benchmark () for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { + hc_device_param_t *device_param = &data.devices_param[device_id]; + + if (device_param->skipped) continue; + char display_dev_cur[16]; memset (display_dev_cur, 0, sizeof (display_dev_cur)); @@ -1609,7 +1637,7 @@ static void status_benchmark () format_speed_display (hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (data.devices_cnt > 1) log_info ("Speed.Dev.#*.: %9sH/s", display_all_cur); + if (data.devices_active > 1) log_info ("Speed.Dev.#*.: %9sH/s", display_all_cur); } /** @@ -1805,7 +1833,7 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co int debug_rule_len = 0; // -1 error uint debug_plain_len = 0; - unsigned char debug_plain_ptr[BLOCK_SIZE]; + u8 debug_plain_ptr[BLOCK_SIZE]; // hash @@ -1828,7 +1856,7 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co uint plain_buf[16]; - unsigned char *plain_ptr = (unsigned char *) plain_buf; + u8 *plain_ptr = (u8 *) plain_buf; unsigned int plain_len = 0; if (data.attack_mode == ATTACK_MODE_STRAIGHT) @@ -3432,15 +3460,19 @@ static void *thread_monitor (void *p) if (Ta == 0) Ta = 1; - for (uint i = 0; i < data.devices_cnt; i++) + for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { - if ((data.devices_param[i].device_type & CL_DEVICE_TYPE_GPU) == 0) continue; + hc_device_param_t *device_param = &data.devices_param[device_id]; - const int temperature = hm_get_temperature_with_device_id (i); + if (device_param->skipped) continue; + + if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) continue; + + const int temperature = hm_get_temperature_with_device_id (device_id); if (temperature > (int) data.gpu_temp_abort) { - log_error ("ERROR: Temperature limit on GPU %d reached, aborting...", i + 1); + log_error ("ERROR: Temperature limit on GPU %d reached, aborting...", device_id + 1); if (data.devices_status != STATUS_QUIT) myabort (); @@ -3451,13 +3483,13 @@ static void *thread_monitor (void *p) if (gpu_temp_retain) // VENDOR_ID_AMD implied { - if (data.hm_device[i].fan_supported == 1) + if (data.hm_device[device_id].fan_supported == 1) { int temp_cur = temperature; int temp_diff_new = gpu_temp_retain - temp_cur; - temp_diff_sum[i] = temp_diff_sum[i] + temp_diff_new; + temp_diff_sum[device_id] = temp_diff_sum[device_id] + temp_diff_new; // calculate Ta value (time difference in seconds between the last check and this check) @@ -3469,15 +3501,15 @@ static void *thread_monitor (void *p) // PID controller (3-term controller: proportional - Kp, integral - Ki, derivative - Kd) - int fan_diff_required = (int) (Kp * (float)temp_diff_new + Ki * Ta * (float)temp_diff_sum[i] + Kd * ((float)(temp_diff_new - temp_diff_old[i])) / Ta); + int fan_diff_required = (int) (Kp * (float)temp_diff_new + Ki * Ta * (float)temp_diff_sum[device_id] + Kd * ((float)(temp_diff_new - temp_diff_old[device_id])) / Ta); if (abs (fan_diff_required) >= temp_threshold) { - const int fan_speed_cur = hm_get_fanspeed_with_device_id (i); + const int fan_speed_cur = hm_get_fanspeed_with_device_id (device_id); int fan_speed_level = fan_speed_cur; - if (fan_speed_chgd[i] == 0) fan_speed_level = temp_cur; + if (fan_speed_chgd[device_id] == 0) fan_speed_level = temp_cur; int fan_speed_new = fan_speed_level - fan_diff_required; @@ -3486,17 +3518,17 @@ static void *thread_monitor (void *p) if (fan_speed_new != fan_speed_cur) { - int freely_change_fan_speed = (fan_speed_chgd[i] == 1); + int freely_change_fan_speed = (fan_speed_chgd[device_id] == 1); int fan_speed_must_change = (fan_speed_new > fan_speed_cur); if ((freely_change_fan_speed == 1) || (fan_speed_must_change == 1)) { - hm_set_fanspeed_with_device_id_amd (i, fan_speed_new); + hm_set_fanspeed_with_device_id_amd (device_id, fan_speed_new); - fan_speed_chgd[i] = 1; + fan_speed_chgd[device_id] = 1; } - temp_diff_old[i] = temp_diff_new; + temp_diff_old[device_id] = temp_diff_new; } } } @@ -3797,8 +3829,8 @@ static void *thread_outfile_remove (void *p) pke[i] = byte_swap_32 (wpa->pke[i]); } - unsigned char mac1[6]; - unsigned char mac2[6]; + u8 mac1[6]; + u8 mac2[6]; memcpy (mac1, pke_ptr + 23, 6); memcpy (mac2, pke_ptr + 29, 6); @@ -6420,13 +6452,13 @@ int main (int argc, char **argv) * OpenCL platform selection */ - uint opencl_platforms_filter = setup_opencl_platforms_filter (opencl_platforms); + u32 opencl_platforms_filter = setup_opencl_platforms_filter (opencl_platforms); /** * OpenCL device selection */ - uint opencl_devicemask = devices_to_devicemask (opencl_devices); + u32 devices_filter = setup_devices_filter (opencl_devices); /** * OpenCL device type selection @@ -10685,7 +10717,7 @@ int main (int argc, char **argv) wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt; - unsigned char *pke_ptr = (unsigned char *) wpa->pke; + u8 *pke_ptr = (u8 *) wpa->pke; // do the appending task @@ -11746,8 +11778,8 @@ int main (int argc, char **argv) pke[i] = byte_swap_32 (wpa->pke[i]); } - unsigned char mac1[6]; - unsigned char mac2[6]; + u8 mac1[6]; + u8 mac2[6]; memcpy (mac1, pke_ptr + 23, 6); memcpy (mac2, pke_ptr + 29, 6); @@ -12018,7 +12050,7 @@ int main (int argc, char **argv) do { - truecrypt_crc32 (keyfile, (unsigned char *) keyfile_buf); + truecrypt_crc32 (keyfile, (u8 *) keyfile_buf); } while ((keyfile = strtok (NULL, ",")) != NULL); @@ -12370,13 +12402,17 @@ int main (int argc, char **argv) * OpenCL platforms: detect */ - cl_platform_id CL_platforms[CL_PLATFORMS_MAX]; + cl_platform_id platforms[CL_PLATFORMS_MAX]; - uint CL_platforms_cnt = 0; + cl_uint platforms_cnt = 0; - hc_clGetPlatformIDs (CL_PLATFORMS_MAX, CL_platforms, &CL_platforms_cnt); + cl_device_id platform_devices[DEVICES_MAX]; - if (CL_platforms_cnt == 0) + cl_uint platform_devices_cnt; + + hc_clGetPlatformIDs (CL_PLATFORMS_MAX, platforms, &platforms_cnt); + + if (platforms_cnt == 0) { log_error ("ERROR: No OpenCL compatible platform found"); @@ -12387,17 +12423,17 @@ 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 i = 0; i < CL_platforms_cnt; i++) + for (uint platform_id = 0; platform_id < platforms_cnt; platform_id++) { - cl_platform_id CL_platform = CL_platforms[i]; + cl_platform_id platform = platforms[platform_id]; - char CL_platform_vendor[INFOSZ]; + char platform_vendor[INFOSZ]; - memset (CL_platform_vendor, 0, sizeof (CL_platform_vendor)); + memset (platform_vendor, 0, sizeof (platform_vendor)); - hc_clGetPlatformInfo (CL_platform, CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL); + hc_clGetPlatformInfo (platform, CL_PLATFORM_VENDOR, sizeof (platform_vendor), platform_vendor, NULL); - if (strcmp (CL_platform_vendor, CL_VENDOR_NV) == 0) + if (strcmp (platform_vendor, CL_VENDOR_NV) == 0) { // make sure that we do not directly control the fan for NVidia @@ -12408,453 +12444,435 @@ int main (int argc, char **argv) } /** - * OpenCL devices: push all devices from all platforms into the same device array + * OpenCL devices: simply push all devices from all platforms into the same device array */ - uint devices_plf[DEVICES_MAX]; // device number on platform, required for hardware-management mapping + hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (DEVICES_MAX, sizeof (hc_device_param_t)); - cl_device_id devices_all[DEVICES_MAX]; - cl_device_id devices[DEVICES_MAX]; + data.devices_param = devices_param; - uint devices_all_cnt = 0; uint devices_cnt = 0; - for (uint i = 0; i < CL_platforms_cnt; i++) - { - if ((opencl_platforms_filter & (1 << i)) == 0) continue; - - cl_platform_id CL_platform = CL_platforms[i]; + uint devices_active = 0; - cl_device_id devices_platform[DEVICES_MAX]; + for (uint platform_id = 0; platform_id < platforms_cnt; platform_id++) + { + if ((opencl_platforms_filter & (1 << platform_id)) == 0) continue; - cl_uint devices_platform_cnt = 0; + cl_platform_id platform = platforms[platform_id]; - hc_clGetDeviceIDs (CL_platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, devices_platform, &devices_platform_cnt); + hc_clGetDeviceIDs (platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); - for (uint j = 0; j < devices_platform_cnt; j++) + for (uint platform_devices_id = 0; platform_devices_id < platform_devices_cnt; platform_devices_id++) { - devices_all[devices_all_cnt] = devices_platform[j]; - devices_plf[devices_all_cnt] = j; + const uint device_id = devices_cnt; - devices_all_cnt++; - } - } - - /** - * enable custom signal handler(s) - */ - - if (benchmark == 0) - { - hc_signal (sigHandler_default); - } - else - { - hc_signal (sigHandler_benchmark); - } + hc_device_param_t *device_param = &data.devices_param[device_id]; - /** - * devices mask and properties - */ + device_param->device = platform_devices[platform_devices_id]; - uint quiet_sav = quiet; + device_param->device_id = device_id; - if (benchmark) - { - quiet = 0; - } + device_param->platform_devices_id = platform_devices_id; - for (uint device_all_id = 0; device_all_id < devices_all_cnt; device_all_id++) - { - // skip the device, if the user did specify a list of GPUs to skip + // vendor_id - if (opencl_devicemask) - { - uint device_all_id_mask = 1 << device_all_id; + cl_uint vendor_id = 0; - if ((device_all_id_mask & opencl_devicemask) != device_all_id_mask) - { - if (quiet == 0 && algorithm_pos == 0) log_info ("Device #%d: skipped", device_all_id + 1); + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_VENDOR_ID, sizeof (vendor_id), &vendor_id, NULL); - continue; - } - } + device_param->vendor_id = vendor_id; - const uint device_id = devices_cnt; + // device_type - devices[device_id] = devices_all[device_all_id]; + cl_device_type device_type; - devices_plf[device_id] = devices_plf[device_all_id]; + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); - cl_device_type device_type = 0; + device_type &= ~CL_DEVICE_TYPE_DEFAULT; - hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); + device_param->device_type = device_type; - device_type &= ~CL_DEVICE_TYPE_DEFAULT; + // device_name - if ((device_type & device_types_filter) == 0) - { - if (quiet == 0 && algorithm_pos == 0) log_info ("Device #%d: skipped", device_all_id + 1); + char *device_name = (char *) mymalloc (INFOSZ); - continue; - } + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_NAME, INFOSZ, device_name, NULL); - char device_name[INFOSZ]; - char device_version[INFOSZ]; + device_param->device_name = device_name; - memset (device_name, 0, sizeof (device_name)); - memset (device_version, 0, sizeof (device_version)); + // device_version - cl_ulong global_mem_size; - cl_ulong max_mem_alloc_size; - cl_uint max_clock_frequency; - cl_uint max_compute_units; + char *device_version = (char *) mymalloc (INFOSZ); - hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_NAME, sizeof (device_name), &device_name, NULL); - hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (global_mem_size), &global_mem_size, NULL); - hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (max_mem_alloc_size), &max_mem_alloc_size, NULL); - hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (max_clock_frequency), &max_clock_frequency, NULL); - hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL); - hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_VERSION, sizeof (device_version), &device_version, NULL); + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_VERSION, INFOSZ, device_version, NULL); - if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0)) - { - log_info ("Device #%u: %s, %lu/%lu MB allocatable, %dMhz, %uMCU", - device_all_id + 1, - device_name, - (unsigned int) (max_mem_alloc_size / 1024 / 1024), - (unsigned int) (global_mem_size / 1024 / 1024), - (unsigned int) (max_clock_frequency), - (unsigned int) max_compute_units); - } + device_param->device_version = device_version; - if (strstr (device_version, "pocl")) - { - if (force == 0) + if (strstr (device_version, "pocl")) { - log_info (""); - log_info ("ATTENTION! All pocl drivers are known to be broken due to broken LLVM <= 3.7"); - log_info ("You are STRONGLY encouraged not to use it"); - log_info ("You can use --force to override this but do not post error reports if you do so"); - log_info (""); + // pocl returns the real vendor_id in CL_DEVICE_VENDOR_ID which causes many problems because of hms and missing amd_bfe () etc + // we need to overwrite vendor_id to avoid this. maybe open pocl issue? - return (-1); + cl_uint vendor_id = 0xffff; + + device_param->vendor_id = vendor_id; } - } - devices_cnt++; - } + // max_compute_units - quiet = quiet_sav; + cl_uint device_processors; - if (devices_cnt == 0) - { - log_error ("ERROR: No devices left that matches your specification."); + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (device_processors), &device_processors, NULL); - return (-1); - } + device_param->device_processors = device_processors; - data.devices_cnt = devices_cnt; + // max_mem_alloc_size - if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0)) - { - log_info (""); - } + cl_ulong device_maxmem_alloc; - /** - * User-defined GPU temp handling - */ + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (device_maxmem_alloc), &device_maxmem_alloc, NULL); - if (gpu_temp_disable == 1) - { - gpu_temp_abort = 0; - gpu_temp_retain = 0; - } + device_param->device_maxmem_alloc = device_maxmem_alloc; - if ((gpu_temp_abort != 0) && (gpu_temp_retain != 0)) - { - if (gpu_temp_abort < gpu_temp_retain) - { - log_error ("ERROR: invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain."); + // max_mem_alloc_size - return (-1); - } - } + cl_ulong device_global_mem; - data.gpu_temp_disable = gpu_temp_disable; - data.gpu_temp_abort = gpu_temp_abort; - data.gpu_temp_retain = gpu_temp_retain; + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (device_global_mem), &device_global_mem, NULL); - /** - * inform the user - */ + device_param->device_global_mem = device_global_mem; - if (data.quiet == 0) - { - log_info ("Hashes: %u hashes; %u unique digests, %u unique salts", hashes_cnt_orig, digests_cnt, salts_cnt); + // max_clock_frequency - log_info ("Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_bits, bitmap_nums, bitmap_mask, bitmap_size, bitmap_shift1, bitmap_shift2); + cl_uint device_maxclock_frequency; - if (attack_mode == ATTACK_MODE_STRAIGHT) - { - log_info ("Rules: %u", kernel_rules_cnt); - } + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (device_maxclock_frequency), &device_maxclock_frequency, NULL); - if (opti_type) - { - log_info ("Applicable Optimizers:"); + device_param->device_maxclock_frequency = device_maxclock_frequency; - for (uint i = 0; i < 32; i++) - { - const uint opti_bit = 1u << i; + // skipped - if (opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit)); - } - } + const u32 skipped1 = ((devices_filter & (1 << device_id)) == 0); + const u32 skipped2 = ((device_types_filter & (device_type)) == 0); - /** - * Watchdog and Temperature balance - */ + device_param->skipped = (skipped1 || skipped2); - if (gpu_temp_abort == 0) - { - log_info ("Watchdog: Temperature abort trigger disabled"); - } - else - { - log_info ("Watchdog: Temperature abort trigger set to %uc", gpu_temp_abort); - } + // driver_version - if (gpu_temp_retain == 0) - { - log_info ("Watchdog: Temperature retain trigger disabled"); - } - else - { - log_info ("Watchdog: Temperature retain trigger set to %uc", gpu_temp_retain); - } - } + char *driver_version = (char *) mymalloc (INFOSZ); - if (data.quiet == 0) log_info (""); + hc_clGetDeviceInfo (device_param->device, CL_DRIVER_VERSION, INFOSZ, driver_version, NULL); - /** - * devices init - */ + if (vendor_id == VENDOR_ID_AMD) + { + sscanf (driver_version, "%*16s %*16s %*16s (%[^)]16s)", driver_version); + } - int *temp_retain_fanspeed_value = (int *) mycalloc (devices_cnt, sizeof (int)); + device_param->driver_version = driver_version; - ADLOD6MemClockState *od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (devices_cnt, sizeof (ADLOD6MemClockState)); + // device_name_chksum - int *od_power_control_status = (int *) mycalloc (devices_cnt, sizeof (int)); + char *device_name_chksum = (char *) mymalloc (INFOSZ); - hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (devices_cnt, sizeof (hc_device_param_t)); + snprintf (device_name_chksum, INFOSZ - 1, "%u-%s-%s-%s-%d", device_param->vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, COMPTIME); - data.devices_param = devices_param; + uint device_name_digest[4]; - for (uint device_id = 0; device_id < devices_cnt; device_id++) - { - hc_device_param_t *device_param = &data.devices_param[device_id]; + device_name_digest[0] = 0; + device_name_digest[1] = 0; + device_name_digest[2] = 0; + device_name_digest[3] = 0; - cl_device_id device = devices[device_id]; + md5_64 ((uint *) device_name_chksum, device_name_digest); - device_param->device = device; + sprintf (device_name_chksum, "%08x", device_name_digest[0]); - cl_device_type device_type = 0; + device_param->device_name_chksum = device_name_chksum; - hc_clGetDeviceInfo (device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); + // device_processor_cores - device_param->device_type = device_type; + if (device_type & CL_DEVICE_TYPE_CPU) + { + cl_uint device_processor_cores = 1; - cl_uint max_compute_units = 0; + device_param->device_processor_cores = device_processor_cores; + } - hc_clGetDeviceInfo (device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL); + if (device_type & CL_DEVICE_TYPE_GPU) + { + if (vendor_id == VENDOR_ID_AMD) + { + cl_uint device_processor_cores = 0; - device_param->device_processors = max_compute_units; + #define CL_DEVICE_WAVEFRONT_WIDTH_AMD 0x4043 - cl_ulong max_mem_alloc_size = 0; + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_WAVEFRONT_WIDTH_AMD, sizeof (device_processor_cores), &device_processor_cores, NULL); - hc_clGetDeviceInfo (device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (max_mem_alloc_size), &max_mem_alloc_size, NULL); + device_param->device_processor_cores = device_processor_cores; + } + else if (vendor_id == VENDOR_ID_NV) + { + cl_uint kernel_exec_timeout = 0; - device_param->device_maxmem_alloc = max_mem_alloc_size; + #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 - cl_uint vendor_id = 0; + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, sizeof (kernel_exec_timeout), &kernel_exec_timeout, NULL); - hc_clGetDeviceInfo (device, CL_DEVICE_VENDOR_ID, sizeof (vendor_id), &vendor_id, NULL); + device_param->kernel_exec_timeout = kernel_exec_timeout; - device_param->vendor_id = vendor_id; + cl_uint device_processor_cores = 0; - char tmp[INFOSZ], t1[64]; + #define CL_DEVICE_WARP_SIZE_NV 0x4003 - memset (tmp, 0, sizeof (tmp)); + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_WARP_SIZE_NV, sizeof (device_processor_cores), &device_processor_cores, NULL); - hc_clGetDeviceInfo (device, CL_DEVICE_NAME, sizeof (tmp), &tmp, NULL); + device_param->device_processor_cores = device_processor_cores; - device_param->device_name = mystrdup (tmp); + cl_uint sm_minor = 0; + cl_uint sm_major = 0; - memset (tmp, 0, sizeof (tmp)); + #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 + #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 - hc_clGetDeviceInfo (device, CL_DEVICE_VERSION, sizeof (tmp), &tmp, NULL); + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof (sm_minor), &sm_minor, NULL); + hc_clGetDeviceInfo (device_param->device, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof (sm_major), &sm_major, NULL); - if (strstr (tmp, "pocl")) - { - // pocl returns the real AMD vendor_id id in CL_DEVICE_VENDOR_ID which causes many problems because of hms and missing amd_bfe () etc - // we need to overwrite vendor_id to avoid this. maybe open pocl issue? + device_param->sm_minor = sm_minor; + device_param->sm_major = sm_major; + } + else + { + cl_uint device_processor_cores = 1; - cl_uint vendor_id = 0xffff; + device_param->device_processor_cores = device_processor_cores; + } + } - device_param->vendor_id = vendor_id; - } + // display results + + if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0)) + { + if (device_param->skipped == 0) + { + log_info ("Device #%u: %s, %lu/%lu MB allocatable, %dMhz, %uMCU", + device_id + 1, + device_name, + (unsigned int) (device_maxmem_alloc / 1024 / 1024), + (unsigned int) (device_global_mem / 1024 / 1024), + (unsigned int) (device_maxclock_frequency), + (unsigned int) device_processors); + } + else + { + log_info ("Device #%u: %s, skipped", + device_id + 1, + device_name); + } + } - memset (t1, 0, sizeof (t1)); + // common driver check - sscanf (tmp, "%*16s %*16s %*16s (%[^)]16s)", t1); + if (device_param->skipped == 0) + { + if (strstr (device_version, "pocl")) + { + if (force == 0) + { + log_info (""); + log_info ("ATTENTION! All pocl drivers are known to be broken due to broken LLVM <= 3.7"); + log_info ("You are STRONGLY encouraged not to use it"); + log_info ("You can use --force to override this but do not post error reports if you do so"); + log_info (""); - device_param->device_version = mystrdup (t1); + return (-1); + } + } + + if (device_type & CL_DEVICE_TYPE_GPU) + { + if (vendor_id == VENDOR_ID_NV) + { + if (device_param->kernel_exec_timeout != 0) + { + if (data.quiet == 0) log_info ("Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1); + if (data.quiet == 0) log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch"); + } + } + else if (vendor_id == VENDOR_ID_AMD) + { + int catalyst_check = (force == 1) ? 0 : 1; - memset (tmp, 0, sizeof (tmp)); + int catalyst_warn = 0; - hc_clGetDeviceInfo (device, CL_DRIVER_VERSION, sizeof (tmp), &tmp, NULL); + int catalyst_broken = 0; - device_param->driver_version = mystrdup (tmp); + if (catalyst_check == 1) + { + catalyst_warn = 1; - // create some filename that is easier to read on cached folder + // v14.9 and higher + if (atoi (device_param->driver_version) >= 1573) + { + catalyst_warn = 0; + } - snprintf (tmp, sizeof (tmp) - 1, "%u-%s-%s-%s-%d", device_param->vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, COMPTIME); + catalyst_check = 0; + } - uint device_name_digest[4]; + if (catalyst_broken == 1) + { + log_info (""); + log_info ("ATTENTION! The installed catalyst driver in your system is known to be broken!"); + log_info ("It will pass over cracked hashes and does not report them as cracked"); + log_info ("You are STRONGLY encouraged not to use it"); + log_info ("You can use --force to override this but do not post error reports if you do so"); + log_info (""); - device_name_digest[0] = 0; - device_name_digest[1] = 0; - device_name_digest[2] = 0; - device_name_digest[3] = 0; + return (-1); + } - md5_64 ((uint *) tmp, device_name_digest); + if (catalyst_warn == 1) + { + log_info (""); + log_info ("ATTENTION! Unsupported or incorrect installed catalyst driver detected!"); + log_info ("You are STRONGLY encouraged to use the official supported catalyst driver for good reasons"); + log_info ("See oclHashcat's homepage for official supported catalyst drivers"); + #ifdef _WIN + log_info ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to"); + #endif + log_info ("You can use --force to override this but do not post error reports if you do so"); + log_info (""); - sprintf (tmp, "%08x", device_name_digest[0]); + return (-1); + } + } + } - device_param->device_name_chksum = mystrdup (tmp); + devices_active++; + } - if (device_type & CL_DEVICE_TYPE_CPU) - { - cl_uint device_processor_cores = 1; + // next please - device_param->device_processor_cores = device_processor_cores; + devices_cnt++; } + } - if (device_type & CL_DEVICE_TYPE_GPU) - { - if (vendor_id == VENDOR_ID_AMD) - { - cl_uint device_processor_cores = 0; - - #define CL_DEVICE_WAVEFRONT_WIDTH_AMD 0x4043 + if (devices_active == 0) + { + log_error ("ERROR: No devices found/left"); - hc_clGetDeviceInfo (device, CL_DEVICE_WAVEFRONT_WIDTH_AMD, sizeof (device_processor_cores), &device_processor_cores, NULL); + return (-1); + } - device_param->device_processor_cores = device_processor_cores; - } - else if (vendor_id == VENDOR_ID_NV) - { - cl_uint kernel_exec_timeout = 0; + data.devices_cnt = devices_cnt; - #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 + data.devices_active = devices_active; - hc_clGetDeviceInfo (device, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, sizeof (kernel_exec_timeout), &kernel_exec_timeout, NULL); + if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0)) + { + log_info (""); + } - device_param->kernel_exec_timeout = kernel_exec_timeout; + /** + * OpenCL devices: allocate buffer for device specific information + */ - cl_uint device_processor_cores = 0; + int *temp_retain_fanspeed_value = (int *) mycalloc (devices_cnt, sizeof (int)); - #define CL_DEVICE_WARP_SIZE_NV 0x4003 + ADLOD6MemClockState *od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (devices_cnt, sizeof (ADLOD6MemClockState)); - hc_clGetDeviceInfo (device, CL_DEVICE_WARP_SIZE_NV, sizeof (device_processor_cores), &device_processor_cores, NULL); + int *od_power_control_status = (int *) mycalloc (devices_cnt, sizeof (int)); - device_param->device_processor_cores = device_processor_cores; + /** + * enable custom signal handler(s) + */ - cl_uint sm_minor = 0; - cl_uint sm_major = 0; + if (benchmark == 0) + { + hc_signal (sigHandler_default); + } + else + { + hc_signal (sigHandler_benchmark); + } - #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 - #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 + /** + * User-defined GPU temp handling + */ - hc_clGetDeviceInfo (device, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof (sm_minor), &sm_minor, NULL); - hc_clGetDeviceInfo (device, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof (sm_major), &sm_major, NULL); + if (gpu_temp_disable == 1) + { + gpu_temp_abort = 0; + gpu_temp_retain = 0; + } - device_param->sm_minor = sm_minor; - device_param->sm_major = sm_major; - } - else - { - cl_uint device_processor_cores = 1; + if ((gpu_temp_abort != 0) && (gpu_temp_retain != 0)) + { + if (gpu_temp_abort < gpu_temp_retain) + { + log_error ("ERROR: invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain."); - device_param->device_processor_cores = device_processor_cores; - } + return (-1); } + } - /** - * common driver check - */ + data.gpu_temp_disable = gpu_temp_disable; + data.gpu_temp_abort = gpu_temp_abort; + data.gpu_temp_retain = gpu_temp_retain; - if (device_type & CL_DEVICE_TYPE_GPU) - { - if (vendor_id == VENDOR_ID_NV) - { - if (device_param->kernel_exec_timeout != 0) - { - if (data.quiet == 0) log_info ("Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1); - if (data.quiet == 0) log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch"); - } - } - else if (vendor_id == VENDOR_ID_AMD) - { - int catalyst_check = (force == 1) ? 0 : 1; + /** + * inform the user + */ - int catalyst_warn = 0; + if (data.quiet == 0) + { + log_info ("Hashes: %u hashes; %u unique digests, %u unique salts", hashes_cnt_orig, digests_cnt, salts_cnt); - int catalyst_broken = 0; + log_info ("Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_bits, bitmap_nums, bitmap_mask, bitmap_size, bitmap_shift1, bitmap_shift2); - if (catalyst_check == 1) - { - catalyst_warn = 1; + if (attack_mode == ATTACK_MODE_STRAIGHT) + { + log_info ("Rules: %u", kernel_rules_cnt); + } - // v14.9 and higher - if ((atoi (device_param->device_version) >= 1573) - && (atoi (device_param->driver_version) >= 1573)) - { - catalyst_warn = 0; - } + if (opti_type) + { + log_info ("Applicable Optimizers:"); - catalyst_check = 0; - } + for (uint i = 0; i < 32; i++) + { + const uint opti_bit = 1u << i; - if (catalyst_broken == 1) - { - log_error (""); - log_error ("ATTENTION! The installed catalyst driver in your system is known to be broken!"); - log_error ("It will pass over cracked hashes and does not report them as cracked"); - log_error ("You are STRONGLY encouraged not to use it"); - log_error ("You can use --force to override this but do not post error reports if you do so"); + if (opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit)); + } + } - return (-1); - } + /** + * Watchdog and Temperature balance + */ - if (catalyst_warn == 1) - { - log_error (""); - log_error ("ATTENTION! Unsupported or incorrect installed catalyst driver detected!"); - log_error ("You are STRONGLY encouraged to use the official supported catalyst driver for good reasons"); - log_error ("See oclHashcat's homepage for official supported catalyst drivers"); - #ifdef _WIN - log_error ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to"); - #endif - log_error ("You can use --force to override this but do not post error reports if you do so"); + if (gpu_temp_abort == 0) + { + log_info ("Watchdog: Temperature abort trigger disabled"); + } + else + { + log_info ("Watchdog: Temperature abort trigger set to %uc", gpu_temp_abort); + } - return (-1); - } - } + if (gpu_temp_retain == 0) + { + log_info ("Watchdog: Temperature retain trigger disabled"); + } + else + { + log_info ("Watchdog: Temperature retain trigger set to %uc", gpu_temp_retain); } } + if (data.quiet == 0) log_info (""); + /** * HM devices: init */ @@ -12978,16 +12996,18 @@ int main (int argc, char **argv) if ((device_param->device_type & CL_DEVICE_TYPE_GPU) == 0) continue; - cl_uint device_id_on_platform = devices_plf[device_id]; + if (device_param->skipped) continue; + + const uint platform_devices_id = device_param->platform_devices_id; if (device_param->vendor_id == VENDOR_ID_NV) { - memcpy (&data.hm_device[device_id], &hm_adapters_nv[device_id_on_platform], sizeof (hm_attrs_t)); + memcpy (&data.hm_device[device_id], &hm_adapters_nv[platform_devices_id], sizeof (hm_attrs_t)); } if (device_param->vendor_id == VENDOR_ID_AMD) { - memcpy (&data.hm_device[device_id], &hm_adapters_amd[device_id_on_platform], sizeof (hm_attrs_t)); + memcpy (&data.hm_device[device_id], &hm_adapters_amd[platform_devices_id], sizeof (hm_attrs_t)); } } } @@ -13006,6 +13026,10 @@ int main (int argc, char **argv) for (uint device_id = 0; device_id < devices_cnt; device_id++) { + hc_device_param_t *device_param = &data.devices_param[device_id]; + + if (device_param->skipped) continue; + if (data.hm_device[device_id].od_version == 6) { // set powertune value only @@ -13056,6 +13080,8 @@ int main (int argc, char **argv) hc_device_param_t *device_param = &data.devices_param[device_id]; + if (device_param->skipped) continue; + /** * device properties */ @@ -13369,7 +13395,7 @@ int main (int argc, char **argv) size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t)); - const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *)); + const u8 **kernel_sources = (const u8 **) mymalloc (sizeof (u8 *)); if (force_jit_compilation == 0) { @@ -13387,9 +13413,9 @@ int main (int argc, char **argv) clGetProgramInfo (device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - unsigned char *binary = (unsigned char *) mymalloc (binary_size); + u8 *binary = (u8 *) mymalloc (binary_size); - clGetProgramInfo (device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); + clGetProgramInfo (device_param->program, CL_PROGRAM_BINARIES, binary_size, &binary, NULL); writeProgramBin (cached_file, binary, binary_size); @@ -13401,7 +13427,7 @@ int main (int argc, char **argv) load_kernel (cached_file, 1, kernel_lengths, kernel_sources); - device_param->program = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL); + device_param->program = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const u8 **) kernel_sources, NULL); hc_clBuildProgram (device_param->program, 1, &device_param->device, build_opts, NULL, NULL); } @@ -13500,7 +13526,7 @@ int main (int argc, char **argv) size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t)); - const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *)); + const u8 **kernel_sources = (const u8 **) mymalloc (sizeof (u8 *)); if (cached == 0) { @@ -13516,9 +13542,9 @@ int main (int argc, char **argv) clGetProgramInfo (device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - unsigned char *binary = (unsigned char *) mymalloc (binary_size); + u8 *binary = (u8 *) mymalloc (binary_size); - clGetProgramInfo (device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); + clGetProgramInfo (device_param->program_mp, CL_PROGRAM_BINARIES, binary_size, &binary, NULL); writeProgramBin (cached_file, binary, binary_size); @@ -13530,7 +13556,7 @@ int main (int argc, char **argv) load_kernel (cached_file, 1, kernel_lengths, kernel_sources); - device_param->program_mp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL); + device_param->program_mp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const u8 **) kernel_sources, NULL); hc_clBuildProgram (device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); } @@ -13613,7 +13639,7 @@ int main (int argc, char **argv) size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t)); - const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *)); + const u8 **kernel_sources = (const u8 **) mymalloc (sizeof (u8 *)); if (cached == 0) { @@ -13629,9 +13655,9 @@ int main (int argc, char **argv) clGetProgramInfo (device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - unsigned char *binary = (unsigned char *) mymalloc (binary_size); + u8 *binary = (u8 *) mymalloc (binary_size); - clGetProgramInfo (device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); + clGetProgramInfo (device_param->program_amp, CL_PROGRAM_BINARIES, binary_size, &binary, NULL); writeProgramBin (cached_file, binary, binary_size); @@ -13643,7 +13669,7 @@ int main (int argc, char **argv) load_kernel (cached_file, 1, kernel_lengths, kernel_sources); - device_param->program_amp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL); + device_param->program_amp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const u8 **) kernel_sources, NULL); hc_clBuildProgram (device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); } @@ -15315,6 +15341,8 @@ int main (int argc, char **argv) { hc_device_param_t *device_param = &data.devices_param[device_id]; + if (device_param->skipped) continue; + device_param->kernel_params_mp[0] = &device_param->d_combs; device_param->kernel_params_mp[1] = &device_param->d_root_css_buf; device_param->kernel_params_mp[2] = &device_param->d_markov_css_buf; @@ -15456,6 +15484,8 @@ int main (int argc, char **argv) { hc_device_param_t *device_param = &data.devices_param[device_id]; + if (device_param->skipped) continue; + device_param->speed_pos = 0; memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (u64)); @@ -15822,6 +15852,8 @@ int main (int argc, char **argv) { hc_device_param_t *device_param = &data.devices_param[device_id]; + if (device_param->skipped) continue; + device_param->kernel_params_mp_l[0] = &device_param->d_pws_buf; device_param->kernel_params_mp_l[1] = &device_param->d_root_css_buf; device_param->kernel_params_mp_l[2] = &device_param->d_markov_css_buf; @@ -16021,7 +16053,7 @@ int main (int argc, char **argv) { hc_device_param_t *device_param = &devices_param[device_id]; - device_param->device_id = device_id; + if (device_param->skipped) continue; if (wordlist_mode == WL_MODE_STDIN) { @@ -16262,6 +16294,8 @@ int main (int argc, char **argv) { hc_device_param_t *device_param = &data.devices_param[device_id]; + if (device_param->skipped) continue; + local_free (device_param->result); local_free (device_param->pw_caches); @@ -16336,17 +16370,21 @@ int main (int argc, char **argv) { hc_thread_mutex_lock (mux_adl); - for (uint i = 0; i < data.devices_cnt; i++) + for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { - if (data.hm_device[i].fan_supported == 1) + hc_device_param_t *device_param = &data.devices_param[device_id]; + + if (device_param->skipped) continue; + + if (data.hm_device[device_id].fan_supported == 1) { - int fanspeed = temp_retain_fanspeed_value[i]; + int fanspeed = temp_retain_fanspeed_value[device_id]; if (fanspeed == -1) continue; - int rc = hm_set_fanspeed_with_device_id_amd (i, fanspeed); + int rc = hm_set_fanspeed_with_device_id_amd (device_id, fanspeed); - if (rc == -1) log_info ("WARNING: Failed to restore default fan speed for gpu number: %i:", i); + if (rc == -1) log_info ("WARNING: Failed to restore default fan speed for gpu number: %i:", device_id); } } @@ -16360,15 +16398,19 @@ int main (int argc, char **argv) { hc_thread_mutex_lock (mux_adl); - for (uint i = 0; i < data.devices_cnt; i++) + for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { - if (data.hm_device[i].od_version == 6) + hc_device_param_t *device_param = &data.devices_param[device_id]; + + if (device_param->skipped) continue; + + if (data.hm_device[device_id].od_version == 6) { // check powertune capabilities first, if not available then skip device int powertune_supported = 0; - if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll_amd, data.hm_device[i].adapter_index.amd, &powertune_supported)) != ADL_OK) + if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll_amd, data.hm_device[device_id].adapter_index.amd, &powertune_supported)) != ADL_OK) { log_error ("ERROR: Failed to get ADL PowerControl Capabilities"); @@ -16379,7 +16421,7 @@ int main (int argc, char **argv) { // powercontrol settings - if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll_amd, data.hm_device[i].adapter_index.amd, od_power_control_status[i])) != ADL_OK) + if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll_amd, data.hm_device[device_id].adapter_index.amd, od_power_control_status[device_id])) != ADL_OK) { log_info ("ERROR: Failed to restore the ADL PowerControl values"); @@ -16392,12 +16434,12 @@ int main (int argc, char **argv) performance_state->iNumberOfPerformanceLevels = 2; - performance_state->aLevels[0].iEngineClock = od_clock_mem_status[i].state.aLevels[0].iEngineClock; - performance_state->aLevels[1].iEngineClock = od_clock_mem_status[i].state.aLevels[1].iEngineClock; - 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; + performance_state->aLevels[0].iEngineClock = od_clock_mem_status[device_id].state.aLevels[0].iEngineClock; + performance_state->aLevels[1].iEngineClock = od_clock_mem_status[device_id].state.aLevels[1].iEngineClock; + performance_state->aLevels[0].iMemoryClock = od_clock_mem_status[device_id].state.aLevels[0].iMemoryClock; + performance_state->aLevels[1].iMemoryClock = od_clock_mem_status[device_id].state.aLevels[1].iMemoryClock; - if ((hc_ADL_Overdrive_State_Set (data.hm_dll_amd, data.hm_device[i].adapter_index.amd, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK) + if ((hc_ADL_Overdrive_State_Set (data.hm_dll_amd, data.hm_device[device_id].adapter_index.amd, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK) { log_info ("ERROR: Failed to restore ADL performance state"); diff --git a/src/shared.c b/src/shared.c index 28ef1b3..6530bbd 100644 --- a/src/shared.c +++ b/src/shared.c @@ -5116,7 +5116,7 @@ uint setup_opencl_platforms_filter (char *opencl_platforms) { int platform = atoi (next); - if (platform < 1 || platform > 31) + if (platform < 1 || platform > 32) { log_error ("ERROR: invalid OpenCL platform %u specified", platform); @@ -5137,73 +5137,77 @@ uint setup_opencl_platforms_filter (char *opencl_platforms) return opencl_platforms_filter; } -cl_device_type setup_device_types_filter (char *opencl_device_types) +u32 setup_devices_filter (char *opencl_devices) { - cl_device_type device_types_filter = 0; + u32 devices_filter = 0; - if (opencl_device_types) + if (opencl_devices) { - char *device_types = strdup (opencl_device_types); + char *devices = strdup (opencl_devices); - char *next = strtok (device_types, ","); + char *next = strtok (devices, ","); do { - int device_type = atoi (next); + int device_id = atoi (next); - if (device_type < 1 || device_type > 3) + if (device_id < 1 || device_id > 32) { - log_error ("ERROR: invalid device_type %u specified", device_type); + log_error ("ERROR: invalid device_id %u specified", device_id); exit (-1); } - device_types_filter |= 1 << device_type; + devices_filter |= 1 << (device_id - 1); } while ((next = strtok (NULL, ",")) != NULL); - free (device_types); + free (devices); } else { - // Do not use CPU by default, this often reduces GPU performance because - // the CPU is to busy to handle GPU synchronization - - device_types_filter = CL_DEVICE_TYPE_ALL & ~CL_DEVICE_TYPE_CPU; + devices_filter = -1; } - return device_types_filter; + return devices_filter; } -uint devices_to_devicemask (char *opencl_devices) +cl_device_type setup_device_types_filter (char *opencl_device_types) { - uint opencl_devicemask = 0; + cl_device_type device_types_filter = 0; - if (opencl_devices) + if (opencl_device_types) { - char *devices = strdup (opencl_devices); + char *device_types = strdup (opencl_device_types); - char *next = strtok (devices, ","); + char *next = strtok (device_types, ","); do { - uint device_id = atoi (next); + int device_type = atoi (next); - if (device_id < 1 || device_id > 8) + if (device_type < 1 || device_type > 3) { - log_error ("ERROR: invalid device_id %u specified", device_id); + log_error ("ERROR: invalid device_type %u specified", device_type); exit (-1); } - opencl_devicemask |= 1 << (device_id - 1); + device_types_filter |= 1 << device_type; } while ((next = strtok (NULL, ",")) != NULL); - free (devices); + free (device_types); } + else + { + // Do not use CPU by default, this often reduces GPU performance because + // the CPU is to busy to handle GPU synchronization - return opencl_devicemask; + device_types_filter = CL_DEVICE_TYPE_ALL & ~CL_DEVICE_TYPE_CPU; + } + + return device_types_filter; } u32 get_random_num (const u32 min, const u32 max) @@ -8859,6 +8863,8 @@ u64 get_lowest_words_done () { hc_device_param_t *device_param = &data.devices_param[device_id]; + if (device_param->skipped) continue; + const u64 words_done = device_param->words_done; if (words_done < words_cur) words_cur = words_done;