fandango

Kernel function problem

Discussion created by fandango on Apr 27, 2009
Latest reply on May 27, 2009 by fandango

Hi,

I have faced with small problem. My kernel function does not work correctly and return partly right result. This is function is very simple and I believe it is not my mistake. Could you please look at my example? What's wrong?

kernel void func1(unsigned char src[][],  unsigned char str, out unsigned char o_img<>
{
    // Output position
    int j = instance().x; // width
    int i = instance().y; // height
   
    int rest = j % 16;
   
    if (rest == 0)
    {
        o_img = src [ i] [j];
    }
    else
    {
        o_img = str;
    }
}

 

Input:

3   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   3   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   3   1   1   1   1   1   1   1   1

I just replace 1 by 9.

Wrong output:

  3      9   9   9   9   9   9   9   9   9   9   9   9   9   9   3      9   9   9   9   9   9   9   9   9   9   9   9   9   9   3      9   9   9   9   9   9   9

You can see garbage  in memory. If I remove if statement from the kernel , the output will be without garbage. But I need the first way.

 

 

Outcomes