Commit 89eb1fa393730ac04edea6f6a7e3a8c9cf35f406

Con Kolivas 2012-07-23T17:41:31

Check the maximum allocable memory size per opencl device.

diff --git a/miner.h b/miner.h
index 95affeb..291574c 100644
--- a/miner.h
+++ b/miner.h
@@ -356,9 +356,11 @@ struct cgpu_info {
 	int virtual_adl;
 	int intensity;
 	bool dynamic;
+
 	cl_uint vwidth;
 	size_t work_size;
 	enum cl_kernels kernel;
+	cl_ulong max_alloc;
 
 #ifdef USE_SCRYPT
 	int lookup_gap;
diff --git a/ocl.c b/ocl.c
index b7c8e5f..880aaf7 100644
--- a/ocl.c
+++ b/ocl.c
@@ -363,6 +363,13 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
 	}
 	applog(LOG_DEBUG, "Max work group size reported %d", clState->max_work_size);
 
+	status = clGetDeviceInfo(devices[gpu], CL_DEVICE_MAX_MEM_ALLOC_SIZE , sizeof(cl_ulong), (void *)&gpus[gpu].max_alloc, NULL);
+	if (status != CL_SUCCESS) {
+		applog(LOG_ERR, "Error %d: Failed to clGetDeviceInfo when trying to get CL_DEVICE_MAX_MEM_ALLOC_SIZE", status);
+		return NULL;
+	}
+	applog(LOG_DEBUG, "Max mem alloc size is %u", gpus[gpu].max_alloc);
+
 	/* Create binary filename based on parameters passed to opencl
 	 * compiler to ensure we only load a binary that matches what would
 	 * have otherwise created. The filename is: