Results 1 to 5 of 5

Thread: use pointer in kernel code

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    11

    use pointer in kernel code

    hi, i would like to optimize the code of my algorithm trying to use pointers.
    in my code i have a cycle within which the calculation always an expression.

    Code :
    __kernel void cicle(__global uchar * in, __global float * out, int w, int h)
    {
     
    int x = get_global_id(0);
    float pix = 0;
     
    ...
     
    for (int i = 0; i< h; i++)
    {
    ...
         pix = in[x+i*w];
    ...
    }
     
    ...
     
    }

    how can I use pointers to not always calculate the expression in the for cycle?

    Thank you

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: use pointer in kernel code

    Have you considered using a 2D range instead of a 1D range? From the little source code you have shown it looks like you are operating on an image.

    All you have to do is specify two dimensions when you call clEnqueueNDRangeKernel.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Posts
    11

    Re: use pointer in kernel code

    grazie per avermi risposto. Sto elaborando una immagine, perņ invece di utilizzare un 2d, sto utilizzo 1d.

  4. #4
    Junior Member
    Join Date
    Oct 2010
    Posts
    11

    Re: use pointer in kernel code

    Quote Originally Posted by zakketto
    thanks for reply. I'm working on an image, but instead of using a range of 2D, I'm using 1D.

  5. #5

    Re: use pointer in kernel code

    I would not expect that computing that expression is your bottleneck. Modern processors have cycles to spare and are usually bandwidth bound instead. I would suggest focusing on making your loading/storing to memory more efficient before you worry about saving a few math operations.

Similar Threads

  1. Compiling Kernel With Struct Pointer in Argument
    By ConstantinS in forum OpenCL
    Replies: 1
    Last Post: 03-29-2013, 02:58 PM
  2. Passing NULL pointer to the kernel ?
    By viewon01 in forum OpenCL
    Replies: 2
    Last Post: 07-26-2010, 06:21 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
  •