1 Reply Latest reply on Jun 17, 2009 7:54 AM by gaurav.garg

    Replacing iter

    HarshaBangalore
      How to replace "iter" keyword of Brook language with that in Brook+ language

      Here is a code in Brook programming language, which needs a replacement of "iter" keyword with respect to Brook+ programming language.

      kernel void process(float Hx[][], float Chxh[][], float Chxe[][], float Ez[][], iter float2 it<>, out float o_img<>

      {

           float2 t0 = float2(0.0f,1.0f);

           o_img = (Chxh[it] * Hx [it]) + (Chxe[it] * (Ez[it] - Ez[it + t0]));

      }

      int main(int argc, char* argv[])

      {

           ----------

           ----------

           for(i = 0; i < 100; i++)

          {

               aHx = 0.0f;

               aEz = 0.0f;

               aChxh = 1.0f;

               aChxe = 1.0f;

          }

           streamRead(Hx, aHx);

           streamRead(Ez, aEz);

           streamRead(Chxhx, aChxh);

           streamRead(Chxe, aChxe);

           iter float2 it<110,110> = iter(float2(1.0f, 1.0f), float2 (499.0f,  499.0f));

           float Hx<100,100>, Ez<100,100>

           float Chxh<100,100>, Chxe<100,100>;

           float o_Hx<100,100>;

           process(Hx, Chxh, Chxe, Ez, it, o_Hx);

           streamWrite(Hx, outputHx);  //outputHx is an array

           streamWrite(Ez, outputEz);   //outputEz is an array

           -----------

           -----------

      }

       

        • Replacing iter
          gaurav.garg

          iter is similar to an input stream, but it was used for automatic index generation.

          iter float2 it<110,110> = iter(float2(1.0f, 1.0f), float2 (499.0f,  499.0f));

          is similar to declaring a float2 stream of size 110 * 110 and with values [1, 499). The exact calculation of values, can be find here - http://www.gpgpu.org/w/index.php/Brook

          You can just replace iter with streams and initialize stream with calculated values using streamRead.