From 5a2a29fb932d0069e5ef98765a56b4fa19297560 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 17 Aug 2015 13:40:33 -0500 Subject: [PATCH] Update compyte, add stubs to work with legacy PyOpenCL --- .gitlab-ci.yml | 4 ++-- loopy/target/c/__init__.py | 4 ++-- loopy/target/c/compyte | 2 +- loopy/target/opencl/__init__.py | 14 +++++--------- loopy/target/pyopencl/__init__.py | 20 ++++++++++++++++++-- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index be30067d8..f79c22be5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,10 +35,10 @@ Python 2.7 POCL: - pocl except: - tags -Python 2.7 old PyOpenCL: +Python 2.7 with legacy PyOpenCL: script: - export PY_EXE=python2.7 - - export PYOPENCL_TEST=portable + - export PYOPENCL_TEST=amd:pu - export EXTRA_INSTALL="numpy mako" - export REQUIREMENTS_TXT="requirements-old-pyopencl.txt" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh diff --git a/loopy/target/c/__init__.py b/loopy/target/c/__init__.py index 8620996b0..520bb8a33 100644 --- a/loopy/target/c/__init__.py +++ b/loopy/target/c/__init__.py @@ -36,9 +36,9 @@ class CTarget(TargetBase): @memoize_method def get_dtype_registry(self): from loopy.target.c.compyte.dtypes import ( - DTypeRegistry, fill_with_registry_with_c_types) + DTypeRegistry, fill_registry_with_c_types) result = DTypeRegistry() - fill_with_registry_with_c_types(result, respect_windows=False, + fill_registry_with_c_types(result, respect_windows=False, include_bool=True) return result diff --git a/loopy/target/c/compyte b/loopy/target/c/compyte index fb6ba114d..ac1c71d46 160000 --- a/loopy/target/c/compyte +++ b/loopy/target/c/compyte @@ -1 +1 @@ -Subproject commit fb6ba114d9d906403d47b0aaf69e2fe4cef382f2 +Subproject commit ac1c71d46428c14aa1bd1c09d7da19cd0298d5cc diff --git a/loopy/target/opencl/__init__.py b/loopy/target/opencl/__init__.py index e4533b86d..8392a7a91 100644 --- a/loopy/target/opencl/__init__.py +++ b/loopy/target/opencl/__init__.py @@ -214,17 +214,13 @@ class OpenCLTarget(CTarget): @memoize_method def get_dtype_registry(self): - from loopy.target.c.compyte.dtypes import DTypeRegistry, fill_with_registry_with_c_types - result = DTypeRegistry() - fill_with_registry_with_c_types(result, respect_windows=False) + from loopy.target.c.compyte.dtypes import (DTypeRegistry, + fill_registry_with_opencl_types) - # complex number support left out + result = DTypeRegistry() + fill_registry_with_opencl_types() - # CL defines 'long' as 64-bit - result.get_or_register_dtype( - ["unsigned long", "unsigned long int"], np.uint64) - result.get_or_register_dtype( - ["signed long", "signed long int", "long int"], np.int64) + # no complex number support--needs PyOpenCLTarget _register_vector_types(result) diff --git a/loopy/target/pyopencl/__init__.py b/loopy/target/pyopencl/__init__.py index ee9366800..d13384534 100644 --- a/loopy/target/pyopencl/__init__.py +++ b/loopy/target/pyopencl/__init__.py @@ -233,6 +233,18 @@ def pyopencl_preamble_generator(target, seen_dtypes, seen_functions): # {{{ pyopencl tools +class _LegacyTypeRegistryStub(object): + """Adapts legacy PyOpenCL type registry to be usable with PyOpenCLTarget.""" + + def get_or_register_dtype(self, names, dtype=None): + from pyopencl.compyte.dtypes import get_or_register_dtype + return get_or_register_dtype(names, dtype) + + def dtype_to_ctype(self, dtype): + from pyopencl.compyte.dtypes import dtype_to_ctype + return dtype_to_ctype(dtype) + + class PyOpenCLTarget(OpenCLTarget): def __init__(self, device=None): super(PyOpenCLTarget, self).__init__() @@ -260,8 +272,12 @@ class PyOpenCLTarget(OpenCLTarget): check_sizes(kernel, self.device) def get_dtype_registry(self): - from pyopencl.compyte.dtypes import TYPE_REGISTRY - return TYPE_REGISTRY + try: + from pyopencl.compyte.dtypes import TYPE_REGISTRY + except ImportError: + return _LegacyTypeRegistryStub() + else: + return TYPE_REGISTRY def is_vector_dtype(self, dtype): from pyopencl.array import vec -- GitLab