- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm trying to configure 2 different kernels on 2 different devices in emulator mode. But not able to configure on 2nd device. I could able to launch kernel1 on device1 properly. When I'm trying to launch 2nd kernel on 2nd device then it is throwing "Error in clEnqueueTask1 45" error. Error no 45 = CL_INVALID_PROGRAM_EXECUTABLE. Tried with the following code: # define DEVICE_ID_1 1 # define DEVICE_ID_0 0 cl_program createProgramFromBinary(cl_context context, const char *binary_file_name, const cl_device_id *devices, unsigned num_devices) { // Early exit for potentially the most common way to fail: AOCX does not exist. if(!fileExists(binary_file_name)) { printf("AOCX file '%s' does not exist.\n", binary_file_name); checkError(CL_INVALID_PROGRAM, "Failed to load binary file"); } // Load the binary. size_t binary_size; scoped_array<unsigned char> binary(loadBinaryFile(binary_file_name, &binary_size)); if(binary == NULL) { checkError(CL_INVALID_PROGRAM, "Failed to load binary file"); } scoped_array<size_t> binary_lengths(num_devices); scoped_array<unsigned char *> binaries(num_devices); for(unsigned i = 0; i < num_devices; ++i) { binary_lengths = binary_size;binaries = binary; } cl_int status; scoped_array<cl_int> binary_status(num_devices); cl_program program = clCreateProgramWithBinary(context, num_devices, devices, binary_lengths, (const unsigned char **) binaries.get(), binary_status, &status); checkError(status, "Failed to create program with binary"); for(unsigned i = 0; i < num_devices; ++i) { checkError(binary_status, "failed to load binary for device");
}
return program;
}
void initopenclplatform_1()
{
cl_int err = cl_success;
err = clgetplatformids(0, null, &num_platforms);
if (cl_success != err) {
printf("error in clgetplatformids %d\n", err);
exit(-1);
}
if (0 == num_platforms) {
printf("no opencl platforms found\n");
exit(-1);
}
std::vector<cl_platform_id> platform(num_platforms);
err = clgetplatformids(num_platforms, &platform[0], 0);
if (cl_success != err) {
printf("error in clgetplatformids %d\n", err);
exit(-1);
}
for (cl_int i = 0; i < num_platforms; i++) {
size_t length = 0;
err = clgetplatforminfo(platform, CL_PLATFORM_NAME, 0, NULL, &length); if (CL_SUCCESS != err) { printf("Error in clGetPlatformInfo %d\n", err); exit(-1); } std::vector<char> platform_name(length); err = clGetPlatformInfo(platform, cl_platform_name, length, &platform_name[0], null);
if (cl_success != err) {
printf("error in clgetplatforminfo %d\n", err);
exit(-1);
}
//if (strstr(&platform_name[0], "altera")) {
if (strstr(&platform_name[0], "intel")) {
err = clgetdeviceids(platform, CL_DEVICE_TYPE_ALL, 0, NULL, &numDevices); if (CL_SUCCESS != err) { printf("Error in clGetDeviceIDs %d\n", err); exit(-1); } if (numDevices == 0) { printf("No suitable devices found\n"); exit(-1); } cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platform[i], 0 }; context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_ALL, NULL, NULL, &err); if ((CL_SUCCESS != err) || (NULL == context)) { printf("Error in clCreateContextFromType %d\n", err); exit(-1); } err = clGetContextInfo(context, CL_CONTEXT_DEVICES, 2*sizeof(cl_device_id), deviceId, 0); if (CL_SUCCESS != err) { printf("Error in clGetContextInfo %d\n", err); exit(-1); } const cl_command_queue_properties properties[] = { CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0 }; commandQueue[0] = clCreateCommandQueueWithProperties(context, deviceId[DEVICE_ID_0], properties, &err); if ((CL_SUCCESS != err) || (NULL == commandQueue[0])) { printf("Error in clCreateCommandQueue %d\n", err); exit(-1); } commandQueue[1] = clCreateCommandQueueWithProperties(context, deviceId[DEVICE_ID_1], properties, &err); if ((CL_SUCCESS != err) || (NULL == commandQueue[1])) { printf("Error in clCreateCommandQueue %d\n", err); exit(-1); } std::string binary_file = getBoardBinaryFile("openclExample_1", deviceId[DEVICE_ID_0]); printf("Using AOCX: %s\n", binary_file.c_str()); program[0] = createProgramFromBinary(context, binary_file.c_str(), &deviceId[DEVICE_ID_0], 1); binary_file = getBoardBinaryFile("openclExample_2", deviceId[DEVICE_ID_1]); printf("Using AOCX: %s\n", binary_file.c_str()); program[1] = createProgramFromBinary(context, binary_file.c_str(), &deviceId[DEVICE_ID_1], 1); platform_init = 1; } } } void kernelLaunch() { initOpenCLPlatform_1(); /*kernel object creation for 1st kernel*/ kernel[0] = clCreateKernel(program[0], "examaple_kernel_1", &err); if ((CL_SUCCESS != err) || (kernel[0] == NULL)) { printf("Error in creating kernel[0] %d\n", err); exit(-1); } //assigning kernel arguments for 1st kernel ... //1st kernel launch ... //copying back the output ... /*kernel object creation for 2nd kernel*/ kernel[1] = clCreateKernel(program[1], "examaple_kernel_2", &err); if ((CL_SUCCESS != err) || (kernel[1] == NULL)) { printf("Error in creating kernel[1] %d\n", err); exit(-1); } //assigning kernel arguments for 2nd kernel ... err = clEnqueueTask(commandQueue[1], kernel[1], 0, NULL, NULL); if (CL_SUCCESS != err) { printf("Error in clEnqueueTask1 %d\n", err); exit(-1); } } int main() { kernelLaunch(); }
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page