1 Reply Latest reply on Jan 4, 2009 5:07 AM by gaurav.garg

    Brook+ accumulate operation

    tgm@ncic.ac.cn

      Brook+ does not allow output stream is accumulated ?

      For example:

      kernel void test(float a[], float b<>

      {

      tid = instance().x

      b += a[tid];

      }

      The elements in output stream sometimes are NAN.

        • Brook+ accumulate operation
          gaurav.garg

          I assume you have declared b with out qualifier. It seems from your kernel you don't want to accumulate data in b, but want to read the previous value and update it with a new value. Brook+ doesn't allow reading and writing to the same stream. But, you can try something like this -

          kernel void test(float a[], float bOld<>, out float b<>)

          {

          tid = instance().x

          b = a[tid] + bOld;

          }

          As a sidenote Brook+ allows accumulating data of a stream to a smaller size stream using reduction kernel -

          reduce void test(float a<>, reduce float b<>)

          {

          b += a;

          }