8000 Merge pull request #24479 from seiko2plus/ci_qemu_meson · numpy/numpy@c2051fd · GitHub
[go: up one dir, main page]

Skip to content

Commit c2051fd

Browse files
authored
Merge pull request #24479 from seiko2plus/ci_qemu_meson
CI: Implements Cross-Compile Builds for armhf, ppc64le, and s390x
2 parents 050dbc6 + f012f1d commit c2051fd

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

.github/workflows/linux_qemu.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Meson's Python module doesn't support crosscompiling,
2+
# and python dependencies may be another potential hurdle.
3+
# There might also be a need to run runtime tests during configure time.
4+
#
5+
# The recommended practice is to rely on Docker to provide the x86_64 crosscompile toolchain,
6+
# enabling native execution via binfmt.
7+
#
8+
# In simpler terms, everything except the crosscompile toolchain will be emulated.
9+
10+
name: Linux Qemu tests
11+
12+
on:
13+
pull_request:
14+
branches:
15+
- main
16+
- maintenance/**
17+
18+
defaults:
19+
run:
20+
shell: bash
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
linux_qemu:
28+
if: "github.repository == 'numpy/numpy'"
29+
runs-on: ubuntu-22.04
30+
continue-on-error: true
31+
strategy:
32+
matrix:
33+
BUILD_PROP:
34+
- [
35+
"armhf",
36+
"arm-linux-gnueabihf",
37+
"arm32v7/ubuntu:22.04",
38+
"-Dallow-noblas=true",
39+
# test_unary_spurious_fpexception is currently skipped
40+
# FIXME(@seiko2plus): Requires confirmation for the following issue:
41+
# The presence of an FP invalid exception caused by sqrt. Unsure if this is a qemu bug or not.
42+
"(test_kind or test_multiarray or test_simd or test_umath or test_ufunc) and not test_unary_spurious_fpexception"
43+
]
44+
- [
45+
"ppc64le",
46+
"powerpc64le-linux-gnu",
47+
"ppc64le/ubuntu:22.04",
48+
"-Dallow-noblas=true",
49+
"test_kind or test_multiarray or test_simd or test_umath or test_ufunc",
50+
]
51+
- [
52+
"s390x",
53+
"s390x-linux-gnu",
54+
"s390x/ubuntu:22.04",
55+
"-Dallow-noblas=true",
56+
# Skipping TestRationalFunctions.test_gcd_overflow test
57+
# because of a possible qemu bug that appears to be related to int64 overflow in absolute operation.
58+
# TODO(@seiko2plus): Confirm the bug and provide a minimal reproducer, then report it to upstream.
59+
"(test_kind or test_multiarray or test_simd or test_umath or test_ufunc) and not test_gcd_overflow"
60+
]
61+
- [
62+
"s390x - baseline(Z13)",
63+
"s390x-linux-gnu",
64+
"s390x/ubuntu:22.04",
65+
"-Dallow-noblas=true -Dcpu-baseline=vx",
66+
"(test_kind or test_multiarray or test_simd or test_umath or test_ufunc) and not test_gcd_overflow"
67+
]
68+
env:
69+
TOOLCHAIN_NAME: ${{ matrix.BUILD_PROP[1] }}
70+
DOCKER_CONTAINER: ${{ matrix.BUILD_PROP[2] }}
71+
MESON_OPTIONS: ${{ matrix.BUILD_PROP[3] }}
72+
RUNTIME_TEST_FILTER: ${{ matrix.BUILD_PROP[4] }}
73+
TERM: xterm-256color
74+
75+
name: "${{ matrix.BUILD_PROP[0] }}"
76+
steps:
77+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
78+
with:
79+
submodules: recursive
80+
fetch-depth: 0
81+
82+
- name: Initialize binfmt_misc for qemu-user-static
83+
run: |
84+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
85+
86+
- name: Install GCC cross-compilers
87+
run: |
88+
sudo apt update
89+
sudo apt install -y ninja-build gcc-${TOOLCHAIN_NAME} g++-${TOOLCHAIN_NAME} gfortran-${TOOLCHAIN_NAME}
90+
91+
- name: Cache docker container
92+
uses: actions/cache@v3
93+
id: container-cache
94+
with:
95+
path: ~/docker_${{ matrix.BUILD_PROP[1] }}
96+
key: container-${{ runner.os }}-${{ matrix.BUILD_PROP[1] }}-${{ matrix.BUILD_PROP[2] }}-${{ hashFiles('build_requirements.txt') }}
97+
98+
- name: Creates new container
99+
if: steps.container-cache.outputs.cache-hit != 'true'
100+
run: |
101+
docker run --name the_container --interactive -v /:/host -v $(pwd):/numpy ${DOCKER_CONTAINER} /bin/bash -c "
102+
apt update &&
103+
apt install -y cmake git python3 python-is-python3 python3-dev python3-pip &&
104+
mkdir -p /lib64 && ln -s /host/lib64/ld-* /lib64/ &&
105+
ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu &&
106+
rm -rf /usr/${TOOLCHAIN_NAME} && ln -s /host/usr/${TOOLCHAIN_NAME} /usr/${TOOLCHAIN_NAME} &&
107+
rm -rf /usr/lib/gcc/${TOOLCHAIN_NAME} && ln -s /host/usr/lib/gcc-cross/${TOOLCHAIN_NAME} /usr/lib/gcc/${TOOLCHAIN_NAME} &&
108+
rm -f /usr/bin/gcc && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gcc /usr/bin/gcc &&
109+
rm -f /usr/bin/g++ && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-g++ /usr/bin/g++ &&
110+
rm -f /usr/bin/gfortran && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gfortran /usr/bin/gfortran &&
111+
rm -f /usr/bin/ar && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ar /usr/bin/ar &&
112+
rm -f /usr/bin/as && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-as /usr/bin/as &&
113+
rm -f /usr/bin/ld && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld /usr/bin/ld &&
114+
rm -f /usr/bin/ld.bfd && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld.bfd /usr/bin/ld.bfd &&
115+
rm -f /usr/bin/ninja && ln -s /host/usr/bin/ninja /usr/bin/ninja &&
116+
git config --global --add safe.directory /numpy &&
117+
python -m pip install -r /numpy/build_requirements.txt &&
118+
python -m pip install pytest pytest-xdist hypothesis typing_extensions &&
119+
rm -f /usr/local/bin/ninja && mkdir -p /usr/local/bin && ln -s /host/usr/bin/ninja /usr/local/bin/ninja
120+
"
121+
docker commit the_container the_container
122+
mkdir -p "~/docker_${TOOLCHAIN_NAME}"
123+
docker save -o "~/docker_${TOOLCHAIN_NAME}/the_container.tar" the_container
124+
125+
- name: Load container from cache
126+
if: steps.container-cache.outputs.cache-hit == 'true'
127+
run: docker load -i "~/docker_${TOOLCHAIN_NAME}/the_container.tar"
128+
129+
- name: Meson Build
130+
run: |
131+
docker run --rm -e "TERM=xterm-256color" -v $(pwd):/numpy -v /:/host the_container \
132+
/bin/script -e -q -c "/bin/bash --noprofile --norc -eo pipefail -c '
133+
cd /numpy && spin build --clean -- ${MESON_OPTIONS}
134+
'"
135+
136+
- name: Meson Log
137+
if: always()
138+
run: 'cat build/meson-logs/meson-log.txt'
139+
140+
- name: Run Tests
141+
run: |
142+
docker run --rm -e "TERM=xterm-256color" -v $(pwd):/numpy -v /:/host the_container \
143+
/bin/script -e -q -c "/bin/bash --noprofile --norc -eo pipefail -c '
144+
export F90=/usr/bin/gfortran
145+
cd /numpy && spin test -- -k \"${RUNTIME_TEST_FILTER}\"
146+
'"
147+

numpy/core/tests/test_simd_module.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def test_signed_overflow(self, sfx):
8686
assert lanes == [0] * nlanes
8787

8888
def test_truncate_f32(self):
89+
if not npyv.simd_f32:
90+
pytest.skip("F32 isn't support by the SIMD extension")
8991
f32 = npyv.setall_f32(0.1)[0]
9092
assert f32 != 0.1
9193
assert round(f32, 1) == 0.1

0 commit comments

Comments
 (0)
0