Closed GoogleCodeExporter closed 8 years ago
Helmut,
Thanks for submitting this. Clearly we need to look and float and double a
little closer. This is probably related to issue #27, however that was focused
on dealing with 'real NaN' here we (in Aparapi) or the card are mangling the
float/double representation.
Let me write some test cases for this and take a look.
Gary
Original comment by frost.g...@gmail.com
on 17 May 2012 at 2:32
Helmut
I found the culprit and submitted a patch for this #r467
It was as Steve pointed out in his diagnosis of #27 something weird in
ByteBuffer.d8() which converts double constants from the classfile into the
disassembler.
Actually the fix was in ByteBuffer.u8() (we pull a long in and convert it's
bits to a double)
double d8(int _offset) {
return (Double.longBitsToDouble(u8(_offset)));
}
The previous version was
long u8(int _offset) {
return (((long) u4(_offset)) << 32 | u4(_offset + 4));
}
Sadly for values when the lower 32 bits had the most significant bit set this
was sign extending and causing the top 32 bits to all be 1's.
Now we have
long u8(int _offset) {
return ((u4(_offset)&0xffffffffL) << 32) |(u4(_offset + 4)&0xffffffffL);
}
This stops the sign extension from taking place.
This was my test case.
public class NaNTest{
public static void main(String[] args) {
Kernel k = new Kernel(){
@Override public void run() {
double gauss = (1.0e-10);
}
};
k.execute(1024);
}
}
Original comment by frost.g...@gmail.com
on 17 May 2012 at 4:29
Original issue reported on code.google.com by
helmut.s...@gmx.de
on 16 May 2012 at 10:00