From dc0ee65caef6998d82e9d73e59b89ea21b32a5b4 Mon Sep 17 00:00:00 2001 From: Bogdan Opanchuk Date: Wed, 31 Jul 2024 17:36:23 -0700 Subject: [PATCH] Add POCL-based CI --- .github/workflows/docs.yml | 30 +++++++++++++++++ .github/workflows/lints.yml | 38 ++++++++++++++++++++++ .github/workflows/tests.yml | 64 +++++++++++++++++++++++++++++++++++++ README.md | 11 +++++++ examples/demo_specgram.py | 4 +-- pdm.lock | 39 +++++++++++++++++++++- pyproject.toml | 1 + 7 files changed, 184 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/lints.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..75ee6b2 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,30 @@ +name: Documentation + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + sphinx-build: + runs-on: ubuntu-latest + strategy: + matrix: + # synchronized with `.readthedocs.yml` + python-version: ["3.10"] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install PDM + run: curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 + - name: Install dependencies + run: | + pdm sync -G docs + - name: Run sphinx-build + run: | + pdm run sphinx-build -n docs build/sphinx diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml new file mode 100644 index 0000000..b7d7950 --- /dev/null +++ b/.github/workflows/lints.yml @@ -0,0 +1,38 @@ +name: Lints + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + ruff: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10"] + steps: + - uses: actions/checkout@v3 + - uses: chartboost/ruff-action@v1 + + mypy: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10"] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install PDM + run: curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 + - name: Install dependencies + run: | + pdm sync -G lint + - name: Run mypy + run: | + pdm run mypy examples reikna diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..82d1e40 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,64 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + test-pocl: + + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + python-version: ["3.10"] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install system dependencies + run: | + sudo apt-get install libpocl2 + - name: Install PDM + run: curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 + - name: Install dependencies + run: | + pdm sync -G tests,pyopencl + # Skip performance tests, the test suite is slow enough as it is + - name: Test with pytest + run: | + env POCL_DEVICES="cpu-minimal" pdm run py.test --cov=reikna --cov-report=xml tests -m "not perf" + - name: Run demo_fftn_with_transpose + run: | + env POCL_DEVICES="cpu-minimal" pdm run examples/demo_fftn_with_transpose.py + - name: Run demo_fftshift_transformation + run: | + env POCL_DEVICES="cpu-minimal" pdm run examples/demo_fftshift_transformation.py + - name: Run demo_real_to_complex_fft + run: | + env POCL_DEVICES="cpu-minimal" pdm run examples/demo_real_to_complex_fft.py + - name: Run demo_specgram + run: | + pdm add matplotlib + env POCL_DEVICES="cpu-minimal" pdm run examples/demo_specgram.py + - name: Run demo_specialized_fft + run: | + env POCL_DEVICES="cpu-minimal" pdm run examples/demo_specialized_fft.py + - name: Run demo_struct_reduce + run: | + env POCL_DEVICES="cpu-minimal" pdm run examples/demo_struct_reduce.py + - name: Upload coverage + if: matrix.python-version == '3.10' + run: | + curl -Os https://uploader.codecov.io/latest/linux/codecov + chmod +x codecov + ./codecov diff --git a/README.md b/README.md index 9725111..47ea1a2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,16 @@ # Reikna, the pure Python GPGPU library +[![pypi package][pypi-image]][pypi-link] ![License][pypi-license-image] [![Docs][rtd-image]][rtd-link] [![Coverage][cov-image]][cov-link] + +[pypi-image]: https://img.shields.io/pypi/v/reikna +[pypi-link]: https://pypi.org/project/reikna/ +[pypi-license-image]: https://img.shields.io/pypi/l/reikna +[rtd-image]: https://readthedocs.org/projects/reikna/badge/?version=latest +[rtd-link]: https://reikna.readthedocs.io/en/latest/ +[cov-image]: https://codecov.io/gh/fjarri/reikna/branch/master/graph/badge.svg +[cov-link]: https://codecov.io/gh/fjarri/reikna + + `Reikna` is a library containing various GPU algorithms built on top of [PyCUDA](http://documen.tician.de/pycuda) and [PyOpenCL](http://documen.tician.de/pyopencl). The main design goals are: diff --git a/examples/demo_specgram.py b/examples/demo_specgram.py index 5ba6d16..9501f9c 100644 --- a/examples/demo_specgram.py +++ b/examples/demo_specgram.py @@ -170,8 +170,8 @@ def __init__(self, x, NFFT=256, noverlap=128, pad_to=None, window=hanning_window rolling_frame_trf = rolling_frame(x, NFFT, noverlap, pad_to) complex_dtype = dtypes.complex_for(x.dtype) - fft_arr = Type(complex_dtype, rolling_frame_trf.output.shape) - real_fft_arr = Type(x.dtype, rolling_frame_trf.output.shape) + fft_arr = Type.array(complex_dtype, rolling_frame_trf.output.shape) + real_fft_arr = Type.array(x.dtype, rolling_frame_trf.output.shape) window_trf = window(real_fft_arr, NFFT) broadcast_zero_trf = transformations.broadcast_const(real_fft_arr, 0) diff --git a/pdm.lock b/pdm.lock index c8610b5..b3e9655 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "docs", "lint", "pycuda", "pyopencl", "tests"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:33e56d8b27bcd35a6fc4a204f8766e3beeade34e04e6e5b7da143aace37e5434" +content_hash = "sha256:3ea957ee3b14b9844de9af03afef4e3043a09d49c1f281c7c53b74e004da0c0b" [[metadata.targets]] requires_python = ">=3.10" @@ -651,6 +651,43 @@ files = [ {file = "ruff-0.5.5.tar.gz", hash = "sha256:cc5516bdb4858d972fbc31d246bdb390eab8df1a26e2353be2dbc0c2d7f5421a"}, ] +[[package]] +name = "scipy" +version = "1.14.0" +requires_python = ">=3.10" +summary = "Fundamental algorithms for scientific computing in Python" +groups = ["tests"] +dependencies = [ + "numpy<2.3,>=1.23.5", +] +files = [ + {file = "scipy-1.14.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7e911933d54ead4d557c02402710c2396529540b81dd554fc1ba270eb7308484"}, + {file = "scipy-1.14.0-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:687af0a35462402dd851726295c1a5ae5f987bd6e9026f52e9505994e2f84ef6"}, + {file = "scipy-1.14.0-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:07e179dc0205a50721022344fb85074f772eadbda1e1b3eecdc483f8033709b7"}, + {file = "scipy-1.14.0-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:6a9c9a9b226d9a21e0a208bdb024c3982932e43811b62d202aaf1bb59af264b1"}, + {file = "scipy-1.14.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:076c27284c768b84a45dcf2e914d4000aac537da74236a0d45d82c6fa4b7b3c0"}, + {file = "scipy-1.14.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42470ea0195336df319741e230626b6225a740fd9dce9642ca13e98f667047c0"}, + {file = "scipy-1.14.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:176c6f0d0470a32f1b2efaf40c3d37a24876cebf447498a4cefb947a79c21e9d"}, + {file = "scipy-1.14.0-cp310-cp310-win_amd64.whl", hash = "sha256:ad36af9626d27a4326c8e884917b7ec321d8a1841cd6dacc67d2a9e90c2f0359"}, + {file = "scipy-1.14.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6d056a8709ccda6cf36cdd2eac597d13bc03dba38360f418560a93050c76a16e"}, + {file = "scipy-1.14.0-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:f0a50da861a7ec4573b7c716b2ebdcdf142b66b756a0d392c236ae568b3a93fb"}, + {file = "scipy-1.14.0-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:94c164a9e2498e68308e6e148646e486d979f7fcdb8b4cf34b5441894bdb9caf"}, + {file = "scipy-1.14.0-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:a7d46c3e0aea5c064e734c3eac5cf9eb1f8c4ceee756262f2c7327c4c2691c86"}, + {file = "scipy-1.14.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9eee2989868e274aae26125345584254d97c56194c072ed96cb433f32f692ed8"}, + {file = "scipy-1.14.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9e3154691b9f7ed73778d746da2df67a19d046a6c8087c8b385bc4cdb2cfca74"}, + {file = "scipy-1.14.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:c40003d880f39c11c1edbae8144e3813904b10514cd3d3d00c277ae996488cdb"}, + {file = "scipy-1.14.0-cp311-cp311-win_amd64.whl", hash = "sha256:5b083c8940028bb7e0b4172acafda6df762da1927b9091f9611b0bcd8676f2bc"}, + {file = "scipy-1.14.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:bff2438ea1330e06e53c424893ec0072640dac00f29c6a43a575cbae4c99b2b9"}, + {file = "scipy-1.14.0-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:bbc0471b5f22c11c389075d091d3885693fd3f5e9a54ce051b46308bc787e5d4"}, + {file = "scipy-1.14.0-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:64b2ff514a98cf2bb734a9f90d32dc89dc6ad4a4a36a312cd0d6327170339eb0"}, + {file = "scipy-1.14.0-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:7d3da42fbbbb860211a811782504f38ae7aaec9de8764a9bef6b262de7a2b50f"}, + {file = "scipy-1.14.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d91db2c41dd6c20646af280355d41dfa1ec7eead235642178bd57635a3f82209"}, + {file = "scipy-1.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a01cc03bcdc777c9da3cfdcc74b5a75caffb48a6c39c8450a9a05f82c4250a14"}, + {file = "scipy-1.14.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:65df4da3c12a2bb9ad52b86b4dcf46813e869afb006e58be0f516bc370165159"}, + {file = "scipy-1.14.0-cp312-cp312-win_amd64.whl", hash = "sha256:4c4161597c75043f7154238ef419c29a64ac4a7c889d588ea77690ac4d0d9b20"}, + {file = "scipy-1.14.0.tar.gz", hash = "sha256:b5923f48cb840380f9854339176ef21763118a7300a88203ccd0bdd26e58527b"}, +] + [[package]] name = "setuptools" version = "72.1.0" diff --git a/pyproject.toml b/pyproject.toml index ef7ad75..e9e5a62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,7 @@ tests = [ "pytest>=6", "pytest-cov", "pytest-grunnur>=0.3", + "scipy", ] docs = [ "sphinx>=4",