Error using float numbers inside kernel

24 views
Skip to first unread message

Marcos Paulo Rocha

unread,
Oct 30, 2016, 6:58:02 PM10/30/16
to NativeLibs4Java
Hi, 
I'm new to JavaCL and I was trying to write an application and I noticed a strange behavior using floating points like 0,5 and 1,5. When I multiply some value to these numbers or set them to an array or variable, the decimal part is gone.
Modifying the VectorAdd example in the javacl-demos project to put this kind of number in every position of the output buffer, it results in the same error. Setting these values to a variable and print them inside the kernel, results in the same error too.
I runned this code in a GeForce GTX 750 Ti with OpenCL 1.2.
I'm adding some screenshots to illustrate this behavior.
Any ideas on how to solve this problem 



atribute float value error2.png
atribute float value error.png

Marcin Copik

unread,
Oct 30, 2016, 9:59:42 PM10/30/16
to NativeLibs4Java
Marcos,

is it possible that your locale settings are set to use language where decimal mark in a floating point number is a comma, not a point? I've found a bug in JavaCL where those settings have been affecting the kernel and each floating point hardcoded in kernel has lost its decimal part. My suspicion is that this problem has been caused by how strings are handled in Java.
The easiest way to solve it is to change your system settings. On most of Linux distributions, it should be sufficient to change LC_NUMERIC in locale to standard corresponding to a country where decimal point is used in floating point numbers, e.g. en_US.UTF-8.

I have submitted a bug, but unfortunately it is still not fixed:
https://github.com/nativelibs4java/JavaCL/issues/22

Best regards,
Marcin

--
You received this message because you are subscribed to the Google Groups "NativeLibs4Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nativelibs4ja...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcos Paulo Rocha

unread,
Oct 31, 2016, 10:09:21 PM10/31/16
to NativeLibs4Java
Thanks a lot Marcin, change the locale solve the problem. 
Reply all
Reply to author
Forward
0 new messages