{"action":"opened","issue":{"url":"https://api.github.com/repos/arrayfire/arrayfire/issues/1020","labels_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/1020/labels{/name}","comments_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/1020/comments","events_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/1020/events","html_url":"https://github.com/arrayfire/arrayfire/issues/1020","id":108143814,"number":1020,"title":"languages using C interface do not have single precision float datatypes","user":{"login":"Pascal-J","id":10227663,"avatar_url":"https://avatars.githubusercontent.com/u/10227663?v=3","gravatar_id":"","url":"https://api.github.com/users/Pascal-J","html_url":"https://github.com/Pascal-J","followers_url":"https://api.github.com/users/Pascal-J/followers","following_url":"https://api.github.com/users/Pascal-J/following{/other_user}","gists_url":"https://api.github.com/users/Pascal-J/gists{/gist_id}","starred_url":"https://api.github.com/users/Pascal-J/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pascal-J/subscriptions","organizations_url":"https://api.github.com/users/Pascal-J/orgs","repos_url":"https://api.github.com/users/Pascal-J/repos","events_url":"https://api.github.com/users/Pascal-J/events{/privacy}","received_events_url":"https://api.github.com/users/Pascal-J/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-24T14:36:17Z","updated_at":"2015-09-24T14:36:17Z","closed_at":null,"body":"version 3.1.1 win64\r\n\r\nThe J language can pass  single or double precision float from its 64 bit version.  It is able to truncate them, and pass it to Afire, and if the device supports double precision, it appears to be ok, only if doubles are passed, though there is weird behaviour when passing single.\r\n\r\nThe major problem is for a device that does not support double precision.  There is no way for J to pass actual single precision numbers.  And the array is not created (error 401) even if numbers are truncated to single precision.\r\n\r\n\r\nWHEN SET TO SINGLE PRECISION PARAMETER PASSING\r\nDEVICE 1: GPU supports double.\r\n                  R a [ pD 0j16\": Jf a =. chkerR f32 Atypedf_afopencl_ \". \": %: 3 3 $ 1 2 3 5 6 7 8 10 11  NB. truncated f32                   \r\n    1.0000000000000000 1.4142099618911743 1.7320499420166016                                                                       \r\n    2.2360699176788330 2.4494900703430176 2.6457500457763672                                                                       \r\n    2.8284299373626709 3.1622800827026367 3.3166201114654541                                                                       \r\n    0                                                                                                                              \r\n      R a_base_ [pD 0j16\": Jf a_base_ =: chkerR f32 Atypedf_afopencl_ %: 3 3 $ 1 2 3 5 6 7 8 10 11 NB. not truncated f32           \r\n    1.0000000000000000 1.4142135381698608 1.7320507764816284                                                                       \r\n    2.2360680103302002 2.4494898319244385 2.6457512378692627                                                                       \r\n    2.8284270763397217 3.1622776985168457 3.3166248798370361                                                                       \r\n    0                                                                                                                              \r\n      0j16\": JfR chkerR Af_afopencl_ %: 3 3 $ 1 2 3 5 6 7 8 10 11 NB. crashes if device has no double support NB. f64 not truncated\r\n    1.0000000000000000 1.4142135381698608 1.7320507764816284                                                                       \r\n    2.2360680103302002 2.4494898319244385 2.6457512378692627                                                                       \r\n    2.8284270763397217 3.1622776985168457 3.3166248798370361                                                                       \r\n      0j16\": %: 3 3 $ 1 2 3 5 6 7 8 10 11 NB. What J thinks it should get back                                                     \r\n    1.0000000000000000 1.4142135623730951 1.7320508075688772                                                                       \r\n    2.2360679774997898 2.4494897427831779 2.6457513110645907                                                                       \r\n    2.8284271247461903 3.1622776601683795 3.3166247903553998                                                                       \r\n\r\nabove has very sensible behaviour, except for truncated values. results 2 and 3 are identical which is success.  And indicates work around for doubles.\r\n\r\nON DEVICE 0 without double support.  Non error results: (3rd above is 401 error)\r\n\r\n      R a [ pD 0j16\": Jf a =. chkerR f32 Atypedf_afopencl_ \". \": %: 3 3 $ 1 2 3 5 6 7 8 10 11  NB. truncated f32        \r\n    1.0000000000000000 1.4142099618911743 1.7320499420166016                                                            \r\n    2.2360699176788330 2.4494900703430176 2.6457500457763672                                                            \r\n    2.8284299373626709 3.1622800827026367 3.3166201114654541                                                            \r\n    0                                                                                                                   \r\n      R a_base_ [pD 0j16\": Jf a_base_ =: chkerR f32 Atypedf_afopencl_ %: 3 3 $ 1 2 3 5 6 7 8 10 11 NB. not truncated f32\r\n    1.0000000000000000 1.4142135381698608 1.7320507764816284                                                            \r\n    2.2360680103302002 2.4494898319244385 2.6457512378692627                                                            \r\n    2.8284270763397217 3.1622776985168457 3.3166248798370361          \r\n\r\nabove has at least good news of matching device 1's  1st and 2nd result.  Truncated values though on both seem off.\r\n\r\nWHEN SET TO DOUBLE PARAMETER PASSING  \r\nDEVICE 1:\r\n\r\n      R a [ pD 0j16\": Jf a =. chkerR f32 Atypedf_afopencl_ \". \": %: 3 3 $ 1 2 3 5 6 7 8 10 11  NB. truncated f32                   \r\n    1.0000000000000000 1.4142100000000000 1.7320500000000001                                                                       \r\n    2.2360699999999998 0.5000001016235351 0.5000000000000000                                                                       \r\n    0.5000000000000000 0.5000000000000000 0.5000000000000000                                                                       \r\n    0                                                                                                                              \r\n      R a_base_ [pD 0j16\": Jf a_base_ =: chkerR f32 Atypedf_afopencl_ %: 3 3 $ 1 2 3 5 6 7 8 10 11 NB. not truncated f32           \r\n    1.0000000000000000 1.4142135623730951 1.7320508075688772                                                                       \r\n    2.2360679774997898 0.5000000373193296 0.5000000000000000                                                                       \r\n    0.5000000000000000 0.5000000000000000 0.5000000000000000                                                                       \r\n    0                                                                                                                              \r\n      0j16\": JfR chkerR Af_afopencl_ %: 3 3 $ 1 2 3 5 6 7 8 10 11 NB. crashes if device has no double support NB. f64 not truncated\r\n    1.0000000000000000 1.4142135623730951 1.7320508075688772                                                                       \r\n    2.2360679774997898 2.4494897427831779 2.6457513110645907                                                                       \r\n    2.8284271247461903 3.1622776601683795 3.3166247903553998                                                                       \r\n      0j16\": %: 3 3 $ 1 2 3 5 6 7 8 10 11 NB. What J thinks it should get back                                                     \r\n    1.0000000000000000 1.4142135623730951 1.7320508075688772                                                                       \r\n    2.2360679774997898 2.4494897427831779 2.6457513110645907                                                                       \r\n    2.8284271247461903 3.1622776601683795 3.3166247903553998       \r\n\r\nabove is perfect for f64, but for f32  Only half the actual parameters are passed, or read back (this may be problem in my reader code, that is solved by applying previous sections workarounds) (truncated f32 parameters that are read back are all exactly correct though)\r\n\r\nDEVICE 0:\r\n\r\n     R a [ pD 0j16\": Jf a =. chkerR f32 Atypedf_afopencl_ \". \": %: 3 3 $ 1 2 3 5 6 7 8 10 11  NB. truncated f32        \r\n    1.0000000000000000 1.4142100000000000 1.7320500000000001                                                            \r\n    2.2360699999999998 0.5000001016235351 0.5000000000000000                                                            \r\n    0.5000000000000000 0.5000000000000000 0.5000000000000000                                                            \r\n    0                                                                                                                   \r\n      R a_base_ [pD 0j16\": Jf a_base_ =: chkerR f32 Atypedf_afopencl_ %: 3 3 $ 1 2 3 5 6 7 8 10 11 NB. not truncated f32\r\n    1.0000000000000000 1.4142135623730951 1.7320508075688772                                                            \r\n    2.2360679774997898 0.5000000373193296 0.5000000000000000                                                            \r\n    0.5000000000000000 0.5000000000000000 0.5000000000000000   \r\n\r\nRESOLUTIONS:\r\n\r\ndon't call the crashing code :) use single precision with f32, double precision with f64.  \r\nThe rounding difference issues with J on single precision numbers are minor.  You don't need to pretruncate numbers to get single precision, so don't.  If you need exactly 5 decimal points, use truncated with doubles."}}