Skip to content
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

ENH: Properly support FreeBSD/powerpc64 #22777

Merged
merged 1 commit into from Dec 31, 2022
Merged

ENH: Properly support FreeBSD/powerpc64 #22777

merged 1 commit into from Dec 31, 2022

Conversation

pkubaj
Copy link
Contributor

@pkubaj pkubaj commented Dec 12, 2022

  1. FreeBSD sets machine name (uname -m) differently than Linux and instead uses uname -p for actual architecture name, but this is not present in uname() function. Check just for powerpc or ppc and compiler macros instead.
  2. FreeBSD uses elf_aux_info instead of getauxval.

@pkubaj pkubaj changed the title Properly support FreeBSD/powerpc64 ENH: Properly support FreeBSD/powerpc64 Dec 12, 2022
@charris
Copy link
Member

charris commented Dec 12, 2022

Looks like a couple of tests need fixing and/or the detection can be made backwards compatible.

@pkubaj
Copy link
Contributor Author

pkubaj commented Dec 12, 2022

Can you point me to what's actually wrong? I'm quite puzzled right now.

@charris
Copy link
Member

charris commented Dec 12, 2022

You can find the log by clicking on the details. For the smoke test it is at https://github.com/numpy/numpy/actions/runs/3678279521/jobs/6221343413, and the error is

_________________ TestCCompilerOpt_ppc64_clang.test_interface __________________

self = <numpy.distutils.tests.test_ccompiler_opt.TestCCompilerOpt_ppc64_clang object at 0x7f198b4b8b80>

    def test_interface(self):
        wrong_arch = "ppc64" if self.arch != "ppc64" else "x86"
        wrong_cc   = "clang" if self.cc   != "clang" else "icc"
        opt = self.opt()
>       assert_(getattr(opt, "cc_on_" + self.arch))
E       AssertionError

@seiko2plus seiko2plus added component: SIMD Issues in SIMD (fast instruction sets) code or machinery 36 - Build Build related PR labels Dec 15, 2022
@pkubaj
Copy link
Contributor Author

pkubaj commented Dec 26, 2022

I added a commit that works around the test failures.

@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Dec 26, 2022
@charris charris added this to the 1.24.2 release milestone Dec 26, 2022
@pkubaj
Copy link
Contributor Author

pkubaj commented Dec 28, 2022

I had some issues again with architecture detection so I added '.*' around 'powerpc'. I'd rather prefer just '.powerpc.', since it would be much simpler, but it somehow doesn't work with tests.
Also, commits squashed.

Summary after compilation:

########### EXT COMPILER OPTIMIZATION ###########
INFO: Platform      :
  Architecture: ppc64le
  Compiler    : unix-like

CPU baseline  :
  Requested   : 'min'
  Enabled     : VSX VSX2
  Flags       : -mcpu=power8
  Extra checks: VSX_ASM

CPU dispatch  :
  Requested   : 'max -xop -fma4'
  Enabled     : VSX3 VSX4
  Generated   :
              :
  VSX3        : VSX VSX2
  Flags       : -mcpu=power9 -mtune=power9
  Extra checks: none
  Detect      : VSX3
              : build/src.freebsd-13.1-RELEASE-p5-powerpc-3.9/numpy/core/src/_simd/_simd.dispatch.c
              : build/src.freebsd-13.1-RELEASE-p5-powerpc-3.9/numpy/core/src/umath/loops_trigonometric.dispatch.c
              : numpy/core/src/umath/_umath_tests.dispatch.c
              :
  VSX4        : VSX VSX2 VSX3
  Flags       : -mcpu=power10 -mtune=power10
  Extra checks: VSX4_MMA
  Detect      : VSX4
              : build/src.freebsd-13.1-RELEASE-p5-powerpc-3.9/numpy/core/src/_simd/_simd.dispatch.c
              : build/src.freebsd-13.1-RELEASE-p5-powerpc-3.9/numpy/core/src/umath/loops_arithmetic.dispatch.c
              : build/src.freebsd-13.1-RELEASE-p5-powerpc-3.9/numpy/core/src/umath/loops_hyperbolic.dispatch.c
              : build/src.freebsd-13.1-RELEASE-p5-powerpc-3.9/numpy/core/src/umath/loops_modulo.dispatch.c
              : build/src.freebsd-13.1-RELEASE-p5-powerpc-3.9/numpy/core/src/umath/loops_trigonometric.dispatch.c
INFO: CCompilerOpt.cache_flush[857] : write cache to path -> /wrkdirs/usr/ports/math/py-numpy/work-py39/numpy-1.23.5/build/temp.freebsd-13.1-RELEASE-p5-powerpc-cpython-39/ccompiler_opt_cache_ext.py
INFO:
########### CLIB COMPILER OPTIMIZATION ###########
INFO: Platform      :
  Architecture: ppc64le
  Compiler    : unix-like

CPU baseline  :
  Requested   : 'min'
  Enabled     : VSX VSX2
  Flags       : -mcpu=power8
  Extra checks: VSX_ASM

CPU dispatch  :
  Requested   : 'max -xop -fma4'
  Enabled     : VSX3 VSX4
  Generated   : none

@seiko2plus
Copy link
Member

seiko2plus commented Dec 29, 2022

I had some issues again with architecture detection so I added '.*' around 'powerpc'. I'd rather prefer just '.powerpc.', since it would be much simpler, but it somehow doesn't work with tests.

The fake compiler within distutils tests counts on (ppc64|ppc64le) to differentiate between big|little endian, also it is necessary for Linux. The term ppc64(el|le) is been used among the distributions since Power7.

@pkubaj
Copy link
Contributor Author

pkubaj commented Dec 29, 2022

I know Linux uses ppc64 / ppc64le names. I just didn't know the test suite relied on them. If it didn't, checking just for ppc* and then correct compiler macros would be also ok.

Copy link
Member

@seiko2plus seiko2plus left a comment

Choose a reason for hiding this comment

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

LGTM, Thank you. The following suggestions aren't necessary but still great to have them.

numpy/distutils/ccompiler_opt.py Outdated Show resolved Hide resolved
numpy/distutils/ccompiler_opt.py Outdated Show resolved Hide resolved
numpy/core/src/common/npy_cpu_features.c Outdated Show resolved Hide resolved
numpy/core/src/common/npy_cpu_features.c Outdated Show resolved Hide resolved
1. FreeBSD uses elf_aux_info() instead of getauxval.
2. Switch to using compiler macros for detecting POWER platform
FreeBSD sets the machine name (what uname -m prints) on all powerpc* to
just powerpc. To identify actual architecture, uname -p should be used,
but this is not present in uname() function. Thus, the only way to
correctly detect platform is to use what uname prints and also check
compiler defines.
@seiko2plus seiko2plus merged commit 77f1577 into numpy:main Dec 31, 2022
@seiko2plus
Copy link
Member

Thank you @pkubaj.

@InessaPawson
Copy link
Member

Hi-five on merging your first pull request to NumPy, @pkubaj! We hope you stick around! Your choices aren’t limited to writing code – you can review pull requests, help us stay on top of new and old issues, develop educational material, work on our website, add or improve graphic design, create marketing materials, translate website content, write grant proposals, and help with other fundraising initiatives. For more info, check out: https://numpy.org/contribute
Also, consider joining our mailing list. This is a great way to connect with other cool people in our community and be part of important conversations that affect the development of NumPy: https://mail.python.org/mailman/listinfo/numpy-discussion

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jan 8, 2023
@charris charris removed this from the 1.24.2 release milestone Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
36 - Build Build related PR component: SIMD Issues in SIMD (fast instruction sets) code or machinery
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants