2 Replies Latest reply on May 14, 2009 6:21 AM by anlongstar

    The domain is only support <>? not [][]?

    anlongstar
      domian, stream, array

      eg:

      //--------------------------------------------------------

      Kernel:

      kernel void
      domainAdd(double inCCCCCC,double inputStream[][], out double o[][])
      {
             int2 position = instance().xy;
         int i=position.x;
         int j=position.y;
         o[j]=inputStream[j]+1.0;

      }


      kernel void
      domainAddStream(double inCCCCCC,double inputStream<>, out double o<>
      {
         o=inputStream+1.0;
      }

       

      //-------------------------------------------------

      the main:

       int blockSize=128; 

      #define real double
       
       const unsigned int width = blockSize;
       const unsigned int height = blockSize;
       
       // Specifying the size of the 2D stream
       unsigned int streamSize[] = {width, height};
       
       // Specifying the rank of the stream
       unsigned int rank = 2;
       
       real* outputBuffer = new real[width * height];
       memset(outputBuffer, 0, width * height * sizeof(real));
       real* inputBuffer = new real[width * height];
       memset(inputBuffer, 1, width * height * sizeof(real));
       
       // Create a 2D stream of specified size i.e. 64x64 floating-point values   
       brook::Stream<real> *outputStream;
       outputStream=new Stream<real>(rank, streamSize); 
       brook::Stream<real> inputStream(rank, streamSize);
       

       inputStream.read(inputBuffer);
       unsigned int start[] = {5,0};//(width,height)
       unsigned int end[] = {16,4};

       
       //domainAdd(1.0,inputStream.domain(start,end),outputStream->domain(start,end));// this will get the wrong answer
       domainAddStream(1.0,inputStream.domain(start,end),outputStream->domain(start,end));

        • The domain is only support <>? not [][]?
          gaurav.garg

           

          kernel void domainAdd(double inCCCCCC,double inputStream[][], out double o[][]) {        int2 position = instance().xy;    int i=position.x;    int j=position.y;    o[j]=inputStream[j]+1.0;

           

          }

           

          kernel void domainAddStream(double inCCCCCC,double inputStream<>, out double o<>) {    o=inputStream+1.0; }

           

           

           



          Both of your above kernels are doing different thing. instance().x points to the column of the kernel instance and instance().y points to the row.

          When using C-style indexing for gather or scatter stream, you must index like this-

          o[row][column]

          Making this change, gives the same result for both the kernels.