From 547479ac4aecb4fc8701a2afbe51a1ab8e6aa413 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Mon, 1 Feb 2021 10:08:17 -0800 Subject: [PATCH 1/6] fix generate_integer_arg_finding_from_stridesi opt case --- loopy/target/execution.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/loopy/target/execution.py b/loopy/target/execution.py index 74887155b..2970fe040 100644 --- a/loopy/target/execution.py +++ b/loopy/target/execution.py @@ -293,8 +293,9 @@ class ExecutionWrapperGeneratorBase: % (stride_impl_axis, impl_array_name)) gen("del _lpy_remdr") else: - gen("%s = _lpy_offset // %d" - % (arg.name, base_arg.dtype.itemsize)) + gen("%s = %s.strides[%d] // %d" + % (arg.name, impl_array_name, stride_impl_axis, + base_arg.dtype.itemsize)) gen("# }}}") gen("") -- GitLab From 2d11219abaf9ab2826ce7992c8aae75986f4f9c5 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 1 Feb 2021 17:15:34 -0600 Subject: [PATCH 2/6] Check env var _LOOPY_SKIP_ARG_CHECKS for skip_arg_checks option default --- loopy/options.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/loopy/options.py b/loopy/options.py index 46ff37947..166dcdaa1 100644 --- a/loopy/options.py +++ b/loopy/options.py @@ -23,6 +23,7 @@ THE SOFTWARE. from pytools import ImmutableRecord import re +import os ALLOW_TERMINAL_COLORS = True @@ -210,7 +211,9 @@ class Options(ImmutableRecord): trace_assignments=kwargs.get("trace_assignments", False), trace_assignment_values=kwargs.get("trace_assignment_values", False), - skip_arg_checks=kwargs.get("skip_arg_checks", sys.flags.optimize), + skip_arg_checks=kwargs.get("skip_arg_checks", + sys.flags.optimize + or bool(os.environ.get("_LOOPY_SKIP_ARG_CHECKS"))), no_numpy=kwargs.get("no_numpy", False), cl_exec_manage_array_events=kwargs.get("no_numpy", True), return_dict=kwargs.get("return_dict", False), -- GitLab From b90c9fbae019cb1987840ceb8c01a3d2e00757fd Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 1 Feb 2021 17:15:54 -0600 Subject: [PATCH 3/6] Add CI jobs for test without arg check --- .github/workflows/ci.yml | 12 ++++++++++++ .gitlab-ci.yml | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05b2e3237..4c2feece5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,18 @@ jobs: curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project-within-miniconda.sh . ./build-and-test-py-project-within-miniconda.sh + pytest: + name: Conda Pytest without arg check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: "Main Script" + run: | + CONDA_ENVIRONMENT=.test-conda-env-py3.yml + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project-within-miniconda.sh + export _LOOPY_SKIP_ARG_CHECKS=1 + . ./build-and-test-py-project-within-miniconda.sh + pytest_twice: name: Conda Pytest Twice (for cache behavior) runs-on: ubuntu-latest diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f0e9aa0e5..4886d47d9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,6 +15,24 @@ Python 3 POCL: reports: junit: test/pytest.xml +Python 3 POCL without arg check: + script: + - export PY_EXE=python3 + - export PYOPENCL_TEST=portable:pthread + - export EXTRA_INSTALL="pybind11 numpy mako" + - export LOOPY_NO_CACHE=1 + - export _LOOPY_SKIP_ARG_CHECKS=1 + - 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 + - pocl + except: + - tags + artifacts: + reports: + junit: test/pytest.xml + Python 3 Intel: script: - export PY_EXE=python3 -- GitLab From 8cf14d79d7de8429920748d4681be97ae394d399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Mon, 1 Feb 2021 17:28:34 -0600 Subject: [PATCH 4/6] Fix key duplication in Github CI config --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c2feece5..a389fd5e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project-within-miniconda.sh . ./build-and-test-py-project-within-miniconda.sh - pytest: + pytest_no_arg_check: name: Conda Pytest without arg check runs-on: ubuntu-latest steps: -- GitLab From 23bb1dba2d9f379c4e5d1e25591eb7306a7c0c6c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 1 Feb 2021 18:27:25 -0600 Subject: [PATCH 5/6] Skip test_shape_mismatch_check if arg checks disabled --- test/test_loopy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test_loopy.py b/test/test_loopy.py index be595aaa5..692ea1aa1 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2825,6 +2825,9 @@ def test_shape_mismatch_check(ctx_factory): a = np.random.rand(10, 10).astype(np.float32) b = np.random.rand(10).astype(np.float32) + if prg.options.skip_arg_checks: + pytest.skip("args checks disabled, cannot check") + with pytest.raises(TypeError, match="strides mismatch"): prg(queue, a=a, b=b) -- GitLab From 2763e3e2cce984aaaa22e5d8319a9fedb259b8a7 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 1 Feb 2021 18:30:06 -0600 Subject: [PATCH 6/6] Explain rationale and semantics of _LOOPY_SKIP_ARG_CHECKS --- loopy/options.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/loopy/options.py b/loopy/options.py index 166dcdaa1..45eb3eb63 100644 --- a/loopy/options.py +++ b/loopy/options.py @@ -213,6 +213,11 @@ class Options(ImmutableRecord): skip_arg_checks=kwargs.get("skip_arg_checks", sys.flags.optimize + # Not considered a documented env var: Only used to test + # the skip_arg_checks branch during CI, which can't use + # python -O. + # + # Considered enabled if non-empty. or bool(os.environ.get("_LOOPY_SKIP_ARG_CHECKS"))), no_numpy=kwargs.get("no_numpy", False), cl_exec_manage_array_events=kwargs.get("no_numpy", True), -- GitLab