From 0714897c564817e7a32a6eb6017df1b207f2f60c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 30 Jan 2012 21:12:11 -0500 Subject: [PATCH] Enable complex double support only upon request. --- doc/source/array.rst | 7 +++++++ pyopencl/elementwise.py | 4 +++- src/cl/pyopencl-complex.h | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/source/array.rst b/doc/source/array.rst index 3d3ccbc7..8df254c5 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 f9b115b1..a4ec223e 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 8e4093f2..2709ea42 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 -- GitLab