Create program from the BC source file */
| 182 | Create program from the BC source file |
| 183 | */ |
| 184 | cl_program create_program_from_bc (cl_context context, const std::string& file_name) |
| 185 | { |
| 186 | cl_int load_error = CL_SUCCESS; |
| 187 | cl_int error; |
| 188 | size_t binary_size; |
| 189 | BufferOwningPtr<const unsigned char> binary(load_file_bc(file_name, &binary_size)); |
| 190 | const unsigned char* ptr = binary; |
| 191 | |
| 192 | cl_device_id device = get_context_device(context); |
| 193 | cl_program program = clCreateProgramWithBinary( context, 1, &device, &binary_size, &ptr, &load_error, &error ); |
| 194 | |
| 195 | |
| 196 | if( program == NULL || error != CL_SUCCESS ) |
| 197 | { |
| 198 | throw Exceptions::TestError("clCreateProgramWithBinary failed: Unable to load valid program binary\n", error); |
| 199 | } |
| 200 | |
| 201 | if( load_error != CL_SUCCESS ) |
| 202 | { |
| 203 | throw Exceptions::TestError("clCreateProgramWithBinary failed: Unable to load valid device binary into program\n", load_error); |
| 204 | } |
| 205 | |
| 206 | return program; |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | Creates the kernel with the given name from the given program. |