diff --git a/doc/source/array.rst b/doc/source/array.rst index 3d3ccbc78552602657a946dc8e301a664572988c..8df254c58275eadba9c07b298e063537dba05fcf 100644 --- a/doc/source/array.rst +++ b/doc/source/array.rst @@ -396,6 +396,13 @@ See the `source file `_ for a precise list of what's available. +If you need double precision support, please:: + + #define PYOPENCL_DEFINE_CDOUBLE + +before including the header, as DP support apparently cannot be reliably +autodetected. + Under the hood, the complex types are simply `float2` and `double2`. .. warning:: diff --git a/pyopencl/elementwise.py b/pyopencl/elementwise.py index f9b115b192082dfc80e66d425401be4d83ca63c4..a4ec223e7a0f251230b49bee2511526af9a37ce1 100644 --- a/pyopencl/elementwise.py +++ b/pyopencl/elementwise.py @@ -85,7 +85,9 @@ def get_elwise_kernel_and_types(context, arguments, operation, for arg in parsed_args: if arg.dtype in [np.float64, np.complex128]: if not have_double_pragma: - pragmas.append("#pragma OPENCL EXTENSION cl_khr_fp64: enable\n") + pragmas.append( + "#pragma OPENCL EXTENSION cl_khr_fp64: enable\n" + "#define PYOPENCL_DEFINE_CDOUBLE\n") have_double_pragma = True if arg.dtype.kind == 'c': if not have_complex_include: diff --git a/src/cl/pyopencl-complex.h b/src/cl/pyopencl-complex.h index 8e4093f2e3c99100c59a4cbe41334776ceaad2a6..2709ea422506d1100aeaa2f85e0c9010700ffaa1 100644 --- a/src/cl/pyopencl-complex.h +++ b/src/cl/pyopencl-complex.h @@ -219,7 +219,7 @@ PYOPENCL_DECLARE_COMPLEX_TYPE(float, FLT); #define cfloat_cast(a) ((cfloat_t) ((a).x, (a).y)) -#ifdef DBL_EPSILON +#ifdef PYOPENCL_DEFINE_CDOUBLE PYOPENCL_DECLARE_COMPLEX_TYPE(double, DBL); #define cdouble_cast(a) ((cdouble_t) ((a).x, (a).y)) #endif