1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-02-20 11:32:12 +00:00

Set vector width size for CUDA

This commit is contained in:
Jens Steube 2019-05-01 18:20:19 +02:00
parent 3c4f4df771
commit 456c57a6d0
2 changed files with 64 additions and 28 deletions

View File

@ -1016,7 +1016,7 @@ typedef struct hc_device_param
st_status_t st_status; st_status_t st_status;
u32 vector_width; int vector_width;
u32 kernel_wgs1; u32 kernel_wgs1;
u32 kernel_wgs12; u32 kernel_wgs12;

View File

@ -5404,7 +5404,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
// vector_width // vector_width
cl_uint vector_width; int vector_width;
if (user_options->backend_vector_width_chgd == false) if (user_options->backend_vector_width_chgd == false)
{ {
@ -5424,18 +5424,38 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (tuningdb_entry == NULL || tuningdb_entry->vector_width == -1) if (tuningdb_entry == NULL || tuningdb_entry->vector_width == -1)
{ {
if (hashconfig->opti_type & OPTI_TYPE_USES_BITS_64) if (hashconfig->opti_type & OPTI_TYPE_USES_BITS_64)
{
if (device_param->is_cuda == true)
{
// cuda does not support this query
vector_width = 1;
}
if (device_param->is_opencl == true)
{ {
CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, sizeof (vector_width), &vector_width, NULL); CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, sizeof (vector_width), &vector_width, NULL);
if (CL_rc == -1) return -1; if (CL_rc == -1) return -1;
} }
}
else else
{
if (device_param->is_cuda == true)
{
// cuda does not support this query
vector_width = 1;
}
if (device_param->is_opencl == true)
{ {
CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, sizeof (vector_width), &vector_width, NULL); CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, sizeof (vector_width), &vector_width, NULL);
if (CL_rc == -1) return -1; if (CL_rc == -1) return -1;
} }
} }
}
else else
{ {
vector_width = (cl_uint) tuningdb_entry->vector_width; vector_width = (cl_uint) tuningdb_entry->vector_width;
@ -5603,6 +5623,13 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
* create context for each device * create context for each device
*/ */
if (device_param->is_cuda == true)
{
}
if (device_param->is_opencl == true)
{
/* /*
cl_context_properties properties[3]; cl_context_properties properties[3];
@ -5627,6 +5654,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
CL_rc = hc_clCreateCommandQueue (hashcat_ctx, device_param->context, device_param->opencl_device, CL_QUEUE_PROFILING_ENABLE, &device_param->command_queue); CL_rc = hc_clCreateCommandQueue (hashcat_ctx, device_param->context, device_param->opencl_device, CL_QUEUE_PROFILING_ENABLE, &device_param->command_queue);
if (CL_rc == -1) return -1; if (CL_rc == -1) return -1;
}
/** /**
* create input buffers on device : calculate size of fixed memory buffers * create input buffers on device : calculate size of fixed memory buffers
@ -5902,7 +5930,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (rc_read_kernel == false) return -1; if (rc_read_kernel == false) return -1;
if (backend_ctx->nvrtc) if (device_param->is_cuda)
{ {
nvrtcProgram program; nvrtcProgram program;
@ -5982,7 +6010,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (rc_nvrtcDestroyProgram == -1) return -1; if (rc_nvrtcDestroyProgram == -1) return -1;
} }
if (1) // later just else if (device_param->is_opencl)
{ {
CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program);
@ -6052,6 +6080,13 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (rc_read_kernel == false) return -1; if (rc_read_kernel == false) return -1;
if (device_param->is_cuda)
{
}
if (device_param->is_opencl)
{
CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->opencl_device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program); CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->opencl_device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program);
if (CL_rc == -1) return -1; if (CL_rc == -1) return -1;
@ -6060,6 +6095,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (CL_rc == -1) return -1; if (CL_rc == -1) return -1;
} }
}
hcfree (kernel_sources[0]); hcfree (kernel_sources[0]);
} }