ENH: add support for fujitsu C/C++ compiler and SSL2 to numpy.#22982
ENH: add support for fujitsu C/C++ compiler and SSL2 to numpy.#22982seberg merged 1 commit intonumpy:mainfrom
Conversation
c8aa06d to
6a1d406
Compare
seberg
left a comment
There was a problem hiding this comment.
Just a few thoughts to maybe help get this rolling soon. However, I am worried that this is using a C++ compiler and not a C one.
There is also a thing that we want to migrate to meson soon, and I am not sure how these changes would be affected by it. Not that it matters too much, since this cannot be tested by us anyway (if it breaks, it breaks).
| if (mod) { | ||
| if (isless(b, (@type@)0) != isless(mod, (@type@)0)) { | ||
| if (!isnan@c@(b) && !isnan@c@(mod) && !isinf@c@(b) && !isinf@c@(mod) && | ||
| ((b < (@type@)0) != (mod < (@type@)0))) { |
There was a problem hiding this comment.
Just to get a start on this, how come this is necessary? Is the compiler not C99 conforming or are some tests flake?
Note that we already ignore some warnings on certain platforms, so if it is the latter, it might also just be necessary to ignore the warnings. (because in the end, few users care)
If it is not C99 compliant, I am not sure, I find that surprising (unless you are compiling with a C++ compiler rather C?)
There was a problem hiding this comment.
Sorry for the late reply.
When I do a regression test on NumPy built with fcc, it fails on np.floor_divide for float128.
In the current fujitsu compiler, when isgreater(nan, 1.0l) or isless(nan, 1.0l) is performed for float128, it compares the number with nan without checking nan and the FE_INVALID flag is raised. This is the cause of the error.
When doing np.floor_divide with Nan, the message <stdin>:1: RuntimeWarning: invalid value encountered in floor_divide appears.
- In the case of float128
$ python
>>> import numpy as np
>>> fnan = np.array(np.nan, dtype='float128')
>>> fone = np.array(1.0, dtype='float128')
>>> np.floor_divide(fnan, fone)
<stdin>:1: RuntimeWarning: invalid value encountered in floor_divide
nan- Other than float128
$ python
>>> import numpy as np
>>> fnan = np.array(np.nan)
>>> fone = np.array(1.0)
>>> np.floor_divide(fnan, fone)
nanTherefore, we have rewritten the code to check for Nan and run if Nan is not present.
If we change the code regarding this part, it will have a large impact on other environments. So, I think it is better not to change the code, but to make it a limitation when using the Fujitsu compiler. What do you think? I will change it so that regression tests that fail because of this will be skipped.
There was a problem hiding this comment.
Oh, just the longdouble implementation of isless gets it wrong! Yes, I would suggest to skip the test, since it seems the most pragmatic choice. This had been giving warnings for years on most platforms before we fixed it :).
We have some tests that have for example (I might prefer xfail really, but either works):
@pytest.mark.skipif(platform.machine() == "armv5tel",
reason="See gh-413.")
There was a problem hiding this comment.
Thank you very much. I had no idea that this had happened in the past on other platforms.
I would like to make sure that NumPy was built with fujitsu compiler as this problem only happens when built with this.
I don't feel like I can determine this from sys.platform, etc. Do you know any way to verify used compiler when doing pytest?
There was a problem hiding this comment.
Actually, not sure. @ganesh-k13 is there a simple way to get the compiler used? Sounds like it would also be nice to include in np.show_runtime().
There was a problem hiding this comment.
Thanks, but that means there is no easy way to get it right now to skip a test, I guess. Maybe a very specific platform rule could work in practice?
numpy/distutils/fujitsuccompiler.py
Outdated
| linker_exe=cc_compiler + | ||
| ' -O3 -Nclang -fPIC -lfj90i -lfj90f -lfjsrcinfo -lelf -shared', | ||
| linker_so=cc_compiler + | ||
| ' -O3 -Nclang -lfj90i -lfj90f -lfjsrcinfo -lelf -shared' |
There was a problem hiding this comment.
Adding compiler options here seems not correct? -O3 is not necessarily best for NumPy anyway, although I suppose it may be for many use-cases (at least when not on Linux, since we are probably a bit sloppy with the NPY_GCC_OPT_3 macro, which could be extended!)
There was a problem hiding this comment.
You are right, there is no need to specify -O3 in the linker options.
Sorry, I overlooked that. I will correct it.
|
Sorry, I somehow forgot the main comment: There is a spurious first commit (probably you started from the |
15b78fd to
b2499de
Compare
|
Hi @seberg Thank you for your review comments.
Commit log has been fixed.
The file selection.cpp seems to require a C++compiler. This file appears to have been added to 2022/06. |
|
Just for reference, there was fortran compiler support added in gh-17792 (there is a comment about patching ssl there too). |
|
@t-karatsu just curious if you are still interested in fujitsu compiler support work? In that case it would be great if you could have a look here! |
To have this work in the Meson port, you'll want to add a compiler class here: https://github.com/mesonbuild/meson/blob/master/mesonbuild/compilers Do not hesitate to ask me questions if you wish for guidance implementing this. :) |
|
Hi, @eli-schwartz |
b2499de to
be59f10
Compare
|
Fixed implementation and pushed. Test skip due to fujitsu compiler specification
Test skip due to SVE specification
|
be59f10 to
559354b
Compare
|
Needs a release note. @mattip What about meson support? |
All the changes in |
|
Creating release notes. For meson support, you will need to add fujitsu compiler to meson first, so it will take some time. |
2594de2 to
5fcd83f
Compare
|
I think we're fine with reviewing and merging this with A few questions on the BLAS part of this. Is there anything nonstandard in SSL2 that needs custom handling (e.g. build variants that need to be probed for, with/without some symbols or CBLAS support)? I can't find much info on it, no docs online it seems. https://github.com/spack/spack/pull/18498/files seems to hardcode |
|
@rgommers
|
|
Let me give you a few additional explanations. SSL2 library provides 8 variants (so files) for BLAS functions. Single-threaded/Multi-threaded, NEON(128-bit SIMD)/SVE(512-bit SIMD), LP64/ILP64. SVE of Armv8/9 architecture is defined as scalable SIMD size (128, 256, 384, 512, ..., 2048). H/W implementer can chose one of them. Because the SVE size of Fujitsu A64FX is 512-bit and SSL2 provided for A64FX, the so files of SSL2 for SVE is implemented for 512-bit SVE. We can chose which variant to link by linker option (-lfjlapack, -lfjlapacksve, -lfjlapack_ilp64, -lfjlapacksve_ilp64, -lfjlapackex, -lfjlapackexsve -lfjlapackex_ilp64, -lfjlapackexsve_ilp64). We assume that the users who build numpy with the Fujitsu compilers are those who want to have A64FX handle large problems. In this case, we think it is better to use the multi-threaded SVE version, so we prefer to link multi-threaded/SVE/LP64/ by default, and how about mentioning in the release notes how to link the other variants? |
3d7a22b to
9a3da62
Compare
|
Is there anything else I can do to get this pull request merged? I'm currently fixing the code to pass the CI test. |
seberg
left a comment
There was a problem hiding this comment.
Looks good to give a shot, modulo that one typo.
I might prefer xfail at least for the first test since it generates spurious warnings, I think (which can be pretty annoying compared to missing warnings). But either is fine.
numpy/core/tests/test_multiarray.py
Outdated
| shell=True).communicate()[0]).decode('utf-8') | ||
| return "sve" in process | ||
| except OSError: | ||
| return false |
There was a problem hiding this comment.
| return false | |
| return False |
numpy/core/tests/test_scalarmath.py
Outdated
| return false | ||
|
|
||
| class TestBaseMath: | ||
| @pytest.mark.skipif(check_support_sve, reason="gh-22982") |
There was a problem hiding this comment.
I think I slightly prefer xfail for this one, but either is OK.
| @pytest.mark.skipif(check_support_sve, reason="gh-22982") | |
| @pytest.mark.xfail(check_support_sve, reason="gh-22982") |
numpy/core/tests/test_scalarmath.py
Outdated
| shell=True).communicate()[0]).decode('utf-8') | ||
| return "sve" in process | ||
| except OSError: | ||
| return false |
There was a problem hiding this comment.
Actually, same typo here. Maybe move it together with the IS_WASM definition to not repeat this?
There was a problem hiding this comment.
Thank you very much.
I moved check_support_sve() functions to numpy/testing/_private/utils.py.
There was a problem hiding this comment.
OOps, made this comment a few days ago, but had it stored as pending review. May just follow up today, though.
Thanks, now I notice that it is public, and since it feels a bit like a hack, I may want to rename it to _SUPPORTS_SVE for now (although happy to be convinced otherwise as soon as you need it in SciPy or so).
(Happy if others disagree, its just my gut feeling.)
You removed the except OSError:, maybe it is better to have it? I am wondering if it cannot fail on weirder setups.
Anyway, may just follow up on that myself quickly, thanks.
There was a problem hiding this comment.
Sorry for the late reply.
Changed to _SUPPORTS_SVE.
Changed the check method to use OSError.
I also reviewed the fujitsu compiler options.
If it looks good, put the commit together.
Thank you.
There was a problem hiding this comment.
Thanks, tests are failing now, do you know why? I don't recall them failing before and am not aware what would have changed.
There was a problem hiding this comment.
@seberg
Sorry, I fixed it so that the test passes.
Could you please check again?
0337aff to
c317bb3
Compare
|
@seberg Ping. |
2a6b449 to
fccb005
Compare
|
Thanks @yamadafuyuka lets give it a shot :). |
This is my first pull request, so please let me know if there is anything missing.
I added an implementation for the Fujitsu C/C++ compiler (fcc/FCC) and the SSL2 library.
To build with the Fujitsu compiler, please build as follows:
SSL2 is a library that provides OpenBLAS compatible GEMM functions. SSL2 in Fujitsu Compiler is the library in the same position as MKL in Intel Compiler.
To use SSL2, please edit site.cfg. I changed system_info.py based on mkl implementation.
The regression test was run the following command:.
Because I didn't know how to specify a compiler in runtests.py, I modified the implementation to use the Fujitsu compiler and ran the tests.
Tests passed other than version check.