Results 1 to 2 of 2

Thread: Error when building OpenCl

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    1

    Error when building OpenCl

    Hello,
    I am new to OpenCL. I come this error when building the kernel source code:

    const char* OpenCLProgram[] = {
    "__kernel void OpenCLfunc( \n",
    " __global float* g_input, \n",
    " __global float* f, \n",
    " __global float* g_output, \n",
    " unsigned int n, \n",
    " __local float *sdata){ \n",
    " unsigned int i = get_global_id(0); \n",
    " f[i] = pow(g_input[i],2); \n",
    " barrier(CLK_LOCAL_MEM_FENCE); \n",
    " unsigned int tid = get_local_id(0); \n",
    " sdata[tid] = (i < n) ? f[i] : 0; \n",
    " barrier(CLK_LOCAL_MEM_FENCE); \n",
    " for(unsigned int s=get_local_size(0)/2; s>0; s>>=1) \n",
    " { \n",
    " if (tid < s) sdata[tid] += sdata[tid + s]; \n",
    " barrier(CLK_LOCAL_MEM_FENCE); \n",
    " } \n",
    " if (tid == 0) g_odata[get_group_id(0)] = sdata[0]; \n",
    "} \n",
    };

    I want to compute the squared value of an array and then use reduction to compute the sum of array. I have the error message:
    Err when building program -11
    Build info err 0
    <program source>:7:39: error: expected '}'
    unsigned int i = get_global_id(0);

    Any suggestion is appreciated. Thank you.
    Regards,
    Minhbt

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Error when building OpenCl

    Declare variable "i" as "size_t" instead of "unsigned int".
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Similar Threads

  1. Error LNK2019 building application with OpenGL ES
    By gersonfaf61 in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 06-26-2012, 05:30 AM
  2. error building Nokia 3d example
    By miranda2112 in forum OpenGL ES general technical discussions
    Replies: 3
    Last Post: 02-23-2005, 10:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •