|
|
@@ -339,6 +339,28 @@ int clDevicesNum(void) {
|
|
|
return most_devices;
|
|
|
}
|
|
|
|
|
|
+cl_int bfg_clBuildProgram(_clState * const clState, const cl_device_id const devid, const char * const CompilerOptions)
|
|
|
+{
|
|
|
+ cl_int status;
|
|
|
+
|
|
|
+ status = clBuildProgram(clState->program, 1, &devid, CompilerOptions, NULL, NULL);
|
|
|
+
|
|
|
+ if (status != CL_SUCCESS)
|
|
|
+ {
|
|
|
+ applog(LOG_ERR, "Error %d: Building Program (clBuildProgram)", status);
|
|
|
+ size_t logSize;
|
|
|
+ status = clGetProgramBuildInfo(clState->program, devid, CL_PROGRAM_BUILD_LOG, 0, NULL, &logSize);
|
|
|
+
|
|
|
+ char *log = malloc(logSize ?: 1);
|
|
|
+ status = clGetProgramBuildInfo(clState->program, devid, CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
|
|
|
+ if (logSize > 0 && log[0])
|
|
|
+ applog(LOG_ERR, "%s", log);
|
|
|
+ free(log);
|
|
|
+ }
|
|
|
+
|
|
|
+ return status;
|
|
|
+}
|
|
|
+
|
|
|
static int advance(char **area, unsigned *remaining, const char *marker)
|
|
|
{
|
|
|
char *find = memmem(*area, *remaining, marker, strlen(marker));
|
|
|
@@ -531,6 +553,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
|
|
|
find = strstr(extensions, camo);
|
|
|
if (find)
|
|
|
clState->hasBitAlign = true;
|
|
|
+ free(extensions);
|
|
|
|
|
|
/* Check for OpenCL >= 1.0 support, needed for global offset parameter usage. */
|
|
|
char * devoclver = malloc(1024);
|
|
|
@@ -544,6 +567,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
|
|
|
find = strstr(devoclver, ocl10);
|
|
|
if (!find)
|
|
|
clState->hasOpenCL11plus = true;
|
|
|
+ free(devoclver);
|
|
|
|
|
|
status = clGetDeviceInfo(devices[gpu], CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, sizeof(cl_uint), (void *)&preferred_vwidth, NULL);
|
|
|
if (status != CL_SUCCESS) {
|
|
|
@@ -928,19 +952,11 @@ build:
|
|
|
strcat(CompilerOptions, " -D OCL1");
|
|
|
|
|
|
applog(LOG_DEBUG, "CompilerOptions: %s", CompilerOptions);
|
|
|
- status = clBuildProgram(clState->program, 1, &devices[gpu], CompilerOptions , NULL, NULL);
|
|
|
+ status = bfg_clBuildProgram(clState, devices[gpu], CompilerOptions);
|
|
|
free(CompilerOptions);
|
|
|
|
|
|
- if (status != CL_SUCCESS) {
|
|
|
- applog(LOG_ERR, "Error %d: Building Program (clBuildProgram)", status);
|
|
|
- size_t logSize;
|
|
|
- status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, 0, NULL, &logSize);
|
|
|
-
|
|
|
- char *log = malloc(logSize);
|
|
|
- status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
|
|
|
- applog(LOG_ERR, "%s", log);
|
|
|
+ if (status != CL_SUCCESS)
|
|
|
return NULL;
|
|
|
- }
|
|
|
|
|
|
prog_built = true;
|
|
|
|
|
|
@@ -1055,17 +1071,9 @@ built:
|
|
|
|
|
|
if (!prog_built) {
|
|
|
/* create a cl program executable for all the devices specified */
|
|
|
- status = clBuildProgram(clState->program, 1, &devices[gpu], NULL, NULL, NULL);
|
|
|
- if (status != CL_SUCCESS) {
|
|
|
- applog(LOG_ERR, "Error %d: Building Program (clBuildProgram)", status);
|
|
|
- size_t logSize;
|
|
|
- status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, 0, NULL, &logSize);
|
|
|
-
|
|
|
- char *log = malloc(logSize);
|
|
|
- status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
|
|
|
- applog(LOG_ERR, "%s", log);
|
|
|
+ status = bfg_clBuildProgram(clState, devices[gpu], NULL);
|
|
|
+ if (status != CL_SUCCESS)
|
|
|
return NULL;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/* get a kernel object handle for a kernel with the given name */
|