Skip to content

Commit 29c2030

Browse files
authored
Merge pull request numpy#25108 from charris/add-qemu-tests
CI: Add linux_qemu action and remove travis testing.
2 parents 02d47a9 + 19d5b69 commit 29c2030

File tree

8 files changed

+189
-95
lines changed

8 files changed

+189
-95
lines changed

.github/workflows/linux_qemu.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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+
permissions:
27+
contents: read
28+
29+
jobs:
30+
linux_qemu:
31+
if: "github.repository == 'numpy/numpy'"
32+
runs-on: ubuntu-22.04
33+
continue-on-error: true
34+
strategy:
35+
matrix:
36+
BUILD_PROP:
37+
- [
38+
"armhf",
39+
"arm-linux-gnueabihf",
40+
"arm32v7/ubuntu:22.04",
41+
"-Dallow-noblas=true",
42+
# test_unary_spurious_fpexception is currently skipped
43+
# FIXME(@seiko2plus): Requires confirmation for the following issue:
44+
# The presence of an FP invalid exception caused by sqrt. Unsure if this is a qemu bug or not.
45+
"(test_kind or test_multiarray or test_simd or test_umath or test_ufunc) and not test_unary_spurious_fpexception"
46+
]
47+
- [
48+
"ppc64le",
49+
"powerpc64le-linux-gnu",
50+
"ppc64le/ubuntu:22.04",
51+
"-Dallow-noblas=true",
52+
"test_kind or test_multiarray or test_simd or test_umath or test_ufunc",
53+
]
54+
- [
55+
"ppc64le - baseline(Power9)",
56+
"powerpc64le-linux-gnu",
57+
"ppc64le/ubuntu:22.04",
58+
"-Dallow-noblas=true -Dcpu-baseline=vsx3",
59+
"test_kind or test_multiarray or test_simd or test_umath or test_ufunc",
60+
]
61+
- [
62+
"s390x",
63+
"s390x-linux-gnu",
64+
"s390x/ubuntu:22.04",
65+
"-Dallow-noblas=true",
66+
# Skipping TestRationalFunctions.test_gcd_overflow test
67+
# because of a possible qemu bug that appears to be related to int64 overflow in absolute operation.
68+
# TODO(@seiko2plus): Confirm the bug and provide a minimal reproducer, then report it to upstream.
69+
"(test_kind or test_multiarray or test_simd or test_umath or test_ufunc) and not test_gcd_overflow"
70+
]
71+
- [
72+
"s390x - baseline(Z13)",
73+
"s390x-linux-gnu",
74+
"s390x/ubuntu:22.04",
75+
"-Dallow-noblas=true -Dcpu-baseline=vx",
76+
"(test_kind or test_multiarray or test_simd or test_umath or test_ufunc) and not test_gcd_overflow"
77+
]
78+
env:
79+
TOOLCHAIN_NAME: ${{ matrix.BUILD_PROP[1] }}
80+
DOCKER_CONTAINER: ${{ matrix.BUILD_PROP[2] }}
81+
MESON_OPTIONS: ${{ matrix.BUILD_PROP[3] }}
82+
RUNTIME_TEST_FILTER: ${{ matrix.BUILD_PROP[4] }}
83+
TERM: xterm-256color
84+
85+
name: "${{ matrix.BUILD_PROP[0] }}"
86+
steps:
87+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
88+
with:
89+
submodules: recursive
90+
fetch-depth: 0
91+
92+
- name: Initialize binfmt_misc for qemu-user-static
93+
run: |
94+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
95+
96+
- name: Install GCC cross-compilers
97+
run: |
98+
sudo apt update
99+
sudo apt install -y ninja-build gcc-${TOOLCHAIN_NAME} g++-${TOOLCHAIN_NAME} gfortran-${TOOLCHAIN_NAME}
100+
101+
- name: Cache docker container
102+
uses: actions/cache@v3
103+
id: container-cache
104+
with:
105+
path: ~/docker_${{ matrix.BUILD_PROP[1] }}
106+
key: container-${{ runner.os }}-${{ matrix.BUILD_PROP[1] }}-${{ matrix.BUILD_PROP[2] }}-${{ hashFiles('build_requirements.txt') }}
107+
108+
- name: Creates new container
109+
if: steps.container-cache.outputs.cache-hit != 'true'
110+
run: |
111+
docker run --name the_container --interactive -v /:/host -v $(pwd):/numpy ${DOCKER_CONTAINER} /bin/bash -c "
112+
apt update &&
113+
apt install -y cmake git python3 python-is-python3 python3-dev python3-pip &&
114+
mkdir -p /lib64 && ln -s /host/lib64/ld-* /lib64/ &&
115+
ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu &&
116+
rm -rf /usr/${TOOLCHAIN_NAME} && ln -s /host/usr/${TOOLCHAIN_NAME} /usr/${TOOLCHAIN_NAME} &&
117+
rm -rf /usr/lib/gcc/${TOOLCHAIN_NAME} && ln -s /host/usr/lib/gcc-cross/${TOOLCHAIN_NAME} /usr/lib/gcc/${TOOLCHAIN_NAME} &&
118+
rm -f /usr/bin/gcc && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gcc /usr/bin/gcc &&
119+
rm -f /usr/bin/g++ && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-g++ /usr/bin/g++ &&
120+
rm -f /usr/bin/gfortran && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gfortran /usr/bin/gfortran &&
121+
rm -f /usr/bin/ar && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ar /usr/bin/ar &&
122+
rm -f /usr/bin/as && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-as /usr/bin/as &&
123+
rm -f /usr/bin/ld && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld /usr/bin/ld &&
124+
rm -f /usr/bin/ld.bfd && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld.bfd /usr/bin/ld.bfd &&
125+
rm -f /usr/bin/ninja && ln -s /host/usr/bin/ninja /usr/bin/ninja &&
126+
git config --global --add safe.directory /numpy &&
127+
python -m pip install -r /numpy/build_requirements.txt &&
128+
python -m pip install pytest pytest-xdist hypothesis typing_extensions &&
129+
rm -f /usr/local/bin/ninja && mkdir -p /usr/local/bin && ln -s /host/usr/bin/ninja /usr/local/bin/ninja
130+
"
131+
docker commit the_container the_container
132+
mkdir -p "~/docker_${TOOLCHAIN_NAME}"
133+
docker save -o "~/docker_${TOOLCHAIN_NAME}/the_container.tar" the_container
134+
135+
- name: Load container from cache
136+
if: steps.container-cache.outputs.cache-hit == 'true'
137+
run: docker load -i "~/docker_${TOOLCHAIN_NAME}/the_container.tar"
138+
139+
- name: Meson Build
140+
run: |
141+
docker run --rm -e "TERM=xterm-256color" -v $(pwd):/numpy -v /:/host the_container \
142+
/bin/script -e -q -c "/bin/bash --noprofile --norc -eo pipefail -c '
143+
cd /numpy && spin build --clean -- ${MESON_OPTIONS}
144+
'"
145+
146+
- name: Meson Log
147+
if: always()
148+
run: 'cat build/meson-logs/meson-log.txt'
149+
150+
- name: Run Tests
151+
run: |
152+
docker run --rm -e "TERM=xterm-256color" -v $(pwd):/numpy -v /:/host the_container \
153+
/bin/script -e -q -c "/bin/bash --noprofile --norc -eo pipefail -c '
154+
export F90=/usr/bin/gfortran
155+
cd /numpy && spin test -- -k \"${RUNTIME_TEST_FILTER}\"
156+
'"
157+

.github/workflows/windows.yml

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,23 @@ jobs:
2323
compiler: ["MSVC", "Clang-cl"]
2424
steps:
2525
- name: Checkout
26-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
26+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2727
with:
2828
submodules: recursive
2929
fetch-depth: 0
3030

3131
- name: Setup Python
32-
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
32+
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
3333
with:
3434
python-version: '3.11'
3535

3636
- name: Install build dependencies from PyPI
3737
run: |
3838
python -m pip install spin Cython
3939
40-
- name: Install OpenBLAS (MacPython build)
40+
- name: Install pkg-config
4141
run: |
42-
# Download and install pre-built OpenBLAS library with 32-bit
43-
# interfaces. Unpack it in the pkg-config hardcoded path
44-
choco install unzip -y
45-
choco install wget -y
4642
choco install -y --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
47-
wget https://anaconda.org/multibuild-wheels-staging/openblas-libs/v0.3.21/download/openblas-v0.3.21-win_amd64-gcc_10_3_0.zip
48-
unzip -d c:\opt openblas-v0.3.21-win_amd64-gcc_10_3_0.zip
49-
echo "PKG_CONFIG_PATH=c:\opt\64\lib\pkgconfig;" >> $env:GITHUB_ENV
5043
5144
- name: Install Clang-cl
5245
if: matrix.compiler == 'Clang-cl'
@@ -55,26 +48,26 @@ jobs:
5548
5649
- name: Install NumPy (MSVC)
5750
if: matrix.compiler == 'MSVC'
51+
env:
52+
PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas
5853
run: |
59-
spin build -j2 -- --vsenv
54+
python -m pip install scipy-openblas32
55+
spin build --with-scipy-openblas=32 -j2 -- --vsenv
6056
6157
- name: Install NumPy (Clang-cl)
6258
if: matrix.compiler == 'Clang-cl'
59+
env:
60+
PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas
6361
run: |
6462
"[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
65-
spin build -j2 -- --vsenv --native-file=$PWD/clang-cl-build.ini
63+
python -m pip install scipy-openblas32
64+
spin build --with-scipy-openblas=32 -j2 -- --vsenv --native-file=$PWD/clang-cl-build.ini
6665
67-
- name: Copy OpenBLAS DLL, write _distributor_init.py
66+
- name: Meson Log
67+
shell: bash
68+
if: ${{ failure() }}
6869
run: |
69-
# Getting the OpenBLAS DLL to the right place so it loads
70-
$installed_path = "$PWD\build-install\usr\Lib\site-packages"
71-
$numpy_path = "${installed_path}\numpy"
72-
$libs_path = "${installed_path}\numpy.libs"
73-
mkdir ${libs_path}
74-
$ob_path = "C:/opt/64/bin/"
75-
cp $ob_path/*.dll $libs_path
76-
# Write _distributor_init.py to load .libs DLLs.
77-
python -c "from tools import openblas_support; openblas_support.make_init(r'${numpy_path}')"
70+
cat build/meson-logs/meson-log.txt
7871
7972
- name: Install test dependencies
8073
run: |
@@ -85,19 +78,19 @@ jobs:
8578
run: |
8679
spin test
8780
88-
msvc_32bit_python_openblas:
81+
msvc_32bit_python_no_openblas:
8982
name: MSVC, 32-bit Python, no BLAS
9083
runs-on: windows-2019
9184
if: "github.repository == 'numpy/numpy'"
9285
steps:
9386
- name: Checkout
94-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
87+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
9588
with:
9689
submodules: recursive
9790
fetch-depth: 0
9891

9992
- name: Setup Python (32-bit)
100-
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
93+
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
10194
with:
10295
python-version: '3.10'
10396
architecture: 'x86'

.travis.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

meson_cpu/ppc64/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ VSX3 = mod_features.new(
3333
VSX4 = mod_features.new(
3434
'VSX4', 4, implies: VSX3, args: {'val': '-mcpu=power10', 'match': '.*[mcpu=|vsx].*'},
3535
detect: {'val': 'VSX4', 'match': 'VSX.*'},
36-
test_code: files(source_root + '/numpy/distutils/checks/cpu_vsx3.c')[0],
36+
test_code: files(source_root + '/numpy/distutils/checks/cpu_vsx4.c')[0],
3737
extra_tests: {
3838
'VSX4_MMA': files(source_root + '/numpy/distutils/checks/extra_vsx4_mma.c')[0]
3939
}

numpy/core/src/common/half.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Half final {
4747
/// Default constructor. initialize nothing.
4848
Half() = default;
4949

50-
/// Constract from float
50+
/// Construct from float
5151
/// If there are no hardware optimization available, rounding will always
5252
/// be set to ties to even.
5353
explicit Half(float f)
@@ -118,7 +118,7 @@ class Half final {
118118
#endif
119119
}
120120

121-
/// Returns a new Half constracted from the IEEE 754 binary16.
121+
/// Returns a new Half constructed from the IEEE 754 binary16.
122122
static constexpr Half FromBits(uint16_t bits)
123123
{
124124
Half h{};
@@ -131,7 +131,7 @@ class Half final {
131131
return bits_;
132132
}
133133

134-
/// @name Comparison operators (orderd)
134+
/// @name Comparison operators (ordered)
135135
/// @{
136136
constexpr bool operator==(Half r) const
137137
{
@@ -155,7 +155,7 @@ class Half final {
155155
}
156156
/// @}
157157

158-
/// @name Comparison operators (unorderd)
158+
/// @name Comparison operators (unordered)
159159
/// @{
160160
constexpr bool operator!=(Half r) const
161161
{

numpy/core/tests/test_half.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,17 @@ def test_half_correctness(self):
274274
if len(a32_fail) != 0:
275275
bad_index = a32_fail[0]
276276
assert_equal(self.finite_f32, a_manual,
277-
"First non-equal is half value %x -> %g != %g" %
278-
(self.finite_f16[bad_index],
277+
"First non-equal is half value 0x%x -> %g != %g" %
278+
(a_bits[bad_index],
279279
self.finite_f32[bad_index],
280280
a_manual[bad_index]))
281281

282282
a64_fail = np.nonzero(self.finite_f64 != a_manual)[0]
283283
if len(a64_fail) != 0:
284284
bad_index = a64_fail[0]
285285
assert_equal(self.finite_f64, a_manual,
286-
"First non-equal is half value %x -> %g != %g" %
287-
(self.finite_f16[bad_index],
286+
"First non-equal is half value 0x%x -> %g != %g" %
287+
(a_bits[bad_index],
288288
self.finite_f64[bad_index],
289289
a_manual[bad_index]))
290290

@@ -327,7 +327,8 @@ def test_half_funcs(self):
327327
a = np.array([0, 0, -1, -1/1e20, 0, 2.0**-24, 7.629e-6], dtype=float16)
328328
assert_equal(a.nonzero()[0],
329329
[2, 5, 6])
330-
a = a.byteswap().newbyteorder()
330+
a = a.byteswap()
331+
a = a.view(a.dtype.newbyteorder())
331332
assert_equal(a.nonzero()[0],
332333
[2, 5, 6])
333334

numpy/core/tests/test_ufunc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,8 @@ def check_identityless_reduction(self, a):
16171617
assert_equal(np.minimum.reduce(a, axis=()), a)
16181618

16191619
@requires_memory(6 * 1024**3)
1620+
@pytest.mark.skipif(sys.maxsize < 2**32,
1621+
reason="test array too large for 32bit platform")
16201622
def test_identityless_reduction_huge_array(self):
16211623
# Regression test for gh-20921 (copying identity incorrectly failed)
16221624
arr = np.zeros((2, 2**31), 'uint8')

0 commit comments

Comments
 (0)