cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

dukeleto
Adept I

brook+ truncates double declarations

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

0 Likes
3 Replies
AlligatorJack
Journeyman III

brook+ truncates double declarations

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.

0 Likes
marcr
Staff
Staff

brook+ truncates double declarations


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



0 Likes
dukeleto
Adept I

brook+ truncates double declarations

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
0 Likes