-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Support for RISC-V architecture #8213
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
Comments
Can you submit this as a pull request? On Wed, Oct 26, 2016 at 9:48 AM, rwmjones [email protected] wrote:
Nathaniel J. Smith -- https://vorpus.org http://vorpus.org |
@rwmjones ping? :-) |
This patch as written won't work because the final version of GCC used different macros. You would need to use something like:
|
Here's the latest patch, written by David Abdurachmanov: |
Again, please submit this as a pull request. |
Couldn't you just grab the patch and apply it? The github "workflow" for pull requests is incredibly tedious. |
Was the patch tested? Does the test suite pass with it, or does it just
fix compilation.
|
So it was compile tested, yes. You can find the logs for that here: https://fedorapeople.org/groups/risc-v/logs/numpy-1.14.2-1.0.riscv64.fc28.src.rpm/build.log We have built other packages using this, but we have not run the numpy test suite. BTW my colleague suggested that you should just use |
If you like you can grab bootable disk images which can be run on x86_64: https://fedorapeople.org/groups/risc-v/disk-images/ Compiling numpy will take a very long time, probably days. No idea about running the test suite but that could equally take days. |
If the patch has only been compile-tested, then I think it should not
be applied.
The per-arch flags don't only control endianness, but also other stuff
e.g. long double repr.
|
All changes to numpy go through pull requests, so you're asking random volunteers to do your "tedious" work for you. It's not usually a great way to make people sympathetic to your change... |
I backported the patch to the Debian package, so on version 1.13.3. It built fine on riscv64 and the testsuite is almost fine too: Python 2.7:
Python 3.6:
In both cases the failures are the same:
The first failure is specific to RISC-V and probably needs some investigation. The second failure is due to f2py missing during the build, and also happens when building the Debian package on other architectures. I guess the per-arch flags are correct, otherwise I would have expected many more failures. |
I investigated the
The code that doesn't behave on RISC-V is the following one:
Basically -np.nan is a float64 value, that is converted to float32 when assigned to the array. This caused it to be canonicalized and to loose the negative sign. That's also the reason why the test_double part doesn't fail as there is no float64 to float32 conversion. One (ugly) way to make the test pass is to change the sign after converting the value to float32:
|
Huh. Indeed, on page 48 of Volume I: RISC-V User-Level ISA V2.2 it says:
It might be "optional", but it's provided by all the major general-purpose ISAs, and whole ecosystems like R have grown up assuming that CPUs do NaN payload propagation, since it's required for efficient NA support. Hopefully NumPy will assume this soon too. Sorta tempted to say that if a weirdo ISA that no-one uses has broken IEEE-754 then it's the compiler's job to work around that, not ours. Of course this would destroy floating point performance, but wtf, you can't just leave out a chunk of IEEE 754. I get that RISC-V is supposed to scale down to special-purpose DSPs and stuff like that where you'd never run general-purpose software like NumPy, so if that kind of chip wants to leave out important functionality like this then whatever, but I sure hope that by the time people start shipping bigger chips they'll have sorted out that "nonstandard operating mode"... |
RISC-V (pronounced "RISC Five") is an open source instruction set architecture (ISA). The 64-bit version may run the Linux kernel and the usual stack of applications on top of it, including Python. This patch adds support for riscv64 to Numpy. With it the full testsuite passes for both Python 2.7 and 3.6, with the only exception of test_float (test_numeric.TestBoolCmp). See numpy#8213 for details. Closes: numpy#8213
I went ahead and merged the patch as it doesn't affect any other architectures. If risc-v doesn't work after this, I figure it is someone else's problem ;) |
Patch for RISC-V (64 bit only) support:
http://oirase.annexia.org/tmp/numpy-riscv64.patch
The text was updated successfully, but these errors were encountered: