diff --git a/include/terminal.h b/include/terminal.h index ddb5dc3a1..2c23101ea 100644 --- a/include/terminal.h +++ b/include/terminal.h @@ -42,6 +42,8 @@ int tty_getchar(); int tty_fix(); void opencl_info (hashcat_ctx_t *hashcat_ctx); +void opencl_info_compact (hashcat_ctx_t *hashcat_ctx); + void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx); void status_display (hashcat_ctx_t *hashcat_ctx); void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index bc61e4745..2c8cdf6ab 100644 --- a/include/types.h +++ b/include/types.h @@ -850,6 +850,7 @@ typedef struct opencl_ctx char **platforms_vendor; char **platforms_name; char **platforms_version; + bool *platforms_skipped; cl_uint platform_devices_cnt; cl_device_id *platform_devices; diff --git a/src/main.c b/src/main.c index 5b6069f6e..714459165 100644 --- a/src/main.c +++ b/src/main.c @@ -913,6 +913,8 @@ int main (int argc, char **argv) { // now execute hashcat + opencl_info_compact (hashcat_ctx); + rc_final = hashcat_session_execute (hashcat_ctx); } } diff --git a/src/opencl.c b/src/opencl.c index b0f829c3d..e557fa758 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -1969,6 +1969,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) char **platforms_vendor = (char **) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (char *)); VERIFY_PTR (platforms_vendor); char **platforms_name = (char **) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (char *)); VERIFY_PTR (platforms_name); char **platforms_version = (char **) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (char *)); VERIFY_PTR (platforms_version); + bool *platforms_skipped = (bool *) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (bool)); VERIFY_PTR (platforms_skipped); cl_uint platforms_cnt = 0; cl_platform_id *platforms = (cl_platform_id *) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (cl_platform_id)); VERIFY_PTR (platforms); cl_uint platform_devices_cnt = 0; @@ -2062,6 +2063,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) opencl_ctx->platforms_vendor = platforms_vendor; opencl_ctx->platforms_name = platforms_name; opencl_ctx->platforms_version = platforms_version; + opencl_ctx->platforms_skipped = platforms_skipped; opencl_ctx->platforms_cnt = platforms_cnt; opencl_ctx->platforms = platforms; opencl_ctx->platform_devices_cnt = platform_devices_cnt; @@ -2205,7 +2207,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) platform_vendor_id = VENDOR_ID_GENERIC; } - u32 platform_skipped = ((opencl_ctx->opencl_platforms_filter & (1u << platform_id)) == 0); + bool platform_skipped = ((opencl_ctx->opencl_platforms_filter & (1u << platform_id)) == 0); CL_rc = hc_clGetDeviceIDs (hashcat_ctx, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); @@ -2215,38 +2217,12 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) //return -1; - platform_skipped = 2; + platform_skipped = true; } - if ((user_options->benchmark == true || user_options->speed_only == true || user_options->quiet == false)) - { - if (user_options->machine_readable == false) - { - if (platform_skipped == 0) - { - const int len = event_log_info (hashcat_ctx, "OpenCL Platform #%u: %s", platform_id + 1, platform_vendor); - - char line[256] = { 0 }; - - for (int i = 0; i < len; i++) line[i] = '='; - - event_log_info (hashcat_ctx, line); - } - else if (platform_skipped == 1) - { - event_log_info (hashcat_ctx, "OpenCL Platform #%u: %s, skipped", platform_id + 1, platform_vendor); - event_log_info (hashcat_ctx, ""); - } - else if (platform_skipped == 2) - { - event_log_info (hashcat_ctx, "OpenCL Platform #%u: %s, skipped! No OpenCL compatible devices found", platform_id + 1, platform_vendor); - event_log_info (hashcat_ctx, ""); - } - } - } + opencl_ctx->platforms_skipped[platform_id] = platform_skipped; - if (platform_skipped == 1) continue; - if (platform_skipped == 2) continue; + if (platform_skipped == true) continue; hc_device_param_t *devices_param = opencl_ctx->devices_param; @@ -2669,30 +2645,6 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) } } - // display results - - if ((user_options->benchmark == true || user_options->speed_only == true || user_options->quiet == false)) - { - if (user_options->machine_readable == false) - { - if (device_param->skipped == 0) - { - event_log_info (hashcat_ctx, "* Device #%u: %s, %lu/%lu MB allocatable, %uMCU", - device_id + 1, - device_name, - (unsigned int) (device_maxmem_alloc / 1024 / 1024), - (unsigned int) (device_global_mem / 1024 / 1024), - (unsigned int) device_processors); - } - else - { - event_log_info (hashcat_ctx, "* Device #%u: %s, skipped", - device_id + 1, - device_name); - } - } - } - // common driver check if (device_param->skipped == 0) @@ -2768,14 +2720,6 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) devices_cnt++; } - - if ((user_options->benchmark == true || user_options->speed_only == true || user_options->quiet == false)) - { - if (user_options->machine_readable == false) - { - event_log_info (hashcat_ctx, ""); - } - } } if (devices_active == 0) diff --git a/src/terminal.c b/src/terminal.c index f018782d3..8256c5906 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -484,21 +484,21 @@ void opencl_info (hashcat_ctx_t *hashcat_ctx) for (cl_uint devices_idx = 0; devices_idx < devices_cnt; devices_idx++) { - const hc_device_param_t *hc_device_param = opencl_ctx->devices_param + devices_idx; - - if (hc_device_param->platform != platform_id) continue; - - cl_device_type device_type = hc_device_param->device_type; - cl_uint device_vendor_id = hc_device_param->device_vendor_id; - char *device_vendor = hc_device_param->device_vendor; - char *device_name = hc_device_param->device_name; - u32 device_processors = hc_device_param->device_processors; - u32 device_maxclock_frequency = hc_device_param->device_maxclock_frequency; - u64 device_maxmem_alloc = hc_device_param->device_maxmem_alloc; - u64 device_global_mem = hc_device_param->device_global_mem; - char *device_opencl_version = hc_device_param->device_opencl_version; - char *device_version = hc_device_param->device_version; - char *driver_version = hc_device_param->driver_version; + const hc_device_param_t *device_param = opencl_ctx->devices_param + devices_idx; + + if (device_param->platform != platform_id) continue; + + cl_device_type device_type = device_param->device_type; + cl_uint device_vendor_id = device_param->device_vendor_id; + char *device_vendor = device_param->device_vendor; + char *device_name = device_param->device_name; + u32 device_processors = device_param->device_processors; + u32 device_maxclock_frequency = device_param->device_maxclock_frequency; + u64 device_maxmem_alloc = device_param->device_maxmem_alloc; + u64 device_global_mem = device_param->device_global_mem; + char *device_opencl_version = device_param->device_opencl_version; + char *device_version = device_param->device_version; + char *driver_version = device_param->driver_version; event_log_info (hashcat_ctx, " Device ID #%u", devices_idx + 1); event_log_info (hashcat_ctx, " Type : %s", ((device_type & CL_DEVICE_TYPE_CPU) ? "CPU" : ((device_type & CL_DEVICE_TYPE_GPU) ? "GPU" : "Accelerator"))); @@ -516,6 +516,75 @@ void opencl_info (hashcat_ctx_t *hashcat_ctx) } } +void opencl_info_compact (hashcat_ctx_t *hashcat_ctx) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return; + if (user_options->machine_readable == true) return; + + cl_uint platforms_cnt = opencl_ctx->platforms_cnt; + cl_platform_id *platforms = opencl_ctx->platforms; + char **platforms_vendor = opencl_ctx->platforms_vendor; + bool *platforms_skipped = opencl_ctx->platforms_skipped; + cl_uint devices_cnt = opencl_ctx->devices_cnt; + + for (cl_uint platforms_idx = 0; platforms_idx < platforms_cnt; platforms_idx++) + { + cl_platform_id platform_id = platforms[platforms_idx]; + char *platform_vendor = platforms_vendor[platforms_idx]; + bool platform_skipped = platforms_skipped[platforms_idx]; + + if (platform_skipped == false) + { + const int len = event_log_info (hashcat_ctx, "OpenCL Platform #%u: %s", platforms_idx + 1, platform_vendor); + + char line[HCBUFSIZ_TINY]; + + memset (line, '=', len); + + line[len] = 0; + + event_log_info (hashcat_ctx, line); + } + else + { + event_log_info (hashcat_ctx, "OpenCL Platform #%u: %s, skipped or no OpenCL compatible devices found", platforms_idx + 1, platform_vendor); + } + + for (cl_uint devices_idx = 0; devices_idx < devices_cnt; devices_idx++) + { + const hc_device_param_t *device_param = opencl_ctx->devices_param + devices_idx; + + if (device_param->platform != platform_id) continue; + + char *device_name = device_param->device_name; + u32 device_processors = device_param->device_processors; + u64 device_maxmem_alloc = device_param->device_maxmem_alloc; + u64 device_global_mem = device_param->device_global_mem; + + if (device_param->skipped == false) + { + event_log_info (hashcat_ctx, "* Device #%u: %s, %lu/%lu MB allocatable, %uMCU", + devices_idx + 1, + device_name, + (unsigned int) (device_maxmem_alloc / 1024 / 1024), + (unsigned int) (device_global_mem / 1024 / 1024), + (unsigned int) device_processors); + } + else + { + event_log_info (hashcat_ctx, "* Device #%u: %s, skipped", + devices_idx + 1, + device_name); + } + } + + event_log_info (hashcat_ctx, ""); + } +} + void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) { const user_options_t *user_options = hashcat_ctx->user_options;