From: jsteube Date: Mon, 4 Jan 2016 19:12:34 +0000 (+0100) Subject: Preparation for distinguish between OpenCL device types at runtime (mostly for HMS) X-Git-Tag: v3.00-beta~553 X-Git-Url: https://www.flypig.org.uk/git/?a=commitdiff_plain;h=8baf705f6aa137b9fd38c58d7cf88d1149f61054;p=hashcat.git Preparation for distinguish between OpenCL device types at runtime (mostly for HMS) --- diff --git a/include/types.h b/include/types.h index 2bd32f3..8daff5f 100644 --- a/include/types.h +++ b/include/types.h @@ -879,6 +879,7 @@ struct __hc_device_param char *driver_version; cl_device_id device; + cl_device_type device_type; cl_kernel kernel1; cl_kernel kernel12; diff --git a/src/oclHashcat.c b/src/oclHashcat.c index bf40161..ecaf740 100644 --- a/src/oclHashcat.c +++ b/src/oclHashcat.c @@ -12722,6 +12722,12 @@ int main (int argc, char **argv) device_param->device = device; + cl_device_type device_type = 0; + + hc_clGetDeviceInfo (device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); + + device_param->device_type = device_type; + cl_uint max_compute_units = 0; hc_clGetDeviceInfo (device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL); @@ -12758,120 +12764,119 @@ int main (int argc, char **argv) device_param->driver_version = mystrdup (tmp); - if (vendor_id == VENDOR_ID_AMD) + if (device_type == CL_DEVICE_TYPE_CPU) { - cl_uint gpu_processor_cores = 0; - - #define CL_DEVICE_WAVEFRONT_WIDTH_AMD 0x4043 - - hc_clGetDeviceInfo (device, CL_DEVICE_WAVEFRONT_WIDTH_AMD, sizeof (gpu_processor_cores), &gpu_processor_cores, NULL); + cl_uint gpu_processor_cores = 1; device_param->gpu_processor_cores = gpu_processor_cores; } - if (vendor_id == VENDOR_ID_NV) + if (device_type == CL_DEVICE_TYPE_GPU) { - cl_uint kernel_exec_timeout = 0; + if (vendor_id == VENDOR_ID_AMD) + { + cl_uint gpu_processor_cores = 0; - #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 + #define CL_DEVICE_WAVEFRONT_WIDTH_AMD 0x4043 - hc_clGetDeviceInfo (device, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, sizeof (kernel_exec_timeout), &kernel_exec_timeout, NULL); + hc_clGetDeviceInfo (device, CL_DEVICE_WAVEFRONT_WIDTH_AMD, sizeof (gpu_processor_cores), &gpu_processor_cores, NULL); - device_param->kernel_exec_timeout = kernel_exec_timeout; + device_param->gpu_processor_cores = gpu_processor_cores; + } - cl_uint gpu_processor_cores = 0; + if (vendor_id == VENDOR_ID_NV) + { + cl_uint kernel_exec_timeout = 0; - #define CL_DEVICE_WARP_SIZE_NV 0x4003 + #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 - hc_clGetDeviceInfo (device, CL_DEVICE_WARP_SIZE_NV, sizeof (gpu_processor_cores), &gpu_processor_cores, NULL); + hc_clGetDeviceInfo (device, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, sizeof (kernel_exec_timeout), &kernel_exec_timeout, NULL); - device_param->gpu_processor_cores = gpu_processor_cores; + device_param->kernel_exec_timeout = kernel_exec_timeout; - cl_uint sm_minor = 0; - cl_uint sm_major = 0; + cl_uint gpu_processor_cores = 0; - #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 - #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 + #define CL_DEVICE_WARP_SIZE_NV 0x4003 - 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); + hc_clGetDeviceInfo (device, CL_DEVICE_WARP_SIZE_NV, sizeof (gpu_processor_cores), &gpu_processor_cores, NULL); - device_param->sm_minor = sm_minor; - device_param->sm_major = sm_major; - } + device_param->gpu_processor_cores = gpu_processor_cores; - if (vendor_id == VENDOR_ID_POCL) - { - cl_uint gpu_processor_cores = 1; + cl_uint sm_minor = 0; + cl_uint sm_major = 0; - device_param->gpu_processor_cores = gpu_processor_cores; - } + #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 + #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 - if (vendor_id == VENDOR_ID_UNKNOWN) - { - cl_uint gpu_processor_cores = 1; + 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); - device_param->gpu_processor_cores = gpu_processor_cores; + device_param->sm_minor = sm_minor; + device_param->sm_major = sm_major; + } } /** * common driver check */ - if (vendor_id == VENDOR_ID_NV) + if (device_type == CL_DEVICE_TYPE_GPU) { - if (device_param->kernel_exec_timeout != 0) + if (vendor_id == VENDOR_ID_NV) { - 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"); + 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"); + } } - } - - if (vendor_id == VENDOR_ID_AMD) - { - int catalyst_check = (force == 1) ? 0 : 1; - int catalyst_warn = 0; + if (vendor_id == VENDOR_ID_AMD) + { + int catalyst_check = (force == 1) ? 0 : 1; - int catalyst_broken = 0; + int catalyst_warn = 0; - if (catalyst_check == 1) - { - catalyst_warn = 1; + int catalyst_broken = 0; - // v14.9 and higher - if ((atoi (device_param->device_version) >= 1573) - && (atoi (device_param->driver_version) >= 1573)) + if (catalyst_check == 1) { - catalyst_warn = 0; - } + catalyst_warn = 1; - catalyst_check = 0; - } + // v14.9 and higher + if ((atoi (device_param->device_version) >= 1573) + && (atoi (device_param->driver_version) >= 1573)) + { + catalyst_warn = 0; + } - if (catalyst_broken == 1) - { - log_error (""); - log_error ("ATTENTION! The installed GPU 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"); + catalyst_check = 0; + } - return (-1); - } + if (catalyst_broken == 1) + { + log_error (""); + log_error ("ATTENTION! The installed GPU 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 (catalyst_warn == 1) - { - log_error (""); - log_error ("ATTENTION! Unsupported or incorrect installed GPU driver detected!"); - log_error ("You are STRONGLY encouraged to use the official supported GPU driver for good reasons"); - log_error ("See oclHashcat's homepage for official supported GPU 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"); + return (-1); + } - return (-1); + if (catalyst_warn == 1) + { + log_error (""); + log_error ("ATTENTION! Unsupported or incorrect installed GPU driver detected!"); + log_error ("You are STRONGLY encouraged to use the official supported GPU driver for good reasons"); + log_error ("See oclHashcat's homepage for official supported GPU 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"); + + return (-1); + } } } }