Hi to all,
I have a Udoo Quad board with the i.mx6Quad CPU and the Vivante GC2000 GPU. The OS is UDOObuntu, that essentially is an Ubuntu 12.04 based distro.
In CodeBlocks I'm trying to run a simple "helloWorld" OpenCL program. The program is built and the libraries are linked, but at runtime there is a strange error after calling "clBuildProgram".
The kernel computes a simple C=A+B vector sum:
__kernel void hello_kernel(__global const float *a,__global const float *b,__global float *result)
{
int gid = get_global_id(0);
result[gid] = a[gid] + b[gid];
}
The C++ file is very simple. I'll show only the function that should create and build the CL program;
cl_program CreateProgram(cl_context context, cl_device_id device, const char* fileName)
{
cl_int errNum = -1000;
cl_program program;
std::ifstream kernelFile(fileName, std::ios::in);
if (!kernelFile.is_open())
{
std::cerr << "Failed to open file for reading: " << fileName << std::endl;
return NULL;
}
std::ostringstream oss;
oss << kernelFile.rdbuf();
std::string srcStdStr = oss.str();
const char *srcStr = srcStdStr.c_str();
program = clCreateProgramWithSource(context, 1,(const char**)&srcStr,NULL, NULL);
if (program == NULL)
{
std::cerr << "Failed to create CL program from source." << std::endl;
return NULL;
}
///////////////////// ERROR IS HERE //////////////////////
try
{
//errNum = clBuildProgram(program, 1, &device, "-cl-std=CL1.1 -w -cl-opt-disable", NULL, NULL);
errNum = clBuildProgram(program, 0, NULL, "", NULL, NULL);
} catch(...)
{
std::cout<< __LINE__<<", "<<__FILE__<<": errNum="<<errNum<<std::endl;
}
std::cout<< __LINE__<<", "<<__FILE__<<": errNum="<<errNum<<std::endl;
if (errNum != CL_SUCCESS)
{
// Determine the reason for the error
size_t logSize;
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,0, NULL, &logSize);
char* buildLog = new char[logSize];
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,sizeof(buildLog), buildLog, NULL);
std::cerr << "Error in kernel: " << std::endl;
std::cerr << buildLog;
clReleaseProgram(program);
delete[] buildLog;
return NULL;
}
return program;
}
Both the version in line 29 and the version in line 30 crash. The catch block is never reached, and the program exits immediately.
The compiler options are:
-march=native -fexceptions -DLINUX -DUSE_SOC_MX6 -Wall -fsigned-char -mfloat-abi=hard -mfpu=neon -DEGL_API_FB -DGPU_TYPE_VIV -DGL_GLEXT_PROTOTYPES -DENABLE_GPU_RENDER_20
I'm linking glib2.0, OpenCL, GAL, CLC, dl and pthread. Also the linker has option -mfloat-abi=hard
Hi Mauro
you can try Freescale OpenCL Hello World example for Sabre boards
https://community.freescale.com/docs/DOC-93984
as for Udoo board, one can post on meta-fsl-arm mailing list,
so that someone familiar with that board could try to assist you.
https://lists.yoctoproject.org/listinfo/meta-freescale
Best regards
igor
Hi Igor,
I tried also with the Freescale "Hello World". The options given to compiler and linker are taken from it. Unfortunately I had the same error.
The only difference is that I used the libOpenCL.so libGAL.so and libCLC.so already provided in Udoobuntu image inside /usr/lib/.
In fact I could not compile LTIB as explained in Freescale documentation.
Could the problem be a wrong version of the OpenCL libraries? If so, is there a link where to download the correct ones without working on LTIB?
Thanks,
Mauro
Hi Mauro
yes these may depend on libraries versions.
I am not familiar with Udoo distributions, suggest to post
on Udoo forum or meta-fsl-arm mailing list.
~igor