GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BLD, SIMD: The meson CPU dispatcher implementation by seiko2plus · Pull Request #23096 · numpy/numpy

BLD, SIMD: The meson CPU dispatcher implementation #23096

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.

Sign up for GitHub

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

Merged
rgommers merged 31 commits into numpy:main from seiko2plus:meson_simd
Aug 11, 2023

Uh oh!

There was an error while loading. Please reload this page.

Merged

BLD, SIMD: The meson CPU dispatcher implementation #23096

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 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
3363fa3
CI: fix doc refguide check failure on CircleCI
rgommers Aug 10, 2023
b868d25
Merge branch 'main' into meson_simd
rgommers Aug 11, 2023
b1855c0
STY: minor fixes to code comments
rgommers Aug 11, 2023
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

29 changes: 29 additions & 0 deletions 29 .github/meson_actions/action.yml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: MesonBuildTest
Comment thread

@rgommers rgommers Jul 31, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this in .github/meson_actions/ rather than .github/workflows/?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seiko2plus seiko2plus Aug 1, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just followed the same pattern of .github/actions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rgommers rgommers Aug 1, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like an action but more like a regular CI job, so it should be under workflows/. This change in other CI files for (e.g.) the setup-python action is something I don't quite understand:

-    - uses: ./.github/actions
+    - uses: ./.github/meson_actions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rgommers rgommers Aug 10, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I see what this does and looked at the history; it's been like this for quite a while. The multiple levels of indirection and then ending up calling tools/travis-*.sh scripts makes debugging difficult, and most of it is just cruft by now. But best to clean it up only after we get rid of the setup.py build I think.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
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 20 .github/workflows/build_test.yml
Show comments
View file
Open in desktop
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: ./.github/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
2 changes: 2 additions & 0 deletions 2 MANIFEST.in
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ recursive-include numpy/random *.pyx *.pxd *.pyx.in *.pxd.in
include numpy/py.typed
include numpy/random/include/*
include numpy/*.pxd
# Meson CPU Dispatcher
recursive-include meson_cpu *.build *.in
# Add build support that should go in sdist, but not go in bdist/be installed
# Note that sub-directories that don't have __init__ are apparently not
# included by 'recursive-include', so list those separately
Expand Down
4 changes: 2 additions & 2 deletions 4 build_requirements.txt
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
meson-python>=0.10.0
Cython
meson-python>=0.13.1
Cython>=3.0
wheel==0.38.1
ninja
spin==0.4
2 changes: 1 addition & 1 deletion 2 doc/source/user/quickstart.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ and other Python sequences.
>>> for i in a:
... print(i**(1 / 3.))
...
9.999999999999998
9.999999999999998 # may vary
1.0
9.999999999999998
3.0
Expand Down
3 changes: 2 additions & 1 deletion 3 meson.build
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(
# See `numpy/__init__.py`
version: '2.0.0.dev0',
license: 'BSD-3',
meson_version: '>= 1.1.0',
meson_version: '>=1.2.99', # version in vendored-meson is 1.2.99
default_options: [
'buildtype=debugoptimized',
'b_ndebug=if-release',
Expand Down Expand Up @@ -80,4 +80,5 @@ else
meson.add_dist_script(py, versioneer, '-o', '_version_meson.py')
endif

subdir('meson_cpu')
Comment thread
rgommers marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

subdir('numpy')
58 changes: 58 additions & 0 deletions 58 meson_cpu/arm/meson.build
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
source_root = meson.project_source_root()
mod_features = import('features')
NEON = mod_features.new(
'NEON', 1,
test_code: files(source_root + '/numpy/distutils/checks/cpu_neon.c')[0]
)
NEON_FP16 = mod_features.new(
'NEON_FP16', 2, implies: NEON,
test_code: files(source_root + '/numpy/distutils/checks/cpu_neon_fp16.c')[0]
)
# FMA
NEON_VFPV4 = mod_features.new(
'NEON_VFPV4', 3, implies: NEON_FP16,
test_code: files(source_root + '/numpy/distutils/checks/cpu_neon_vfpv4.c')[0]
)
# Advanced SIMD
ASIMD = mod_features.new(
'ASIMD', 4, implies: NEON_VFPV4, detect: {'val': 'ASIMD', 'match': 'NEON.*'},
test_code: files(source_root + '/numpy/distutils/checks/cpu_asimd.c')[0]
)
cpu_family = host_machine.cpu_family()
if cpu_family == 'aarch64'
# hardware baseline
NEON.update(implies: [NEON_FP16, NEON_VFPV4, ASIMD])
NEON_FP16.update(implies: [NEON, NEON_VFPV4, ASIMD])
NEON_VFPV4.update(implies: [NEON, NEON_FP16, ASIMD])
elif cpu_family == 'arm'
NEON.update(args: '-mfpu=neon')
NEON_FP16.update(args: ['-mfp16-format=ieee', {'val': '-mfpu=neon-fp16', 'match': '-mfpu=.*'}])
NEON_VFPV4.update(args: [{'val': '-mfpu=neon-vfpv4', 'match': '-mfpu=.*'}])
ASIMD.update(args: [
{'val': '-mfpu=neon-fp-armv8', 'match': '-mfpu=.*'},
'-march=armv8-a+simd'
])
endif
# ARMv8.2 half-precision & vector arithm
ASIMDHP = mod_features.new(
'ASIMDHP', 5, implies: ASIMD,
args: {'val': '-march=armv8.2-a+fp16', 'match': '-march=.*', 'mfilter': '\+.*'},
test_code: files(source_root + '/numpy/distutils/checks/cpu_asimdhp.c')[0]
)
## ARMv8.2 dot product
ASIMDDP = mod_features.new(
'ASIMDDP', 6, implies: ASIMD,
args: {'val': '-march=armv8.2-a+dotprod', 'match': '-march=.*', 'mfilter': '\+.*'},
test_code: files(source_root + '/numpy/distutils/checks/cpu_asimddp.c')[0]
)
## ARMv8.2 Single & half-precision Multiply
ASIMDFHM = mod_features.new(
'ASIMDFHM', 7, implies: ASIMDHP,
args: {'val': '-march=armv8.2-a+fp16fml', 'match': '-march=.*', 'mfilter': '\+.*'},
test_code: files(source_root + '/numpy/distutils/checks/cpu_asimdfhm.c')[0]
)
# TODO: Add support for MSVC
ARM_FEATURES = {
'NEON': NEON, 'NEON_FP16': NEON_FP16, 'NEON_VFPV4': NEON_VFPV4,
'ASIMD': ASIMD, 'ASIMDHP': ASIMDHP, 'ASIMDFHM': ASIMDFHM
}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.