Browse Source

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

Con Kolivas 14 years ago
parent
commit
4beade3772
1 changed files with 7 additions and 8 deletions
  1. 7 8
      ocl.c

+ 7 - 8
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)");