the729

Seg-fault on second run

Discussion created by the729 on Oct 10, 2008
Latest reply on Oct 10, 2008 by udeepta@amd

Hi, all

#include <stdio.h>

kernel void increase(float a<>, out float c<>
{
    c = a+1;
}

int main(int argc, char** argv)
{
  int i, j;
  float input_a[4] = {1, 2, 3, 4};
  float c<4>;

  for(i=0; i<2; i++) {
    float a<4>;
    streamRead(a, input_a);
    increase(a, c);
    streamWrite(c, input_a);
  }

  return 0;
}

This piece of code lead to a segment fault on my system. It is OK on the first iteration, but crashes at __k->Map() on the second iteration.
However, everything is fine if I move the declaration of stream a<> outside of the loop, like this:
  .....
  float c<4>;
  float a<4>;

  for(i=0; i<2; i++) {
    ......
  }

I'm not sure if it is related to this thread:
http://forums.amd.com/devforum/messageview.cfm?catid=328&threadid=101244&enterthread=y

Outcomes