Add debugging output if buffer allocation fails for scrypt and round up bufsize to a multiple of 256.
diff --git a/ocl.c b/ocl.c
index d6e12c5..b7c8e5f 100644
--- a/ocl.c
+++ b/ocl.c
@@ -761,11 +761,22 @@ built:
if (opt_scrypt) {
size_t ipt = (1024 / gpus[gpu].lookup_gap + (1024 % gpus[gpu].lookup_gap > 0));
size_t bufsize = 128 * ipt * gpus[gpu].thread_concurrency;
- applog(LOG_DEBUG, "Creating scrypt buffer sized %d", bufsize);
- clState->CLbuffer0 = clCreateBuffer(clState->context, CL_MEM_READ_ONLY, 80, NULL, &status);
- clState->padbuffer8 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, bufsize, NULL, &status);
+ if (bufsize % 256)
+ bufsize += (256 - bufsize % 256);
+ applog(LOG_DEBUG, "Creating scrypt buffer sized %d", bufsize);
clState->padbufsize = bufsize;
+ clState->padbuffer8 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, bufsize, NULL, &status);
+ if (status != CL_SUCCESS) {
+ applog(LOG_ERR, "Error %d: clCreateBuffer (padbuffer8), decrease CT or increase LG", status);
+ return NULL;
+ }
+
+ clState->CLbuffer0 = clCreateBuffer(clState->context, CL_MEM_READ_ONLY, 128, NULL, &status);
+ if (status != CL_SUCCESS) {
+ applog(LOG_ERR, "Error %d: clCreateBuffer (CLbuffer0)", status);
+ return NULL;
+ }
}
#endif
clState->outputBuffer = clCreateBuffer(clState->context, CL_MEM_WRITE_ONLY, BUFFERSIZE, NULL, &status);