4 Replies Latest reply on Apr 10, 2009 4:36 AM by arros123

    Read and write into output scatter stream allowed?

    Peterp

      Hi,

      i've the following code thet does work but is it ok to read from the outputstream ?

       

      kernel void interlinkNet(int array_width, int array_heigth, float fuLat, 

       out float b[][])

      {

      int2 index = instance().xy;

      int i = 0;

      if(index.x==0)

      {

      for(i=0;i<array_width-1;i++)

      {

      float point1 = b[index.y];

      float point2 = b[index.y][i+1];

      float fr = fuLat * (point2-point1);

      b[index.y] = point1+fr;

      b[index.y][i+1] = point2-fr;

      }

      }

      }

        • Read and write into output scatter stream allowed?
          ryta1203

          I couldn't get this to compile using SKA, I didn't try it in VS yet.

           

          Line (19) : WARN--1: Strongly recommended to use c-style indexing for gather\scatter arrays

           Statement: b[index.y] in b[index.y]

          Line (19) : ERROR--1: Problem in index expression: Gather\scatter array dimensions and subscript vector components must match

           Statement: b[index.y] in b[index.y]

          Line (25) : WARN--2: Strongly recommended to use c-style indexing for gather\scatter arrays

           Statement: b[index.y] in b[index.y] = point1 + fr

          Line (25) : ERROR--2: Problem in index expression: Gather\scatter array dimensions and subscript vector components must match

           Statement: b[index.y] in b[index.y] = point1 + fr

          ***Semantic check found 2 errors

           

          You shouldn't be able to read from an output, that was my understanding, and even if you could it would just be junk anyways, so there wouldn't be any point to it. You are also accessing a 2D stream with 1D in some places, which I would think would give you problems, as it did in my SKA compilation. If you need to access it pass another stream as a gather; however, you probably won't see very good performance from this kernel.

          You probably aren't getting the correct results are you?

            • Read and write into output scatter stream allowed?
              Peterp

              Hi,

              i get the correct results. Of cource before the kernel starts, the output stream reads the data i want to read and write:

               

              s2.read(data);

              interlinkNet(SIZE,SIZE,fuLat,s2);

                • Read and write into output scatter stream allowed?
                  ryta1203

                   

                  Originally posted by: Peterp Hi,

                  i get the correct results. Of cource before the kernel starts, the output stream reads the data i want to read and write:

                   

                  s2.read(data);

                  interlinkNet(SIZE,SIZE,fuLat,s2)

                   

                  Interesting. It was explained to me that this wouldn't gaurantee correct results, unless something has changed in 1.4.

                  In fact, this flies directly in the face off their Stream Programming Model and the fact that there are no read/write streams.

                  I'm interested to see what AMD has to say.

                • Read and write into output scatter stream allowed?
                  arros123

                  I assume you are using XP for your development. Brook+ uses one thread local variable in the generated CPP and XP (not Vista or Linux) has limitation on using thread local variable in a dll and calling LoadLibrary() on this dll (more information at http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx).

                  There are two possible solution of this issue. You can choose any one of them-

                  1. Instead of loading libraries at runtime, make them link time dependent.
                  2. Change line 48 of KernelInterface.h (under $(BROOKROOT)\ sdk\include\brook) from #define __THREAD__ __declspec(thread) to #define __THREAD__ and rebuild your application or dll (no need to build Brook+ source). This change should not affect your application until your application is calling the same kernel from multiple threads.

                   

                  Edit:Removed Advertising from the post