mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-27 17:08:12 +00:00
Transfer only a few byte should be enough to force the runtime to actually allocate the memory
This commit is contained in:
parent
242d991def
commit
9f54c3dd14
31
src/opencl.c
31
src/opencl.c
@ -4284,8 +4284,6 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
cl_mem *tmp_device = (cl_mem *) hccalloc (MAX_ALLOC_CHECKS_CNT, sizeof (cl_mem));
|
cl_mem *tmp_device = (cl_mem *) hccalloc (MAX_ALLOC_CHECKS_CNT, sizeof (cl_mem));
|
||||||
|
|
||||||
char *tmp_host = (char *) hcmalloc (MAX_ALLOC_CHECKS_SIZE);
|
|
||||||
|
|
||||||
u64 c;
|
u64 c;
|
||||||
|
|
||||||
for (c = 0; c < MAX_ALLOC_CHECKS_CNT; c++)
|
for (c = 0; c < MAX_ALLOC_CHECKS_CNT; c++)
|
||||||
@ -4305,11 +4303,23 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CL_err = ocl->clEnqueueReadBuffer (device_param->command_queue, tmp_device[c], CL_TRUE, 0, MAX_ALLOC_CHECKS_SIZE, tmp_host, 0, NULL, NULL);
|
// transfer only a few byte should be enough to force the runtime to actually allocate the memory
|
||||||
|
|
||||||
|
u8 tmp_host[8];
|
||||||
|
|
||||||
|
CL_err = ocl->clEnqueueReadBuffer (device_param->command_queue, tmp_device[c], CL_TRUE, 0, sizeof (tmp_host), tmp_host, 0, NULL, NULL);
|
||||||
|
|
||||||
if (CL_err != CL_SUCCESS) break;
|
if (CL_err != CL_SUCCESS) break;
|
||||||
|
|
||||||
CL_err = ocl->clEnqueueWriteBuffer (device_param->command_queue, tmp_device[c], CL_TRUE, 0, MAX_ALLOC_CHECKS_SIZE, tmp_host, 0, NULL, NULL);
|
CL_err = ocl->clEnqueueWriteBuffer (device_param->command_queue, tmp_device[c], CL_TRUE, 0, sizeof (tmp_host), tmp_host, 0, NULL, NULL);
|
||||||
|
|
||||||
|
if (CL_err != CL_SUCCESS) break;
|
||||||
|
|
||||||
|
CL_err = ocl->clEnqueueReadBuffer (device_param->command_queue, tmp_device[c], CL_TRUE, MAX_ALLOC_CHECKS_SIZE - sizeof (tmp_host), sizeof (tmp_host), tmp_host, 0, NULL, NULL);
|
||||||
|
|
||||||
|
if (CL_err != CL_SUCCESS) break;
|
||||||
|
|
||||||
|
CL_err = ocl->clEnqueueWriteBuffer (device_param->command_queue, tmp_device[c], CL_TRUE, MAX_ALLOC_CHECKS_SIZE - sizeof (tmp_host), sizeof (tmp_host), tmp_host, 0, NULL, NULL);
|
||||||
|
|
||||||
if (CL_err != CL_SUCCESS) break;
|
if (CL_err != CL_SUCCESS) break;
|
||||||
}
|
}
|
||||||
@ -4318,16 +4328,17 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
|
|
||||||
u64 r;
|
for (c = 0; c < MAX_ALLOC_CHECKS_CNT; c++)
|
||||||
|
|
||||||
for (r = 0; r < c; r++)
|
|
||||||
{
|
{
|
||||||
CL_rc = hc_clReleaseMemObject (hashcat_ctx, tmp_device[r]);
|
if (((c + 1 + 1) * MAX_ALLOC_CHECKS_SIZE) >= device_param->device_global_mem) break;
|
||||||
|
|
||||||
|
if (tmp_device[c] != NULL)
|
||||||
|
{
|
||||||
|
CL_rc = hc_clReleaseMemObject (hashcat_ctx, tmp_device[c]);
|
||||||
|
|
||||||
if (CL_rc == -1) return -1;
|
if (CL_rc == -1) return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
hcfree (tmp_host);
|
|
||||||
|
|
||||||
hcfree (tmp_device);
|
hcfree (tmp_device);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user