Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Beginner question: understanding NDRange

  1. #11

    Re: Beginner question: understanding NDRange

    Hi;

    Not all arguments of EnqueueNDRangeKernel are being used right now. Some are there for future implementations. It should be OK to leave some values for OpenCL to decide (like the number of workgroups).

    As for the work-items and work-dimension question, here is a simple answer. Have in mind that in OpenCL all codes are executed at the same time and in regular code they are executed in sequence, which is a big difference.

    work_dim = {n}
    Regular Code:

    Code :
    for (int i=0; i < n; i++)
    {
         //your code
    }

    OpenCL code:
    Code :
    kernel ( /*your arguments*/ )
    {
        i = get_global_id(0);
       //your code
    }
    EnqueueNDRange(yourkernel, work_items, etc.)
    work_dim = {n, p}
    Regular Code:

    Code :
    for (int i=0; i < n; i++)
    {
       for (int j=0; j < p; j++)
       {
         //your code
       }
    }

    OpenCL code:
    Code :
    kernel ( /*your arguments*/ )
    {
        i = get_global_id(0);
        j = get_global_id(1);
       //your code
    }
    EnqueueNDRange(yourkernel, work_items, etc.)

    I hope I mande things clearer. I am currently working on an OpenCL tutorial that may help you. I have made it available at
    http://www.cmsoft.com.br/ , developers section. I have not reached advanced topics yet but it might help.
    Visit my computational mathematics webpage
    http://www.cmsoft.com.br

    View math resources, OpenGL contents, OpenCL resources and tutorials and more content related to computational math.

  2. #12
    Junior Member
    Join Date
    Feb 2010
    Posts
    23

    Re: Beginner question: understanding NDRange

    This is a very useful thread for me. It has helped to settle my thinking on the NDRange values, thanks. I hope that this does not highjack the thread too much but I don't quite understand the relationship between local work size and the get_local_id function. In my code (that appears to be working) I have set the local work size to 128, but in my opencl code I'm assuming that the get_local_id function is limited to the actual number of stream processors. Is this true? I'm worried now because I have tied the local id to a buffer and that I might be accessing memory that is beyond the bounds of the buffer. In this case the buffer is an array 16 items long, because my card (geforce 9400) only has 16 stream processors. Should the buffer be 128 items long? As I said before the program runs fine and I haven't had a crash because of this in all the times I have ran it. I just want to make sure that I haven't just been lucky.

    Thanks,

    Grimm

  3. #13

    Re: Beginner question: understanding NDRange

    Quote Originally Posted by grimm
    This is a very useful thread for me. It has helped to settle my thinking on the NDRange values, thanks. I hope that this does not highjack the thread too much but I don't quite understand the relationship between local work size and the get_local_id function. In my code (that appears to be working) I have set the local work size to 128, but in my opencl code I'm assuming that the get_local_id function is limited to the actual number of stream processors. Is this true? I'm worried now because I have tied the local id to a buffer and that I might be accessing memory that is beyond the bounds of the buffer. In this case the buffer is an array 16 items long, because my card (geforce 9400) only has 16 stream processors. Should the buffer be 128 items long? As I said before the program runs fine and I haven't had a crash because of this in all the times I have ran it. I just want to make sure that I haven't just been lucky.
    get_local_id has no relation to the number of stream processors. If, as you say, the local work size if 128, then get_local_id will return a value in the range from 0 to 127.

  4. #14
    Junior Member
    Join Date
    Feb 2010
    Posts
    23

    Re: Beginner question: understanding NDRange

    Thanks Ibbles, now to go fix my code. I must have been lucky then.

    Grimm

  5. #15

    Re: Beginner question: understanding NDRange

    Douglas/ibbles,

    Thanks for your helpful replies. I have written small Java program using nativelibs4java that will emphasize the global-ids, local-ids and group-ids. I ran the kernel on my HD5750.

    To get global-ids, local-ids and group-ids for a global-work-size of 256 and local-size=4, run the following command (with proper OpenCL for Java setup and CLASSPATH).

    java -DGLOBAL=256 -DLOCAL=4 com.nativelibs4java.opencl.demos.NDRange1

    Same kernel can be tried using C/C++ to get same result

Page 2 of 2 FirstFirst 12

Similar Threads

  1. A question on NDRange
    By jazpearson in forum OpenCL
    Replies: 0
    Last Post: 01-30-2013, 07:47 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
  •