8000 Integration testing: Meson SIMD + vendored meson-python by rgommers · Pull Request #24395 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Integration testing: Meson SIMD + vendored meson-python #24395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ab496b3
ENH, SIMD: The meson CPU dispatcher implementation
seiko2plus Jul 16, 2023
9a139d3
Provide compatibility with distutils
seiko2plus Jul 18, 2023
166477d
Extend test_requirements/pyproject to cover meson module
seiko2plus Jul 18, 2023
9421795
BUG: Fix SSE build on meson
seiko2plus Jul 18, 2023
0c3111c
fix the build when it disabled
seiko2plus Jul 19, 2023
a78ef6b
enable AVX512_SPR for quicksort
seiko2plus Jul 19, 2023
a3058a9
Add support for build option --test-simd
seiko2plus Jul 19, 2023
e4b3d72
Fix sdist build
seiko2plus Jul 20, 2023
4203a5b
Pass Opt level 3 to all dispach-able sources
seiko2plus Jul 20, 2023
04b2e2a
Disable SIMD kernels of log/exp/sin/cos on clang-cl
seiko2plus Jul 20, 2023
1917470
CI: Transition x86 specialized tests to Meson from Distutils
seiko2plus Jul 21, 2023
0963fe0
Cleanup the main configration header and improves docs
seiko2plus Jul 23, 2023
481114a
Detect global architecture args
seiko2plus Jul 23, 2023
58239f3
update the meson module name
seiko2plus Jul 25, 2023
2271d02
fix SSE41 flag on Intel-cl
seiko2plus Aug 1, 2023
080e19c
rename method multi_target to multi_targets
seiko2plus Aug 1, 2023
35292aa
Disables mmx when AVX512 is enabled similar to distutils
seiko2plus Aug 1, 2023
077a09f
Add build target AVX512_ICL for simd_qsort
seiko2plus Aug 1, 2023
7ec6933
CI: Allow noblas for SIMD tests
seiko2plus Aug 1, 2023
0beab65
Bybass sort validation for _simd module
seiko2plus Aug 2, 2023
f580462
Removes build option boolean warning
seiko2plus Aug 2, 2023
de71d9b
removes py_dep from _simd extention
seiko2plus Aug 2, 2023
dedd413
fix Initlize typo
seiko2plus Aug 2, 2023
a751c20
Minimize the log of CPU optimization
seiko2plus Aug 2, 2023
76327b8
Remove debug log and count on multi_targets() debug
seiko2plus Aug 4, 2023
e13ce41
update multi_targets to reduce the number of objects
seiko2plus Aug 7, 2023
9509508
BLD: updates to build and test dependencies
rgommers Aug 10, 2023
371bb76
BLD: add Meson version check, to catch older installed versions early
rgommers Aug 10, 2023
bfb504f
CI: fix doc refguide check failure on CircleCI
rgommers Aug 10, 2023
34ec848
BLD: use numpy's friendly fork of meson-python
rgommers Aug 10, 2023
7a40779
DEV: vendor spin's meson.py, modified to use our vendored Meson
rgommers Aug 8, 2023
a594207
CI: fix Windows GHA jobs for vendored meson-python and spin
rgommers Aug 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/meson_actions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: MesonBuildTest
description: "checkout repo, build, and test numpy"
runs:
using: composite
steps:
- name: Install dependencies
shell: bash
run: pip install -r build_requirements.txt
- name: Build
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
env:
TERM: xterm-256color
run:
spin build -- ${MESON_ARGS[@]}
- name: Check build-internal dependencies
shell: bash
run:
ninja -C build -t missingdeps
- name: Check installed test and stub files
shell: bash
run:
python tools/check_installed_files.py $(find ./build-install -path '*/site-packages/numpy')
- name: Test
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
env:
TERM: xterm-256color
run: |
pip install pytest pytest-xdist hypothesis typing_extensions
spin test -j auto
20 changes: 10 additions & 10 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
if: "github.repository == 'numpy/numpy'"
runs-on: ubuntu-latest
env:
WITHOUT_SIMD: 1
MESON_ARGS: "-Dallow-noblas=true -Dcpu-baseline=none -Dcpu-dispatch=none"
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
Expand All @@ -58,7 +58,7 @@ jobs:
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.github/actions
- uses: ./.github/meson_actions

basic:
needs: [smoke_test]
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name != 'push'
env:
WITHOUT_OPTIMIZATIONS: 1
MESON_ARGS: "-Dallow-noblas=true -Ddisable-optimization=true"
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
Expand All @@ -131,14 +131,14 @@ jobs:
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.github/actions
- uses: ./.github/meson_actions

with_baseline_only:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
env:
CPU_DISPATCH: "none"
MESON_ARGS: "-Dallow-noblas=true -Dcpu-dispatch=none"
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
Expand All @@ -147,14 +147,14 @@ jobs:
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.githu 67F4 b/actions
- uses: ./.github/meson_actions

without_avx512:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
env:
CPU_DISPATCH: "max -xop -fma4 -avx512f -avx512cd -avx512_knl -avx512_knm -avx512_skx -avx512_clx -avx512_cnl -avx512_icl"
MESON_ARGS: "-Dallow-noblas=true -Dcpu-dispatch=SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,AVX2,FMA3"
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
Expand All @@ -163,14 +163,14 @@ jobs:
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.github/actions
- uses: ./.github/meson_actions

without_avx512_avx2_fma3:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
env:
CPU_DISPATCH: "SSSE3 SSE41 POPCNT SSE42 AVX F16C"
MESON_ARGS: "-Dallow-noblas=true -Dcpu-dispatch=SSSE3,SSE41,POPCNT,SSE42,AVX,F16C"
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
Expand All @@ -179,7 +179,7 @@ jobs:
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.github/actions
- uses: ./.github/meson_actions

debug:
needs: [smoke_test]
Expand Down
55 changes: 23 additions & 32 deletions .github/workflows/windows_clangcl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
meson:
name: Meson windows build/test
runs-on: windows-2019
# if: "github.repository == 'numpy/numpy'"
if: "github.repository == 'numpy/numpy'"
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
Expand All @@ -32,14 +32,14 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
- name: Install build dependencies from PyPI
run: |
pip install -r build_requirements.txt
- name: openblas-libs
pip install spin Cython

- name: Install OpenBLAS and Clang-cl
run: |
# Download and install pre-built OpenBLAS library
# with 32-bit interfaces
# Unpack it in the pkg-config hardcoded path
# Download and install pre-built OpenBLAS library with 32-bit
# interfaces Unpack it in the pkg-config hardcoded path
choco install unzip -y
choco install wget -y
# Install llvm, which contains clang-cl
Expand All @@ -48,44 +48,35 @@ jobs:
wget https://anaconda.org/multibuild-wheels-staging/openblas-libs/v0.3.21/download/openblas-v0.3.21-win_amd64-gcc_10_3_0.zip
unzip -d c:\opt openblas-v0.3.21-win_amd64-gcc_10_3_0.zip
echo "PKG_CONFIG_PATH=c:\opt\64\lib\pkgconfig;" >> $env:GITHUB_ENV
- name: meson-configure
run: |
"[binaries]","c = 'clang-cl'","cpp = 'clang-cl'","ar = 'llvm-lib'","c_ld = 'lld-link'","cpp_ld = 'lld-link'" | Out-File $PWD/clang-cl-build.ini -Encoding ascii
meson setup build --prefix=$PWD\build-install --native-file=$PWD/clang-cl-build.ini -Ddebug=false --optimization 2 --vsenv
- name: meson-build
run: |
meson compile -C build -v

- name: meson-install
- name: Write native file for Clang-cl binaries
run: |
cd build
meson install --no-rebuild
- name: build-path
# TODO: this job is identical to the one in `windows_meson.yml` aside
# from installing Clang-cl and usage of this .ini file. So merge the
# two and use a matrix'ed CI job run.
"[binaries]","c = 'clang-cl'","cpp = 'clang-cl'","ar = 'llvm-lib'","c_ld = 'lld-link'","cpp_ld = 'lld-link'" | Out-File $PWD/clang-cl-build.ini -Encoding ascii

- name: Install NumPy
run: |
echo "installed_path=$PWD\build-install\Lib\site-packages" >> $env:GITHUB_ENV
- name: post-install
spin build -j2 -- --vsenv --native-file=$PWD/clang-cl-build.ini

- name: Copy OpenBLAS DLL, write _distributor_init.py
run: |
$numpy_path = "${env:installed_path}\numpy"
# Getting the OpenBLAS DLL to the right place so it loads
$installed_path = "$PWD\build-install\usr\Lib\site-packages"
$numpy_path = "${installed_path}\numpy"
$libs_path = "${numpy_path}\.libs"
mkdir ${libs_path}
$ob_path = "C:/opt/64/bin/"
cp $ob_path/*.dll $libs_path
# Write _distributor_init.py to load .libs DLLs.
python -c "from tools import openblas_support; openblas_support.make_init(r'${numpy_path}')"

- name: prep-test
- name: Install test dependencies
run: |
echo "PYTHONPATH=${env:installed_path}" >> $env:GITHUB_ENV
python -m pip install -r test_requirements.txt
python -m pip install threadpoolctl

- name: test
- name: Run test suite
run: |
mkdir tmp
cd tmp
echo "============================================"
python -c "import numpy; print(numpy.show_runtime())"
echo "============================================"
echo "LASTEXITCODE is '$LASTEXITCODE'"
python -c "import numpy, sys; sys.exit(numpy.test(verbose=3) is False)"
echo "LASTEXITCODE is '$LASTEXITCODE'"
spin test
48 changes: 17 additions & 31 deletions .github/workflows/windows_meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,65 +27,51 @@ jobs:
with:
submodules: recursive
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
- name: Install build dependencies from PyPI
run: |
pip install -r build_requirements.txt
- name: openblas-libs
python -m pip install spin Cython

- name: Install OpenBLAS (MacPython build)
run: |
# Download and install pre-built OpenBLAS library
# with 32-bit interfaces
# Unpack it in the pkg-config hardcoded path
# Download and install pre-built OpenBLAS library with 32-bit
# interfaces. Unpack it in the pkg-config hardcoded path
choco install unzip -y
choco install wget -y
choco install -y --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
wget https://anaconda.org/multibuild-wheels-staging/openblas-libs/v0.3.21/download/openblas-v0.3.21-win_amd64-gcc_10_3_0.zip
unzip -d c:\opt openblas-v0.3.21-win_amd64-gcc_10_3_0.zip
echo "PKG_CONFIG_PATH=c:\opt\64\lib\pkgconfig;" >> $env:GITHUB_ENV
- name: meson-configure
run: |
meson setup build --prefix=$PWD\build-install -Ddebug=false --optimization 2 --vsenv
- name: meson-build
run: |
meson compile -C build -v

- name: meson-install
run: |
cd build
meson install --no-rebuild
- name: build-path
- name: Install NumPy
run: |
echo "installed_path=$PWD\build-install\Lib\site-packages" >> $env:GITHUB_ENV
- name: post-install
spin build -j2 -- --vsenv

- name: Copy OpenBLAS DLL, write _distributor_init.py
run: |
$numpy_path = "${env:installed_path}\numpy"
# Getting the OpenBLAS DLL to the right place so it loads
$installed_path = "$PWD\build-install\usr\Lib\site-packages"
$numpy_path = "${installed_path}\numpy"
$libs_path = "${numpy_path}\.libs"
mkdir ${libs_path}
$ob_path = "C:/opt/64/bin/"
cp $ob_path/*.dll $libs_path
# Write _distributor_init.py to load .libs DLLs.
python -c "from tools import openblas_support; openblas_support.make_init(r'${numpy_path}')"

- name: prep-test
- name: Install test dependencies
run: |
echo "PYTHONPATH=${env:installed_path}" >> $env:GITHUB_ENV
python -m pip install -r test_requirements.txt
python -m pip install threadpoolctl

- name: test
- name: Run test suite
run: |
mkdir tmp
cd tmp
echo "============================================"
python -c "import numpy; print(numpy.show_runtime())"
echo "============================================"
echo "LASTEXITCODE is '$LASTEXITCODE'"
python -c "import numpy, sys; sys.exit(numpy.test(verbose=3) is False)"
echo "LASTEXITCODE is '$LASTEXITCODE'"
spin test

msvc_32bit_python_openblas:
name: MSVC, 32-bit Python, no BLAS
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "vendored-meson/meson"]
path = vendored-meson/meson
url = https://github.com/numpy/meson.git
[submodule "vendored-meson/meson-python"]
path = vendored-meson/meson-python
url = https://github.com/numpy/meson-python.git
29 changes: 29 additions & 0 deletions .spin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2021--2022, Scientific Python project
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading
0