1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-05 23:10:00 +00:00

Emulate effect of reqd_work_group_size() in CUDA

This commit is contained in:
Jens Steube 2019-06-06 17:49:41 +02:00
parent 5920bd7f78
commit 0568c0746a
2 changed files with 31 additions and 20 deletions

View File

@ -68,7 +68,7 @@ int hc_cuMemcpyHtoD (hashcat_ctx_t *hashcat_ctx, CUdeviceptr dstDev
int hc_cuMemFree (hashcat_ctx_t *hashcat_ctx, CUdeviceptr dptr);
int hc_cuModuleGetFunction (hashcat_ctx_t *hashcat_ctx, CUfunction *hfunc, CUmodule hmod, const char *name);
int hc_cuModuleLoadDataEx (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const void *image, unsigned int numOptions, CUjit_option *options, void **optionValues);
int hc_cuModuleLoadDataExLog (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const void *image);
int hc_cuModuleLoadDataExLog (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const void *image, const u64 threads_per_block);
int hc_cuModuleUnload (hashcat_ctx_t *hashcat_ctx, CUmodule hmod);
int hc_cuStreamCreate (hashcat_ctx_t *hashcat_ctx, CUstream *phStream, unsigned int Flags);
int hc_cuStreamDestroy (hashcat_ctx_t *hashcat_ctx, CUstream hStream);

View File

@ -1297,32 +1297,45 @@ int hc_cuModuleLoadDataEx (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const v
return 0;
}
int hc_cuModuleLoadDataExLog (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const void *image)
int hc_cuModuleLoadDataExLog (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const void *image, const u64 threads_per_block)
{
#define LOG_SIZE 8192
char *info_log = hcmalloc (LOG_SIZE);
char *error_log = hcmalloc (LOG_SIZE);
CUjit_option opts[6];
CUjit_option opts[7];
void *vals[7];
opts[0] = CU_JIT_TARGET_FROM_CUCONTEXT;
opts[1] = CU_JIT_LOG_VERBOSE;
opts[2] = CU_JIT_INFO_LOG_BUFFER;
opts[3] = CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES;
opts[4] = CU_JIT_ERROR_LOG_BUFFER;
opts[5] = CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES;
void *vals[6];
vals[0] = (void *) 0;
opts[1] = CU_JIT_LOG_VERBOSE;
vals[1] = (void *) 1;
opts[2] = CU_JIT_INFO_LOG_BUFFER;
vals[2] = (void *) info_log;
opts[3] = CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES;
vals[3] = (void *) LOG_SIZE;
opts[4] = CU_JIT_ERROR_LOG_BUFFER;
vals[4] = (void *) error_log;
opts[5] = CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES;
vals[5] = (void *) LOG_SIZE;
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataEx (hashcat_ctx, module, image, 6, opts, vals);
int opts_cnt = 6;
if (threads_per_block)
{
opts[6] = CU_JIT_THREADS_PER_BLOCK;
vals[6] = (void *) threads_per_block;
opts_cnt++;
}
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataEx (hashcat_ctx, module, image, opts_cnt, opts, vals);
#if defined (DEBUG)
printf ("cuModuleLoadDataEx() Info Log (%d):\n%s\n\n", (int) strlen (info_log), info_log);
@ -7765,9 +7778,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (rc_nvrtcDestroyProgram == -1) return -1;
// tbd: check for some useful options
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module, binary);
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module, binary, device_param->kernel_threads_max);
if (rc_cuModuleLoadDataEx == -1) return -1;
@ -7853,7 +7864,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (device_param->is_cuda == true)
{
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module, kernel_sources[0]);
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module, kernel_sources[0], device_param->kernel_threads_max);
if (rc_cuModuleLoadDataEx == -1) return -1;
}
@ -8021,7 +8032,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
// tbd: check for some useful options
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_mp, binary);
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_mp, binary, 0);
if (rc_cuModuleLoadDataEx == -1) return -1;
@ -8105,7 +8116,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (device_param->is_cuda == true)
{
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_mp, kernel_sources[0]);
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_mp, kernel_sources[0], 0);
if (rc_cuModuleLoadDataEx == -1) return -1;
}
@ -8276,7 +8287,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
// tbd: check for some useful options
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_amp, binary);
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_amp, binary, 0);
if (rc_cuModuleLoadDataEx == -1) return -1;
@ -8360,7 +8371,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (device_param->is_cuda == true)
{
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_amp, kernel_sources[0]);
const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_amp, kernel_sources[0], 0);
if (rc_cuModuleLoadDataEx == -1) return -1;
}