Results 1 to 2 of 2

Thread: Kernel improvement?

  1. #1
    Junior Member
    Join Date
    Dec 2012

    Kernel improvement?

    I'm passing 2 global arrays of 2D points into my kernel, and then in the kernel, i'm accessing the global arrays multiple times (and passing them into other functions).

    For example:

    Code :
    kernel FooBar(global float2 *array1, global float2 *array2)
      int i = get_global_id(0);
      int j = get_global_id(1);
      float pt1x = array1[i].x;
      float pt1y = array1[i].y;
      float pt2x = array2[j].x;
      float pt2y = array2[j].y;
      // do some calcs 
      float ans1 = SomeFunction(array1);
      float ans2 = SomeFunction(array2);
      // and so on.........

    Is it better to copy these arrays into local memory? How does one do this? Are there any limitations i need to know about (such as memory issues?).


  2. #2
    Senior Member
    Join Date
    Sep 2002
    Santa Clara

    Re: Kernel improvement?

    Local memory can be helpful if one or more work-items are reading from a location in global memory multiple times. In the specific example you posted it is not clear if it will help as the OpenCL compiler will most like replace the second call to array1[i].x and array2[j].y with the value already read by the first call to these array entries stored in a register.

Similar Threads

  1. Kernel Memory Error (illegal access inside kernel) - why?
    By Syndacate in forum OpenCL - parallel programming of heterogeneous systems
    Replies: 4
    Last Post: 08-06-2012, 02:18 AM
  2. Begginer question: native kernel vs OpenCL kernel
    By Rui in forum OpenCL - parallel programming of heterogeneous systems
    Replies: 1
    Last Post: 03-14-2010, 08:34 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
Proudly hosted by Digital Ocean