Retain the program immediately after it's created from source.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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)");