From aa8457c51b184fa16cad6f69ccf50bd193b906f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Tue, 23 Oct 2018 14:37:29 -0400 Subject: [PATCH 1/4] Add a Titan V CI job --- .gitlab-ci.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 770469c2..ed248257 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,7 +52,7 @@ Python 3.6 AMD CPU: Python 3.6 Titan X: script: - - export PY_EXE=python3.5 + - export PY_EXE=python3.6 - export PYOPENCL_TEST=nvi:titan - export EXTRA_INSTALL="pybind11 numpy mako" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh @@ -66,6 +66,22 @@ Python 3.6 Titan X: reports: junit: test/pytest.xml +Python 3.6 Titan V: + script: + - export PY_EXE=python3.6 + - export PYOPENCL_TEST=nvi:titan + - export EXTRA_INSTALL="pybind11 numpy mako" + - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh + - ". ./build-and-test-py-project.sh" + tags: + - python3.6 + - nvidia-titan-v + except: + - tags + artifacts: + reports: + junit: test/pytest.xml + Python 3.6 K40: script: - export PY_EXE=python3.6 -- GitLab From 885b6b3b401600930871c8959792af8789a7bca5 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 27 Oct 2018 22:11:06 -0500 Subject: [PATCH 2/4] Fix race condition in test_fancy_indexing --- test/test_array.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/test/test_array.py b/test/test_array.py index 3e74bcf0..3f2aa3fa 100644 --- a/test/test_array.py +++ b/test/test_array.py @@ -1170,28 +1170,25 @@ def test_fancy_indexing(ctx_factory): context = ctx_factory() queue = cl.CommandQueue(context) - numpy_dest = np.zeros((4,), np.int32) - numpy_idx = np.arange(3, 0, -1, dtype=np.int32) - numpy_src = np.arange(8, 11, dtype=np.int32) - numpy_dest[numpy_idx] = numpy_src - - cl_dest = cl_array.zeros(queue, (4,), np.int32) - cl_idx = cl_array.arange(queue, 3, 0, -1, dtype=np.int32) - cl_src = cl_array.arange(queue, 8, 11, dtype=np.int32) - cl_dest[cl_idx] = cl_src + n = 2 ** 20 + 2**18 + 22 + numpy_dest = np.zeros(n, dtype=np.int32) + numpy_idx = np.arange(n, dtype=np.int32) + np.random.shuffle(numpy_idx) + numpy_src = 20000+np.arange(n, dtype=np.int32) - assert np.all(numpy_dest == cl_dest.get()) - - cl_idx[1] = 3 - cl_idx[2] = 2 - - numpy_idx[1] = 3 - numpy_idx[2] = 2 + cl_dest = cl_array.to_device(queue, numpy_dest) + cl_idx = cl_array.to_device(queue, numpy_idx) + cl_src = cl_array.to_device(queue, numpy_src) numpy_dest[numpy_idx] = numpy_src cl_dest[cl_idx] = cl_src - assert np.all(numpy_dest == cl_dest.get()) + assert np.array_equal(numpy_dest, cl_dest.get()) + + numpy_dest = numpy_src[numpy_idx] + cl_dest = cl_src[cl_idx] + + assert np.array_equal(numpy_dest, cl_dest.get()) def test_multi_put(ctx_factory): -- GitLab From ce381a5c9b800dad11a279adfbcc41e5b557f29e Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 27 Oct 2018 22:49:12 -0500 Subject: [PATCH 3/4] Placate flake8 3.6 --- pyopencl/_buffers.py | 2 +- pyopencl/characterize/__init__.py | 16 ++++++++-------- test/test_wrapper.py | 24 ++++++++++++------------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pyopencl/_buffers.py b/pyopencl/_buffers.py index 27cf4f4c..bbf81a2f 100644 --- a/pyopencl/_buffers.py +++ b/pyopencl/_buffers.py @@ -106,7 +106,7 @@ try: CheckBuffer = ctypes.pythonapi.PyObject_CheckBuffer CheckBuffer.argtypes = [ctypes.py_object] CheckBuffer.restype = ctypes.c_int -except AttributeError as err: +except AttributeError: # Python 2.6 doesn't appear to have CheckBuffer support... def CheckBuffer(x): # noqa return True diff --git a/pyopencl/characterize/__init__.py b/pyopencl/characterize/__init__.py index 873e1c11..eae523be 100644 --- a/pyopencl/characterize/__init__.py +++ b/pyopencl/characterize/__init__.py @@ -390,8 +390,8 @@ def has_struct_arg_count_bug(dev, ctx=None): def _may_have_svm(dev): - has_svm = (dev.platform._get_cl_version() >= (2, 0) and - cl.get_cl_header_version() >= (2, 0)) + has_svm = (dev.platform._get_cl_version() >= (2, 0) + and cl.get_cl_header_version() >= (2, 0)) if dev.platform.name == "Portable Computing Language": has_svm = ( @@ -402,18 +402,18 @@ def _may_have_svm(dev): def has_coarse_grain_buffer_svm(dev): - return (_may_have_svm(dev) and - bool(dev.svm_capabilities + return (_may_have_svm(dev) + and bool(dev.svm_capabilities & cl.device_svm_capabilities.COARSE_GRAIN_BUFFER)) def has_fine_grain_buffer_svm(dev): - return (_may_have_svm(dev) and - bool(dev.svm_capabilities + return (_may_have_svm(dev) + and bool(dev.svm_capabilities & cl.device_svm_capabilities.FINE_GRAIN_BUFFER)) def has_fine_grain_system_svm(dev): - return (_may_have_svm(dev) and - bool(dev.svm_capabilities + return (_may_have_svm(dev) + and bool(dev.svm_capabilities & cl.device_svm_capabilities.FINE_GRAIN_SYSTEM)) diff --git a/test/test_wrapper.py b/test/test_wrapper.py index fff07e0d..fba8ceb9 100644 --- a/test/test_wrapper.py +++ b/test/test_wrapper.py @@ -667,8 +667,8 @@ def test_wait_for_events(ctx_factory): def test_unload_compiler(platform): - if (platform._get_cl_version() < (1, 2) or - cl.get_cl_header_version() < (1, 2)): + if (platform._get_cl_version() < (1, 2) + or cl.get_cl_header_version() < (1, 2)): from pytest import skip skip("clUnloadPlatformCompiler is only available in OpenCL 1.2") _skip_if_pocl(platform, (0, 13), 'pocl does not support unloading compiler') @@ -688,8 +688,8 @@ def test_platform_get_devices(ctx_factory): dev_types = [cl.device_type.ACCELERATOR, cl.device_type.ALL, cl.device_type.CPU, cl.device_type.DEFAULT, cl.device_type.GPU] - if (platform._get_cl_version() >= (1, 2) and - cl.get_cl_header_version() >= (1, 2) + if (platform._get_cl_version() >= (1, 2) + and cl.get_cl_header_version() >= (1, 2) and not platform.name.lower().startswith("nvidia")): dev_types.append(cl.device_type.CUSTOM) @@ -706,8 +706,8 @@ def test_platform_get_devices(ctx_factory): def test_user_event(ctx_factory): ctx = ctx_factory() - if (ctx._get_cl_version() < (1, 1) and - cl.get_cl_header_version() < (1, 1)): + if (ctx._get_cl_version() < (1, 1) + and cl.get_cl_header_version() < (1, 1)): from pytest import skip skip("UserEvent is only available in OpenCL 1.1") @@ -762,8 +762,8 @@ def test_buffer_get_host_array(ctx_factory): buf = cl.Buffer(ctx, mf.READ_WRITE | mf.USE_HOST_PTR, hostbuf=host_buf) host_buf2 = buf.get_host_array(25, np.float32) assert (host_buf == host_buf2).all() - assert (host_buf.__array_interface__['data'][0] == - host_buf.__array_interface__['data'][0]) + assert (host_buf.__array_interface__['data'][0] + == host_buf.__array_interface__['data'][0]) assert host_buf2.base is buf buf = cl.Buffer(ctx, mf.READ_WRITE | mf.ALLOC_HOST_PTR, size=100) @@ -887,8 +887,8 @@ def test_global_offset(ctx_factory): def test_sub_buffers(ctx_factory): ctx = ctx_factory() - if (ctx._get_cl_version() < (1, 1) or - cl.get_cl_header_version() < (1, 1)): + if (ctx._get_cl_version() < (1, 1) + or cl.get_cl_header_version() < (1, 1)): from pytest import skip skip("sub-buffers are only available in OpenCL 1.1") @@ -917,8 +917,8 @@ def test_spirv(ctx_factory): ctx = ctx_factory() queue = cl.CommandQueue(ctx) - if (ctx._get_cl_version() < (2, 1) or - cl.get_cl_header_version() < (2, 1)): + if (ctx._get_cl_version() < (2, 1) + or cl.get_cl_header_version() < (2, 1)): from pytest import skip skip("SPIR-V program creation only available in OpenCL 2.1 and higher") -- GitLab From ff539e30e2fe07ed374e62ab1d97ccc11677faf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Sun, 28 Oct 2018 00:02:34 -0400 Subject: [PATCH 4/4] Placate flake8 3.6 harder --- test/test_clmath.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/test_clmath.py b/test/test_clmath.py index beebc2a8..9c844016 100644 --- a/test/test_clmath.py +++ b/test/test_clmath.py @@ -1,6 +1,4 @@ -from __future__ import division, print_function -from __future__ import absolute_import -from six.moves import range +from __future__ import division, print_function, absolute_import __copyright__ = "Copyright (C) 2009 Andreas Kloeckner" @@ -24,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +from six.moves import range + import math import numpy as np @@ -298,8 +298,7 @@ def test_bessel(ctx_factory): if use_pyfmmlib and ( which_func == "j" - or - (which_func == "y" and n in [0, 1])): + or (which_func == "y" and n in [0, 1])): pyfmm_bessel = pfymm_result[:, n] error_pyfmm = get_err(cl_bessel, pyfmm_bessel) assert error_pyfmm < 1e-10, error_pyfmm -- GitLab