Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: when to use get_global id and get_local id in opencl?

  1. #1

    when to use get_global id and get_local id in opencl?

    when to use get_global id and get_local id in opencl?

    thanks

  2. #2

    Re: when to use get_global id and get_local id in opencl?

    difference between global_work size and local_work size?

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    8

    Re: when to use get_global id and get_local id in opencl?



    In the picture above you can see how id works in one-dimensional.
    Get it? You can use them both in most cases.

  4. #4
    Junior Member
    Join Date
    Jun 2012
    Posts
    7

    Re: when to use get_global id and get_local id in opencl?

    Is it correct to assume that the kernel will be run global_work_size times regardless of local worksizes and etc?

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    8

    Re: when to use get_global id and get_local id in opencl?

    Yes, the kernel will run globalWorkSize times.
    localWorkSize items will be executed in parallel.

    globalWorkSize = localWorkSize * numberOfGroups;

  6. #6

    Re: when to use get_global id and get_local id in opencl?

    but many times in kernel it is written that
    get_global_id(0);it means that only one core is using of particular gpu so it means that it is not parallel program if application is using only that kernel ? pls clarify this

  7. #7
    Junior Member
    Join Date
    Jan 2012
    Posts
    5

    Re: when to use get_global id and get_local id in opencl?

    Quote Originally Posted by jai
    but many times in kernel it is written that
    get_global_id(0);it means that only one core is using of particular gpu so it means that it is not parallel program if application is using only that kernel ? pls clarify this
    get_global_id(0) returns the global ID of the workitem in the first dimension. For 1D problems, this is enough for the algorithm to work. The kernel will still be launched in parallel many times.

    Take for example:
    __kernel array_sum (__global float* A, __global float* B, __global float* C)
    {
    int idx = get_global_id(0);
    C[idx] = A[idx] + B[idx];
    }
    Assume A, B & C are arrays of equal size.
    This kernel sums in parallel the arrays A & B into C. each workitem sums one index.
    The application launchs this kernel with 1D global size equal to the array size. The divide to local sizes in this case is not relevant to the algorithm, and can be left to the HW. If there will be enough groups, the device (CPU or GPU) will utilize all available cores.

  8. #8

    Re: when to use get_global id and get_local id in opencl?

    but global_id(0) means first work item in 1 Dimension ,so how other work items can execute for the same kernel,while giving global_id is 0. while it should be increased using ++ for next work item? pls clarify.....

  9. #9
    Junior Member
    Join Date
    Jun 2012
    Posts
    7

    Re: when to use get_global id and get_local id in opencl?

    if you are in the first work item get_global_id(0) will return 0. If you are in the second work item get_global_id(0) will return 1 and so on. The 0 stand for the dimension.

  10. #10

    Re: when to use get_global id and get_local id in opencl?

    it means that values are automatically assigned to cores of gpu ? It means kernel automatically runs on next core whose value is --> previous core's id + 1?
    is it right?

Page 1 of 2 12 LastLast

Posting Permissions

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