Skip to content

Commit

Permalink
BUG: Fix build on ppc64 when the baseline set to Power9 or higher
Browse files Browse the repository at this point in the history
Backport of numpy#24806.

This backport was already made in numpy#25083, but that didn't make
use of the linux_qemu.yml action, so this tweaks it a bit.
  • Loading branch information
charris committed Nov 11, 2023
1 parent 882a5a0 commit ba1e504
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/linux_qemu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
linux_qemu:
if: "github.repository == 'numpy/numpy'"
Expand All @@ -48,6 +51,13 @@ jobs:
"-Dallow-noblas=true",
"test_kind or test_multiarray or test_simd or test_umath or test_ufunc",
]
- [
"ppc64le - baseline(Power9)",
"powerpc64le-linux-gnu",
"ppc64le/ubuntu:22.04",
"-Dallow-noblas=true -Dcpu-baseline=vsx3",
"test_kind or test_multiarray or test_simd or test_umath or test_ufunc",
]
- [
"s390x",
"s390x-linux-gnu",
Expand All @@ -74,7 +84,7 @@ jobs:

name: "${{ matrix.BUILD_PROP[0] }}"
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion meson_cpu/ppc64/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ VSX3 = mod_features.new(
VSX4 = mod_features.new(
'VSX4', 4, implies: VSX3, args: {'val': '-mcpu=power10', 'match': '.*[mcpu=|vsx].*'},
detect: {'val': 'VSX4', 'match': 'VSX.*'},
test_code: files(source_root + '/numpy/distutils/checks/cpu_vsx3.c')[0],
test_code: files(source_root + '/numpy/distutils/checks/cpu_vsx4.c')[0],
extra_tests: {
'VSX4_MMA': files(source_root + '/numpy/distutils/checks/extra_vsx4_mma.c')[0]
}
Expand Down
8 changes: 4 additions & 4 deletions numpy/core/src/common/half.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Half final {
/// Default constructor. initialize nothing.
Half() = default;

/// Constract from float
/// Construct from float
/// If there are no hardware optimization available, rounding will always
/// be set to ties to even.
explicit Half(float f)
Expand Down Expand Up @@ -118,7 +118,7 @@ class Half final {
#endif
}

/// Returns a new Half constracted from the IEEE 754 binary16.
/// Returns a new Half constructed from the IEEE 754 binary16.
static constexpr Half FromBits(uint16_t bits)
{
Half h{};
Expand All @@ -131,7 +131,7 @@ class Half final {
return bits_;
}

/// @name Comparison operators (orderd)
/// @name Comparison operators (ordered)
/// @{
constexpr bool operator==(Half r) const
{
Expand All @@ -155,7 +155,7 @@ class Half final {
}
/// @}

/// @name Comparison operators (unorderd)
/// @name Comparison operators (unordered)
/// @{
constexpr bool operator!=(Half r) const
{
Expand Down
11 changes: 6 additions & 5 deletions numpy/core/tests/test_half.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,17 @@ def test_half_correctness(self):
if len(a32_fail) != 0:
bad_index = a32_fail[0]
assert_equal(self.finite_f32, a_manual,
"First non-equal is half value %x -> %g != %g" %
(self.finite_f16[bad_index],
"First non-equal is half value 0x%x -> %g != %g" %
(a_bits[bad_index],
self.finite_f32[bad_index],
a_manual[bad_index]))

a64_fail = np.nonzero(self.finite_f64 != a_manual)[0]
if len(a64_fail) != 0:
bad_index = a64_fail[0]
assert_equal(self.finite_f64, a_manual,
"First non-equal is half value %x -> %g != %g" %
(self.finite_f16[bad_index],
"First non-equal is half value 0x%x -> %g != %g" %
(a_bits[bad_index],
self.finite_f64[bad_index],
a_manual[bad_index]))

Expand Down Expand Up @@ -327,7 +327,8 @@ def test_half_funcs(self):
a = np.array([0, 0, -1, -1/1e20, 0, 2.0**-24, 7.629e-6], dtype=float16)
assert_equal(a.nonzero()[0],
[2, 5, 6])
a = a.byteswap().newbyteorder()
a = a.byteswap()
a = a.view(a.dtype.newbyteorder())
assert_equal(a.nonzero()[0],
[2, 5, 6])

Expand Down
2 changes: 1 addition & 1 deletion numpy/distutils/ccompiler_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ def feature_names(self, names=None, force_flags=None, macros=[]):
def feature_is_exist(self, name):
"""
Returns True if a certain feature is exist and covered within
`_Config.conf_features`.
``_Config.conf_features``.
Parameters
----------
Expand Down

0 comments on commit ba1e504

Please sign in to comment.