AnsweredAssumed Answered

Strange behavior in kernel - Losing variables during kernel run

Question asked by dasmurkel on Aug 22, 2013
Latest reply on Jun 17, 2014 by pinform

Hi,

 

I've come across some very strange kernel behavior when running a certain kernel on my Radeon Device. Interestingly, the exact same code performs fine using the CPU-Device, either with the AMD-APP SDK or the Intel SDK (I have a Core i5).

 

The kernel looks as follows:

 

kernel void
incident_bitmask (const uint size,
                  const uint intersectionBufferPerRay,
                  const global uint* intersectionCount,
                  const global intersection* intersections,
                  const global ray* rays,
                  const global transmitter* sourceTransmitters,
                  const global wall* walls,
                  const global building* buildings,
                  float rx_planeHeight,
                  global uint* bitmask,
                  global incidentPoint* incidents)
{
  const uint id = get_global_id (0);
  if (id >= size)
    {
      return;
    }

 

// ... Some stuff ...
  printf ("ID: %i, intersectionBufPerRay: %i\n", id, intersectionBufferPerRay);
  const uint resultBufferSize = 2 * intersectionBufferPerRay + 1;

 

// ... Lots of more stuff, branches, loopsand function calls ...


  printf ("resultBufferSize for ID %i: %i\n", id, resultBufferSize);

}

 

I run this kernel with a global size of 6 and obviously the "size" parameter is also set to 6. This is my output:

 

ID: 0, intersectionBufPerRay: 100
resultBufferSize for ID 0: 201
ID: 1, intersectionBufPerRay: 100
resultBufferSize for ID 1: 201
ID: 2, intersectionBufPerRay: 100
resultBufferSize for ID 2: 201
ID: 3, intersectionBufPerRay: 100
resultBufferSize for ID 0: 201
ID: 4, intersectionBufPerRay: 100
resultBufferSize for ID 0: 201
ID: 5, intersectionBufPerRay: 100
resultBufferSize for ID 0: 201
ID: 6, intersectionBufPerRay: 100
resultBufferSize for ID 0: 201

 

 

Please note that I get the IDs printed out correctly for the first prinf but that I get only 0-2 for the second printf. The rest of the ids (which were set to the correct global_id at the beginning of the kernel and are const, so there is no way I changed them) is set to zero.

 

Another thing is, that this only happens sometimes and hat the margin for which the values are correct changes. Sometimes everything is fine, sometimes I get 0-3 correct and the rest is wrong, sometimes the "intersectionBufferPerRay" also prints zero.

 

Environment: Ubuntu 12.10, Catalyst 13.4, Radeon HD 7850

 

Any help is greatly appreciated!

Outcomes