Results 1 to 5 of 5

Thread: How can I get this error?

  1. #1

    How can I get this error?

    Today, I received a sample source that is reduce for calcuration.

    I write this project, build, and compile.

    One Error is occured.

    Error: Failed to build program executable!
    :80: error: expected identifier or '('
    }???????????????????????????????????????
    ^

    I search this line, and see it. But I don't find it what is expected identifier.

    I appending this kernel source.
    Code :
    #ifndef GROUP_SIZE 
    #define GROUP_SIZE 64 
    #endif 
     
    __kernel void 
    reduce(__global float *output, __global const float *input,  
              __local float *shared, unsigned int n) 
    { 
        const unsigned int lid = get_local_id(0); 
        const unsigned int lsize = GROUP_SIZE;//get_local_size(0);  
        // NOTE:  get_local_size(0) must equal GROUP_SIZE 
     
        const unsigned int gid = get_group_id(0); 
        const unsigned int gsize = get_num_groups(0); 
     
      const unsigned int gs2 = GROUP_SIZE * 2; 
        const size_t stride = gs2 * gsize;  
     
        shared[lid] = 0.0f; 
     
        size_t i = gid * gs2 + lid; 
        while (i < n) 
        { 
            shared[lid] += input[i] + input[(i+GROUP_SIZE)];   
            i += stride; 
        }  
        barrier(CLK_LOCAL_MEM_FENCE); 
     
    #if (GROUP_SIZE >= 512)  
    if (lid < 256) 
        shared[lid] += shared[lid + 256]; 
    barrier(CLK_LOCAL_MEM_FENCE);  
    #endif 
     
    #if (GROUP_SIZE >= 256)  
        if (lid < 128) 
          shared[lid] += shared[lid + 128]; 
        barrier(CLK_LOCAL_MEM_FENCE); 
    #endif     
     
    #if (GROUP_SIZE >= 128)  
        if (lid <  64) 
          shared[lid] += shared[lid +  64];
      barrier(CLK_LOCAL_MEM_FENCE);  
    #endif 
     
        if (lid < 32) 
        { 
    #if (GROUP_SIZE >=  64)  
            shared[lid] += shared[lid + 32];  
          barrier(CLK_LOCAL_MEM_FENCE); 
    #endif 
     
    #if (GROUP_SIZE >=  32)  
            shared[lid] += shared[lid + 16];  
          barrier(CLK_LOCAL_MEM_FENCE); 
    #endif 
    #if (GROUP_SIZE >=  16)  
            shared[lid] += shared[lid +  8]; 
          barrier(CLK_LOCAL_MEM_FENCE); 
    #endif 
    #if (GROUP_SIZE >=   8)  
            shared[lid] += shared[lid +  4];  
          barrier(CLK_LOCAL_MEM_FENCE); 
    #endif 
    #if (GROUP_SIZE >=   4)  
            shared[lid] += shared[lid +  2];  
          barrier(CLK_LOCAL_MEM_FENCE); 
    #endif 
    #if (GROUP_SIZE >=   2)  
            shared[lid] += shared[lid +  1]; 
          barrier(CLK_LOCAL_MEM_FENCE); 
    #endif 
        } 
     
        if (lid == 0) 
          output[gid] = shared[0]; 
     
    }

  2. #2

    Re: How can I get this error?

    I would guess that your source string is not properly NULL terminated. Make sure that you append a NULL terminator after you have read the kernel source file.

  3. #3

    Re: How can I get this error?

    Quote Originally Posted by ibbles
    I would guess that your source string is not properly NULL terminated. Make sure that you append a NULL terminator after you have read the kernel source file.
    I don't understand your advise..

    The sentense means that after I have read the kernel source file then the memory is initialize NULL??

    How do I fixed to kernel source or application source??

  4. #4

    Re: How can I get this error?

    In your first post you included an error message that, in turn, included a line from the source your are trying to compile:

    }???????????????????????????????????????

    I'm guessing that the leading '}' is the last valid char of your source and that the remaining '?' are garbage, i.e. uninitialized data. The OpenCL compiler need to know the length of the source, so it does not try to include the '?' chars while compiling. One way of doing this is to have a NULL terminator after the trailing '}' (the other way is to specify the source length as the fourth argument to clCreateProgramWithSource). So read the source as you already do, but keep track of where you wrote the last valid source char, and then write a NULL to the next buffer position.

  5. #5
    Junior Member
    Join Date
    Apr 2010
    Posts
    27

    Re: How can I get this error?

    Judging from my little experience, such error message can occur when the kernel source code has bugs. So you have to check your kernel source code carefully.

    Commenting some part out, a basic method for debugging, helps a lot for this kind of error message.

    Sometimes, if the kernel souce code contains unused structure definitions, which never appear in kernel functions but defined in the .cl file.

Similar Threads

  1. fatal error C1189: #error : ERROR: Use of C runtime library
    By gjermani in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 09-24-2007, 03:02 AM
  2. about X Error: GLXBadDrawable 158 Error
    By Ulimit77 in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 06-05-2005, 04:19 AM

Posting Permissions

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