Commit 4beade3772be0299f81bf5525a0d15914cc9343a

Con Kolivas 2011-08-18T22:42:37

Retain the program immediately after it's created from source.

diff --git a/ocl.c b/ocl.c
index 5625bbb..f994fa2 100644
--- a/ocl.c
+++ b/ocl.c
@@ -494,12 +494,17 @@ build:
 		applog(LOG_DEBUG, "cl_amd_media_ops not found, will not BFI_INT patch");
 
 	clState->program = clCreateProgramWithSource(clState->context, 1, (const char **)&source, sourceSize, &status);
-	if (status != CL_SUCCESS)
-	{
+	if (status != CL_SUCCESS) {
 		applog(LOG_ERR, "Error: Loading Binary into cl_program (clCreateProgramWithSource)");
 		return NULL;
 	}
 
+	clRetainProgram(clState->program);
+	if (status != CL_SUCCESS) {
+		applog(LOG_ERR, "Error: Retaining Program (clRetainProgram)");
+		return NULL;
+	}
+
 	/* create a cl program executable for all the devices specified */
 	char CompilerOptions[256];
 	sprintf(CompilerOptions, "%s%i", "-DWORKSIZE=", (int)clState->work_size);
@@ -520,12 +525,6 @@ build:
 		return NULL;
 	}
 
-	clRetainProgram(clState->program);
-	if (status != CL_SUCCESS) {
-		applog(LOG_ERR, "Error: Retaining Program (clRetainProgram)");
-		return NULL;
-	}
-
 	status = clGetProgramInfo( clState->program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t)*nDevices, binary_sizes, NULL );
 	if (unlikely(status != CL_SUCCESS)) {
 		applog(LOG_ERR, "Error: Getting program info CL_PROGRAM_BINARY_SIZES. (clGetPlatformInfo)");