3 Replies Latest reply on Jun 27, 2008 5:09 AM by dukeleto

    brook+ truncates double declarations

    dukeleto
      declaring a double does not work properly

      Hello,
      upon comparing cpp issued from the brook+ "compilation" of a .br,
      it appears that double declarations are truncated to floats:

      for a .br that contains something like this:

      int main{

      ...
      double test = 0.1234567898765;

      ...
      }


      the .cpp will have something like this:

      int main{

      ...
      double test = 0.123456;

      ...
      }



      This is a serious problem for me! Is there a declaration method that avoids this?
      Thanks

        • brook+ truncates double declarations
          AlligatorJack

          The only currently aviable graficcard which supports 64Bit is the AMD Firestream. So the double gets a 32-Bit float because your card doesn't support 64Bit.

          • brook+ truncates double declarations
            marcr

            This is a know problem, and actually mentioned in the release notes.
            brcc chops down any double literal to float, even outside of kernels.

            As far as workarounds go, how about this (I haven't tried it, but it should work):

            - In a separate c++ source file create a double array and initialize it
            with your double constants. Compile this using the C++ compiler, not brcc.
            - In your .br file, reference the array as an extern, and do a streamRead
            of it into a gather stream. Pass the gather stream to your kernel as an
            input parameter, and access your constants as gather stream elements.

            This trick also lets you work around brcc correctness issues with passing multiple double vars to a kernel.

            There may be performance implications vs. using float constants, I'm not sure.

            -- marcr



            • brook+ truncates double declarations
              dukeleto
              OK thanks, I will try that.
              For what it's worth, I have tried changing the c++ output from brook back to the proper double literals, and
              in that case things work properly.
              On a side note, what's the deal with brook output code initializing brtdoubles with brtfloat{xxx} ?
              It seems to work, but the syntax is unnerving to my untrained eye!
              Thanks