OPENCL clBuildProgram fails with no return

Discussion in 'Troubleshooting' started by MauroManzo, Jan 12, 2015.

  1. MauroManzo

    MauroManzo New Member

    Joined:
    Dec 29, 2014
    Messages:
    3
    Likes Received:
    0
    Hi to all,

    I have a Udoo Quad board with the i.mx6Quad CPU and the Vivante GC2000 GPU, and UDOObuntu as OS.

    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:

    Code:
        __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;

    Code:
       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.

    I suppose that there should be some problem in libCLC.so. I tried with other versions found online, mainly on the freescale website, but I had no luck.

    Has anybody successfully used OpenCL on UdooBuntu, or other Udoo Distro? If so, could you provide me your OpenCL libraries (libOpenCL.so, libCLC.so, libGAL.so) and headers, and the options given to compiler/linker?

    I'm in hurry for a project, and I'm stuck in this situation since last month! I'd really appreciate your help!

    Thanks,
    Mauro
     
  2. delba

    delba Administrator Staff Member

    Joined:
    May 8, 2013
    Messages:
    1,064
    Likes Received:
    9
    Never tried to use OpenCL with Codeblocks in UDOO, sry.
     
  3. MauroManzo

    MauroManzo New Member

    Joined:
    Dec 29, 2014
    Messages:
    3
    Likes Received:
    0
    Update: I successfully ran the opencl sample switching to Ubuntu 12.04. As I suspected, there must be a sort of bug in the libraries provided in UdooBuntu.
     
  4. delba

    delba Administrator Staff Member

    Joined:
    May 8, 2013
    Messages:
    1,064
    Likes Received:
    9
    Ok, great then.
     

Share This Page