10 Replies Latest reply on Nov 10, 2008 10:43 PM by traits

    The problem about gather the double struct

    traits

      When I gather the double struct in kernel, I encountered the problem. Here is the code:

      #include <brook/brt.hpp>
      typedef struct test
      {
          double a;
          double b;
      }doubletest;


      kernel void gather_double_struct(doubletest x[], out double y<>)
       {
          doubletest test=x[1];
          y=test.a;
       }

      int main()
      {
          int length=4;
          int size=length/2;
          double * x, *y;
          int i=0;
          x=(double*) malloc(sizeof(double) *length);
          y=(double*) malloc(sizeof(double) *length);

          for(i=0;i<length;i++){
              x [ i ]=i;
              y [ i ]=1;
          }

          {
              doubletest x_stream<size>;
              double y_stream<length>;

              streamRead(x_stream,x);
              gather_double_struct(x_stream, y_stream);
              streamWrite(y_stream, y);
          }
          for(i=0;i<length;i++){
              printf("%lf\n",y [ i ] );
          }
          free(x);
          free(y);
          return 0;
      }

      The expected output:

      2.000000
      2.000000
      2.000000
      2.000000

      But, I got this:

      0.000000
      0.000000
      0.000000
      0.000000

      After setting BRT_RUNTIME=cpu,  I got the right output. If I set BRT_RUNTIME=cal, it will be wrong.

        • The problem about gather the double struct
          ryta1203
          x = double
          x_stream = doubletest

          streamRead(x_stream, x)?? Is this allowed? I would think that if this was the problem then you wouldn't get correct results with emu mode either, but there's no telling with this thing.

          Also, I always have a problem when trying to declare and initiliaze a variable in the same line in a kernel with Brook+.

          I agree that it seems emulation mode needs to be fixed so that code that runs in emulation mode will run on the GPU, otherwise, what is the point of emulation mode to begin with, especially since even in emulation mode you cannot put "printf() and such" in the kernel. Emulation mode is almost pointless at this point in the SDK.
            • The problem about gather the double struct
              traits

               

              Originally posted by: ryta1203 x = double x_stream = doubletest streamRead(x_stream, x)?? Is this allowed? I would think that if this was the problem then you wouldn't get correct results with emu mode either, but there's no telling with this thing. Also, I always have a problem when trying to declare and initiliaze a variable in the same line in a kernel with Brook+. I agree that it seems emulation mode needs to be fixed so that code that runs in emulation mode will run on the GPU, otherwise, what is the point of emulation mode to begin with, especially since even in emulation mode you cannot put "printf() and such" in the kernel. Emulation mode is almost pointless at this point in the SDK.


               

              It's right in emulation mode. You can try the code and verify it.

              I just tested using the same type in streamRead. It outputs the same wrong result in CAL.

                • The problem about gather the double struct
                  ryta1203
                  I believe that it works in emu mode, I'm just saying the emu mode needs to be redone or made better.

                  I don't see what you did in the sample "tests/struct". There the streamRead is from a Pairs type to a Pairs type. It looks like you are reading from a double type to a doubletest type.
                    • The problem about gather the double struct
                      traits

                       

                      Originally posted by: ryta1203 I believe that it works in emu mode, I'm just saying the emu mode needs to be redone or made better. I don't see what you did in the sample "tests/struct". There the streamRead is from a Pairs type to a Pairs type. It looks like you are reading from a double type to a doubletest type.


                      Yes, I see. 

                      I just tested using the same type in streamRead. It outputs the same wrong result in CAL.

                • The problem about gather the double structure
                  traits

                  I have test it on AMD Stream Computing SDK v1.2-beta and HD 4870, and it's failure too.

                  • The problem about gather the double struct
                    MicahVillmow
                    traits, please send a simple test case to streamdeveloper@amd.com so that we can have this tested and fixed for our next release.