c++ - Trying double precision math in openCL doesn't compile -
i trying double precision math operations in opencl kernel. have cl_khr_fp64 enabled , can simple +-*/ operations in double, when try use built in math functions (for example, exp ) code fails compile. if switch float works.
i read on khronos site math functions overloaded support double if enable cl_khr_fp64, did. (http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/mathfunctions.html)
i working on new macpro d700 gpu , read of math functions overloaded include double (http://developer.amd.com/knowledge-base/) exponential on list of included functions. also, when send code cpu instead of gpu fails well.
here's code of kernel. it's extension of hello world! example on apple developers site. if switch u float works or if replace exp(u) u (as in first part of conditional) works. toy problem i'm trying work before start implementing real code, have working before move one. i've tried double_exp, expd, , native_exp. lead code compiling runtime errors.
#pragma opencl extension cl_khr_fp64 : enable kernel void square5(global double* input, global double* output, double mul) { size_t = get_global_id(0); double u = 5.0; if(i==0) { output[i] = mul*u*input[i]*input[i]; } else if (i==1023) { output[i] = mul*u*input[i]*input[i]; } else { output[i] = 0.25*mul*exp(u)*(input[i-1] + input[i+1])*(input[i-1] + input[i+1]); } }
here's error log
/users/me/downloads/opencl_hello_world_example/mykernel.cl:12:30: error: call '__fast_relax_exp' ambiguous output[i] = 0.25*mul*exp(u)*(input[i-1] + input[i+1])*(input[i-1] + input[i+1]); ^~~~~~ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:4496:22: note: expanded macro 'exp' #define exp(__x) __fast_relax_exp(__x) ^~~~~~~~~~~~~~~~ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:4494:30: note: candidate function __clfn_fd_1fd_fast_relax(__fast_relax_exp, native_exp, __cl_exp); ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:416:27: note: expanded macro '__clfn_fd_1fd_fast_relax' inline float __overload__ _name(float x) { return _default_name(x); } \ ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:4494:30: note: candidate function __clfn_fd_1fd_fast_relax(__fast_relax_exp, native_exp, __cl_exp); ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:417:28: note: expanded macro '__clfn_fd_1fd_fast_relax' inline float2 __overload__ _name(float2 x) { return _default_name(x); } \ ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:4494:30: note: candidate function __clfn_fd_1fd_fast_relax(__fast_relax_exp, native_exp, __cl_exp); ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:418:28: note: expanded macro '__clfn_fd_1fd_fast_relax' inline float3 __overload__ _name(float3 x) { return _default_name(x); } \ ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:4494:30: note: candidate function __clfn_fd_1fd_fast_relax(__fast_relax_exp, native_exp, __cl_exp); ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:419:28: note: expanded macro '__clfn_fd_1fd_fast_relax' inline float4 __overload__ _name(float4 x) { return _default_name(x); } \ ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:4494:30: note: candidate function __clfn_fd_1fd_fast_relax(__fast_relax_exp, native_exp, __cl_exp); ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:420:28: note: expanded macro '__clfn_fd_1fd_fast_relax' inline float8 __overload__ _name(float8 x) { return _default_name(x); } \ ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:4494:30: note: candidate function __clfn_fd_1fd_fast_relax(__fast_relax_exp, native_exp, __cl_exp); ^ /system/library/frameworks/opencl.framework/versions/a/libraries/../lib/clang/3.2/include/cl_kernel.h:421:29: note: expanded macro '__clfn_fd_1fd_fast_relax' inline float16 __overload__ _name(float16 x){ return _default_name(x); } ^ 1 error generated. command /system/library/frameworks/opencl.framework/libraries/openclc failed exit code 1
Comments
Post a Comment