1 Reply Latest reply on Jun 4, 2008 11:55 PM by marcr

    reduction variables within a reduction kernel

    morin.benoit@ireq.ca

      Hello,

      While trying to compile some brook files with the Linux 1.1 SDK, I came across some differences in regard to reduction variables within a reduction kernel. Theses difference are exhibited between brookgpu 0.5 and brook+ 1.1 and even between the current and previous release fo brook+.

      This simple code use to compile and run without error :

      #include

      reduce void sum(float x<>, reduce float y)
      {
      y += x;
      }

      int main(void)
      {
      float x_in[10];
      float x<10>;
      float y_out;
      int i;

      for (i = 0; i < 10; i++) {
      x_in = i + 1.0;
      }

      y_out = 0.0;

      streamRead(x, x_in);
      sum(x, y_out);

      printf("sum: %f\n", y_out);

      return 0;
      }

      Now, I get a ton of errors when compiling, the top two of which are :

      WARNING: ASSERT(GetResultSymbol().IsValid() + mDataTypeValue.IsValid() >= 1) failed
      While processing :121
      In compiler at ResolveSymbols()[astdelayedlookup.cpp:139]
      *mName = __indexof_y
      Message: unknown symbol

      ERROR: ASSERT(errorCount==0) failed
      While processing :132
      In compiler at CompileShaderToStream()[astroot.cpp:157]
      errorCount = 1
      Message: Unknown Symbols exist
      Aborting...
      Problem with compiling reduce_sum_fulladdr.hlslWARNING: ASSERT(GetResultSymbol().IsValid() + mDataTypeValue.IsValid() >= 1) failed
      While processing :123
      In compiler at ResolveSymbols()[astdelayedlookup.cpp:139]
      *mName = __indexof_y
      Message: unknown symbol

       

      The simple fix is to define the y variable in the kernel as a stream such as :

      reduce void sum(float x<>, reduce float y<> )


      With this simple change, everything now compiles and run correctly. But I wonder if this should be correct. Y isn't a stream, it does not reside (after the kernel is completed) in gpu memory but in cpu memory. If it is accessible without using a streamWrite, why should it be defined as an stream?

      I thank you for you help,

      Benoît Morin