From aaafa1e9c290b238350f5335caa57cfc1856037c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Sun, 15 Jun 2014 22:13:52 +0100 Subject: [PATCH] =?UTF-8?q?Realize=20Lo=C3=AFc=20Damien's=20fix=20for=20gw?= =?UTF-8?q?0's=20warnings=20silencer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/fortran-to-opencl/translate.py | 2 +- pyopencl/_cluda.py | 2 +- pyopencl/algorithm.py | 2 +- pyopencl/clrandom.py | 2 +- pyopencl/elementwise.py | 6 +++--- pyopencl/reduction.py | 2 +- pyopencl/tools.py | 6 ++++-- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/contrib/fortran-to-opencl/translate.py b/contrib/fortran-to-opencl/translate.py index 18f84786..d0355423 100644 --- a/contrib/fortran-to-opencl/translate.py +++ b/contrib/fortran-to-opencl/translate.py @@ -1344,7 +1344,7 @@ def f2cl(source, free_form=False, strict=True, import pyopencl as cl ctx = cl.create_some_context() cl.Program(ctx, """ - #ifndef cl_khr_fp64 + #if __OPENCL_VERSION__ <= CL_VERSION_1_1 #pragma OPENCL EXTENSION cl_khr_fp64: enable #endif #include <pyopencl-complex.h> diff --git a/pyopencl/_cluda.py b/pyopencl/_cluda.py index f4aaec21..40b2fad7 100644 --- a/pyopencl/_cluda.py +++ b/pyopencl/_cluda.py @@ -50,7 +50,7 @@ CLUDA_PREAMBLE = """ #define GDIM_2 get_num_groups(2) % if double_support: - #ifndef cl_khr_fp64 + #if __OPENCL_VERSION__ <= CL_VERSION_1_1 #pragma OPENCL EXTENSION cl_khr_fp64: enable #endif % endif diff --git a/pyopencl/algorithm.py b/pyopencl/algorithm.py index 72975b79..286fdbdd 100644 --- a/pyopencl/algorithm.py +++ b/pyopencl/algorithm.py @@ -558,7 +558,7 @@ class RadixSort(object): _LIST_BUILDER_TEMPLATE = Template("""//CL// % if double_support: - #ifndef cl_khr_fp64 + #if __OPENCL_VERSION__ <= CL_VERSION_1_1 #pragma OPENCL EXTENSION cl_khr_fp64: enable #endif #define PYOPENCL_DEFINE_CDOUBLE diff --git a/pyopencl/clrandom.py b/pyopencl/clrandom.py index f05994ee..b8176c4c 100644 --- a/pyopencl/clrandom.py +++ b/pyopencl/clrandom.py @@ -168,7 +168,7 @@ class RanluxGenerator(object): lines = [] if include_double_pragma and self.support_double: lines.append(""" - #ifndef cl_khr_fp64 + #if __OPENCL_VERSION__ <= CL_VERSION_1_1 #pragma OPENCL EXTENSION cl_khr_fp64: enable #endif """) diff --git a/pyopencl/elementwise.py b/pyopencl/elementwise.py index 2661b35e..0291d4bd 100644 --- a/pyopencl/elementwise.py +++ b/pyopencl/elementwise.py @@ -127,7 +127,7 @@ def get_elwise_kernel_and_types(context, arguments, operation, if arg.dtype in [np.float64, np.complex128]: if not have_double_pragma: pragmas.append(""" - #ifndef cl_khr_fp64 + #if __OPENCL_VERSION__ <= CL_VERSION_1_1 #pragma OPENCL EXTENSION cl_khr_fp64: enable #endif #define PYOPENCL_DEFINE_CDOUBLE @@ -846,7 +846,7 @@ def get_float_binary_func_kernel(context, func_name, x_dtype, y_dtype, if (np.array(0, x_dtype) * np.array(0, y_dtype)).itemsize > 4: arg_type = 'double' preamble = """ - #ifndef cl_khr_fp64 + #if __OPENCL_VERSION__ <= CL_VERSION_1_1 #pragma OPENCL EXTENSION cl_khr_fp64: enable #endif #define PYOPENCL_DEFINE_CDOUBLE @@ -920,7 +920,7 @@ def get_bessel_kernel(context, which_func, out_dtype=np.float64, "z[i] = bessel_%sn(ord_n, x[i])" % which_func, name="bessel_%sn_kernel" % which_func, preamble=""" - #ifndef cl_khr_fp64 + #if __OPENCL_VERSION__ <= CL_VERSION_1_1 #pragma OPENCL EXTENSION cl_khr_fp64: enable #endif #define PYOPENCL_DEFINE_CDOUBLE diff --git a/pyopencl/reduction.py b/pyopencl/reduction.py index 74d9f964..99ebbc39 100644 --- a/pyopencl/reduction.py +++ b/pyopencl/reduction.py @@ -47,7 +47,7 @@ KERNEL = """//CL// #define REDUCE(a, b) (${reduce_expr}) % if double_support: - #ifndef cl_khr_fp64 + #if __OPENCL_VERSION__ <= CL_VERSION_1_1 #pragma OPENCL EXTENSION cl_khr_fp64: enable #endif #define PYOPENCL_DEFINE_CDOUBLE diff --git a/pyopencl/tools.py b/pyopencl/tools.py index 03946779..990838df 100644 --- a/pyopencl/tools.py +++ b/pyopencl/tools.py @@ -506,7 +506,7 @@ class _CDeclList: if self.saw_double: result = ( """ - #ifndef cl_khr_fp64 + #if __OPENCL_VERSION__ <= CL_VERSION_1_1 #pragma OPENCL EXTENSION cl_khr_fp64: enable #endif #define PYOPENCL_DEFINE_CDOUBLE @@ -523,6 +523,7 @@ else: key=lambda device, name, dtype, context=None: (device, name, _dtype_to_key(dtype), context)) + @_memoize_match_dtype_to_c_struct def match_dtype_to_c_struct(device, name, dtype, context=None): """Return a tuple `(dtype, c_decl)` such that the C struct declaration @@ -674,10 +675,11 @@ def match_dtype_to_c_struct(device, name, dtype, context=None): if _dtype_hashable: _memoize_dtype_to_c_struct = memoize else: - import json as _json + import json as _json # noqa _memoize_dtype_to_c_struct = memoize( key=lambda device, dtype: (device, _dtype_to_key(dtype))) + @_memoize_dtype_to_c_struct def dtype_to_c_struct(device, dtype): matched_dtype, c_decl = match_dtype_to_c_struct( -- GitLab