| 60 | } |
| 61 | |
| 62 | int ImportSourceToProgram( |
| 63 | const char* filename, |
| 64 | cl_device_id* device_id, |
| 65 | cl_context context, |
| 66 | cl_program* program, |
| 67 | const char* options) |
| 68 | { |
| 69 | cl_int err; |
| 70 | |
| 71 | // Added as kernel is stringified already |
| 72 | const char *source = filename; |
| 73 | |
| 74 | // OCLADock |
| 75 | size_t sourceSize[] = { strlen(source) }; |
| 76 | |
| 77 | |
| 78 | *program = clCreateProgramWithSource(context, 1, &source, sourceSize, &err); |
| 79 | |
| 80 | if ((!*program) || (err != CL_SUCCESS)){ |
| 81 | printf("Error: clCreateProgramWithBinary() %d\n", err); |
| 82 | fflush(stdout); |
| 83 | return EXIT_FAILURE; |
| 84 | } |
| 85 | |
| 86 | #ifdef PROGRAM_INFO_DISPLAY |
| 87 | err = getProgramInfo(*program); |
| 88 | if (err != CL_SUCCESS){ |
| 89 | printf("Error: getProgramInfo() \n"); |
| 90 | fflush(stdout); |
| 91 | return EXIT_FAILURE; |
| 92 | } |
| 93 | #endif |
| 94 | |
| 95 | // Build the program executable |
| 96 | err = clBuildProgram(*program, 1, device_id, options, NULL, NULL); |
| 97 | |
| 98 | if (err != CL_SUCCESS) { |
| 99 | int err_build; |
| 100 | size_t sizeParam; |
| 101 | char* program_build_log; |
| 102 | |
| 103 | err_build = clGetProgramBuildInfo(*program,device_id[0],CL_PROGRAM_BUILD_LOG,0,NULL,&sizeParam); |
| 104 | if (err_build != CL_SUCCESS){ |
| 105 | printf("Error: clGetProgramBuildInfo() %d\n",err_build); |
| 106 | fflush(stdout); |
| 107 | return EXIT_FAILURE; |
| 108 | } |
| 109 | |
| 110 | program_build_log = (char*)malloc(sizeof(char) * sizeParam); |
| 111 | err_build = clGetProgramBuildInfo(*program, device_id[0], CL_PROGRAM_BUILD_LOG, sizeParam, program_build_log, NULL); |
| 112 | if (err_build != CL_SUCCESS){ |
| 113 | printf("Error: clGetProgramBuildInfo() %d\n", err_build); |
| 114 | fflush(stdout); |
| 115 | return EXIT_FAILURE; |
| 116 | } |
| 117 | printf(" %-45s: %s \n", "CL_PROGRAM_BUILD_LOG", program_build_log); |
| 118 | fflush(stdout); |
| 119 |
no test coverage detected