6 Replies Latest reply on Jul 22, 2008 10:45 AM by Ceq

    shifting streams

    wateenellende
      BROOK language extentions

      For a particular class of applications, such as cellular automata simulations, it would be realy convenient to be able to shift streams. Actually to rotate them would be even better. I've seem a note somewhere (http://merrimac.stanford.edu/brook/quikspec.10-18-02.pdf) that mentions such functions as "coming soon". Any chance of having them in Brook+ ?

        • shifting streams
          ssclift

          I'll add my voice to that one.  There are a lot of financial applications that reduce to calculations like  

          a_0 x[ i ] + a_1 x[i-1] + a_2 x[i-2] ...

          which might be more efficient to code into a Brook kernel using offset copies of the x[] vectors.  x[] is are typically ~504 or ~756 in length (2 or 3 years of business-day data at 252 days/year).

            • shifting streams
              michael.chu
              Would you be able to reformulate your calculation to use gather streams?

              Michael.
                • shifting streams
                  ssclift

                  Probably.

                  With a float4 assigned to x..x[i-3] that would cover a lot of cases.  I'll have to test it out to see; I don't have a good feel for the relative efficiency of each approach.

                    • shifting streams
                      Ceq
                      I think this could be helpful:
                      In another thread 'udeepta' told about the domain operator.
                      I think you can use it like a stream shift, for example:


                      kernel void mul(float i1<>, float i2<>, out float o<> ) {
                      o = i1 * i2;
                      }

                      {
                      ...
                      float input1<10>;
                      float input2<10>;
                      float output<9>;
                      ...
                      mul(input1.domain(0, 9), input2.domain(1, 10), output);
                      ...
                      }

                      (It can be used to control the output range too)
                • shifting streams
                  Ceq
                  It is exclusive of b, note that if it were inclusive the example would be indexing 11 stream elements in the kernel call.
                  You can try it yourself, even if you are using CPU backend it would still work.