bh107 / bohrium

Automatic parallelization of Python/NumPy, C, and C++ codes on Linux and MacOSX
http://www.bh107.org
Apache License 2.0
219 stars 31 forks source link

OpenCL: libmath functions explode for float64 #631

Open jamesavery opened 5 years ago

jamesavery commented 5 years ago

Both bh107 and bohrium explode when applying libmath functions (sin, cos, tanh, exp, etc.) to float64 data in OpenCL mode.

In [1]: import bohrium as bh                                                                                                                                                                                       
In [2]: A = bh.random.random((10))                                                                                                                                                                                 
In [3]: A.dtype                                                                                                                                                                                                    
Out[3]: dtype('float64')
In [4]: B = bh.tanh(A)                                                                                                                                                                                             
In [5]: bh.flush()                                                                                                                                                                                                 
Error code: -11
Error building: 
stringInput.cl:18:20: error: call to 'tanh' is ambiguous
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:34:20: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:133:19: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:1457:21: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:1458:21: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:1459:21: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:1460:21: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:1461:22: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:1462:20: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:1463:20: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:1464:20: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:1465:20: note: candidate function
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:1466:21: note: candidate function

terminate called after throwing an instance of 'cl::Error'
  what():  clBuildProgram
Aborted

bh107 does exactly the same. However, for float32 it works:

In [1]: import bohrium as bh                                                                                                                                                                                       
In [2]: A = bh.random.random((10)).astype(bh.float32)                                                                                                                                                              
In [3]: B = bh.tanh(A)                                                                                                                                                                                             
In [5]: bh.flush()                                                                                                                                                                                                 
In [6]: print(B)                                                                                                                                                                                                   
[0.7571309  0.37564066 0.19148484 0.27567866 0.7203832  0.5446466
 0.28313637 0.7497538  0.64565045 0.31858957]