Results 1 to 5 of 5

Thread: get_global_id is undefined

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    7

    get_global_id is undefined

    Hi All,

    Sorry for this (stupid) question. I'm new to OpenCL programming.

    I've downloaded the CUDA SDK v5 and I'm trying to write my first applications.

    I trying to use the function get_global_id but I got a message saying that it is undefined. I was not able to find this function in any include file.

    Can someone please tell me what happened with this function?

    Thanks a lot!

  2. #2

    Re: get_global_id is undefined

    get_global_id() is a built-in of OpenCL C, so it is only defined inside of kernels. Are you trying to use it in host code? please post a minimal buildable example showing the problem.

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    7

    Re: get_global_id is undefined

    Hi Bilog!

    First of all, thank you very much for your help!

    The code is very simple:

    Code :
    __kernel
    	void array_add(__global const double *a1, __global const double *a2, __global double *ar)
    {
        int id = get_global_id(0);
        ar[id] = a1[id] + a2[id];
    }

    I've tried to change "__kernel" to "__global__", since "__kernel" is also not recognized but I had no success.

    Actually I just wanted to use OpenCL instead of using CUDA. I'm using the CUDA SDK due to my GPU (NVIDIA GeForce GT630M). But it seems that there are some OpenCL types/functions in the CUDA SDK. But I was not able to find the function get_global_id (or "__kernel").

    Can you help me with this?

    Again, thanks a lot!

  4. #4
    Junior Member
    Join Date
    Mar 2013
    Posts
    7

    Re: get_global_id is undefined

    Hi Bilog,

    Not sure but now I think I understood my problem. Again, sorry for my ignorance.

    The kernel code will not be compiled within the .cu file, right?

    Should I create a separate file containing the kernel code and then load in the .cu file using the function clCreateKernel?

    Is there any way to debug this code?

    Thank you!

  5. #5

    Re: get_global_id is undefined

    Quote Originally Posted by mtpurger
    The kernel code will not be compiled within the .cu file, right?
    OpenCL source files usually end in ".cl" (.cu is used by CUDA). But no, .cl files contain the source code.

    Quote Originally Posted by mtpurger
    Should I create a separate file containing the kernel code and then load in the .cu file using the function clCreateKernel?
    To get a kernel first create a cl_program object with clCreateProgramWithSource(), next build the program with clBuildProgram(), and then create the kernel object with clCreateKernel().

Similar Threads

  1. basic question regarding get_global_id
    By prince in forum OpenCL
    Replies: 6
    Last Post: 12-01-2012, 02:03 PM
  2. Should I cache get_global_id(0)?
    By yoavhacohen in forum OpenCL
    Replies: 1
    Last Post: 02-03-2012, 05:23 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
  •