cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

fandango
Journeyman III

Illegal to call scatter kernel from any kernel

Hello again,

What does this error mean?

I have two kernel function.

kernel void motion_estimation(unsigned char src[], unsigned char ref[], int width, int height, out double sad[])

kernel int estimate_macroblock_4x4(unsigned char mbs[],
                                   unsigned char mbr[],
                                   int i,
                                   int j,
                                   int width,
                                   int height, 
                                   out double sad[])


The first calls the second one.

The streams defenition is

    brook::Stream<unsigned char> srcStream(rank, streamSize);
    brook::Stream<unsigned char> refStream(rank, streamSize);

    // copying data from input buffer to input stream
    srcStream.read(src);
    refStream.read(ref);

    // creating the output stream
    streamSize[0] = width / 16 * height / 16;

    rank = 1;

    // creating the output stream
    streamSize[0] = width;
    streamSize[1] = height;
    rank = 1;

    brook::Stream<double> sad(rank, streamSize);

As you can see I don't fully understand you stream conception, because of poor documentation.


Can you advice me something?

0 Likes
2 Replies
fandango
Journeyman III

kernel int estimate_macroblock_16x16(unsigned char mbs[],
                                   unsigned char mbr[],
                                   int i,
                                   int j,
                                   int width,
                                   int height, 
                                   out double sad[])
{
    int x, y;
    int index = i / 16 + (j / 16 * width);
   
    for (y = 0; y < 16; y++)
    {
        for (x = 0; x < 16; x++)
        {
            int index = i + x + ((j + y) * width);
           
            sad[index] += (double)(mbs[index] - mbr[index]);
        }
   
    }
   
    return 0;
}

kernel void motion_estimation(unsigned char src[],
                              unsigned char ref[],
                              int width,
                              int height,
                              out double sad[])
{
    // Output position
    int2 vPos = instance().xy;
   
    int i = vPos.x; // width
    int j = vPos.y; // height
   
    if ((j % 16 == 0 && i % 16 == 0) && (j != height - 1 && i != width - 1))
    {
        estimate_macroblock_16x16(src, ref, i, j, width, height, sad);
    }
}

0 Likes

You can not pass output streams from main kernel to a sub kernel. If your output stream is regular stream, the element is decided by kernel instance. But, in case of scatter stream, you have to explictly index in stream before passing it to sub-kernel.

 

0 Likes