You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consult godbolt for how the intrinsic should be codegen'd, using clang as an example. Use the links below and replace the name of the intrinsic in the code with your intrinsic. Note that if ARM is an error then your intrinsic may be AArch64-only
If the codegen is the same on ARM/AArch64, place the intrinsic in coresimd/arm/neon.rs. If it's different place it in both with appropriate #[cfg] in coresimd/arm/neon.rs. If it's only AArch64 place it in coresimd/aarch64/neon.rs
Write a test for your intrinsic at the bottom of the file as well
Test! Probably use rustup run nightly sh ci/run-docker.sh aarch64-unknown-linux-gnu.
Is there a blocker for these, or is it just finding time to do it? I'd like to help, but I'd need a more experienced compiler/SIMD person to point me in the right direction.
I am not sure I understand the question ? The neon modules in this repository are written by hand, although @Amanieu has expressed interest into generating some parts of them automatically.
Now might be a great time to help make some more progress on this! We've got tons of intrinsics already implemented (thanks @gnzlbg!), and I've just implemented automatic verification of all added intrinsics, so we know if they're added they've got the correct signature at least!
I've updated the OP of this issue with more detailed instructions about how to bind NEON intrinsics. Hopefully it's not too bad any more!
We'll probably want to reorganize modules so they're a bit smaller and more manageable over time, but for now if anyone's interested to add more intrinsics and needs some help let me know!
This will make adding new ones easier (scrolling through a bolierplate-filled file just feels awful), and I'll add a lot more simd_subsimd_mulsimd_lt etc. ones. Would this be accepted?
Given the sheer volume of neon intrinsics, it seems rather daunting to implement them all by hand using the guide in the first post. I'm wondering if there's a deterministic data driven way to generate all of them using #[link_name = "llvm.*"] as done in the first example. Maybe the llvm c headers could be useful?
What is the reasoning behind some intrinsics linking in the LLVM intrinsic directly while others are using the generic simd_XXX functions?
Not all intrinsics have a corresponding simd_* platform-intrinsic.
I'm wondering if there's a deterministic data driven way to generate all of them using #[link_name = "llvm.*"] as done in the first example. Maybe the llvm c headers could be useful?
Please don't. The simd_* platform intrinsics are much easier to implement in alternative codegen backends than the llvm intrinsics, as they are generic over vector types and they are backend independent.
@aloucks most of the intrinsics (AFAIK) have been added piecemeal over time, so it's sort of expected that they're not 100% consistent. Otherwise though I'd imagine that whatever works best would be fine to add to this repository. Auto-generation sounds pretty reasonable to me, and for an implementation we strive to match what Clang does in its implementation of these intrinsics.
Also, to be clear, this library is not designed for ease of implementation in alternate codegen backends. The purpose of this crate is to get the LLVM backend up and running with SIMD. Discussions and design constraints for alternate backends should be discussed in a separate issue.
@Lokathor Several instructions have been added recently: vaddhn, vbic, vorn, vceqz, vtst, vabd, vaba. Though some of them are not fully supported( like vceqzd). If you don’t have time to maintain this google sheet, I think I can help
@bjorn3 Thanks! Indeed I mostly want to know when can we see it in stable version.
By the way do you suggest use nightly in production environment? If so I can use it now.
As in #1230, except for the following instructions and those use 16-bit floating-point, other instructions have been implemented:
The following instructions are only available in aarch64 now, because the corresponding target_feature cannot be found in the available features of arm: vcadd_rot、vcmla、vdot
As in #1230, except for the following instructions and those use 16-bit floating-point, other instructions have been implemented:
1. The following instructions are only available in aarch64 now, because the corresponding `target_feature` cannot be found in the available features of arm:
`vcadd_rot`、`vcmla`、`vdot`
On LLVM's ARM backend, vcadd_rot and vcmla are under the v8.3a feature. vdot is under the dotprod feature. I got this information from llvm-project/llvm/lib/Target/ARM/ARMInstrNEON.td.
2. The feature `i8mm` is not valid:
`vmmla`、`vusmmla`: [rust.godbolt.org/z/8GbKW5ef4](https://rust.godbolt.org/z/8GbKW5ef4)
@Amanieuv8.5a feature is non-runtime detected so we can't use #[simd_test(enable = "neon,v8.5a")]. So how do we add tests for instructions that use v8.5a, like vrnd32x and vrnd64x?
Activity
gnzlbg commentedon Oct 24, 2017
oconnor663 commentedon Nov 15, 2018
Is there a blocker for these, or is it just finding time to do it? I'd like to help, but I'd need a more experienced compiler/SIMD person to point me in the right direction.
gnzlbg commentedon Nov 15, 2018
I can mentor. Start by taking a look at some of the intrinsics in the
coresimd/aarch64/neon.rsmodule :)oconnor663 commentedon Nov 16, 2018
Is there some upstream source that these all get copied from, or are they actually written by hand?
gnzlbg commentedon Nov 16, 2018
I am not sure I understand the question ? The
neonmodules in this repository are written by hand, although @Amanieu has expressed interest into generating some parts of them automatically.oconnor663 commentedon Nov 16, 2018
gnzlbg commentedon Nov 16, 2018
Ah, I see, that would be the ARM NEON spec: https://developer.arm.com/technologies/neon/intrinsics
alexcrichton commentedon Dec 20, 2018
Now might be a great time to help make some more progress on this! We've got tons of intrinsics already implemented (thanks @gnzlbg!), and I've just implemented automatic verification of all added intrinsics, so we know if they're added they've got the correct signature at least!
I've updated the OP of this issue with more detailed instructions about how to bind NEON intrinsics. Hopefully it's not too bad any more!
We'll probably want to reorganize modules so they're a bit smaller and more manageable over time, but for now if anyone's interested to add more intrinsics and needs some help let me know!
valpackett commentedon Jul 28, 2019
I have a proposal for this: using a macro to make definitions one-line e.g.:
This will make adding new ones easier (scrolling through a bolierplate-filled file just feels awful), and I'll add a lot more
simd_subsimd_mulsimd_ltetc. ones. Would this be accepted?macro definition I currently have
gnzlbg commentedon Jul 28, 2019
For the definitions, I think that using macros is ok.
I am not sure I follow how does macros generate run-time tests for the intrinsics, that's usually the bulk of the work.
aloucks commentedon Jul 8, 2020
What is the reasoning behind some intrinsics linking in the LLVM intrinsic directly while others are using the generic
simd_XXXfunctions?For example:
stdarch/crates/core_arch/src/arm/neon/generated.rs
Lines 1416 to 1430 in a371069
Versus:
stdarch/crates/core_arch/src/aarch64/neon/generated.rs
Lines 12 to 18 in a371069
Given the sheer volume of neon intrinsics, it seems rather daunting to implement them all by hand using the guide in the first post. I'm wondering if there's a deterministic data driven way to generate all of them using
#[link_name = "llvm.*"]as done in the first example. Maybe the llvmcheaders could be useful?bjorn3 commentedon Jul 8, 2020
Not all intrinsics have a corresponding
simd_*platform-intrinsic.Please don't. The
simd_*platform intrinsics are much easier to implement in alternative codegen backends than the llvm intrinsics, as they are generic over vector types and they are backend independent.alexcrichton commentedon Jul 8, 2020
@aloucks most of the intrinsics (AFAIK) have been added piecemeal over time, so it's sort of expected that they're not 100% consistent. Otherwise though I'd imagine that whatever works best would be fine to add to this repository. Auto-generation sounds pretty reasonable to me, and for an implementation we strive to match what Clang does in its implementation of these intrinsics.
alexcrichton commentedon Jul 8, 2020
Also, to be clear, this library is not designed for ease of implementation in alternate codegen backends. The purpose of this crate is to get the LLVM backend up and running with SIMD. Discussions and design constraints for alternate backends should be discussed in a separate issue.
3 remaining items
nano-bot commentedon Mar 9, 2021
Awesome, looking forward to this!
fzyzcjy commentedon Sep 27, 2021
Any updates after a long time...? Thanks
bjorn3 commentedon Sep 27, 2021
If you look at the pull request list you can see that there has been activity on this quite recently. For example #1224 was opened yesterday.
fzyzcjy commentedon Sep 27, 2021
@bjorn3 Thanks! Indeed I mostly want to know when can we see it in stable version.
By the way do you suggest use nightly in production environment? If so I can use it now.
CryZe commentedon Oct 21, 2021
@SparrowLii You marked the following instructions as completed (same for min):
It doesn't seem like those instructions are actually part of your recent PR (nor were they on the master branch before that) so I unmarked them again.
SparrowLii commentedon Oct 21, 2021
@CryZe They can be found in the master branch now:
https://github.com/rust-lang/stdarch/blob/master/crates/core_arch/src/aarch64/neon/generated.rs#L8519-L8539
https://github.com/rust-lang/stdarch/blob/master/crates/core_arch/src/aarch64/neon/generated.rs#L8545-L8565
Sorry I marked them before #1230 merged, this is to prevent others from submitting duplicate PRs
CryZe commentedon Oct 21, 2021
Welp, I'll mark them again then. Somehow the GitHub Pull Request UI doesn't show them as diffs at all: https://i.imgur.com/BsHR5in.gif
SparrowLii commentedon Oct 21, 2021
Github’s comparison tool will always have problems when changing a large amount of code XD
SparrowLii commentedon Oct 21, 2021
As in #1230, except for the following instructions and those use 16-bit floating-point, other instructions have been implemented:
The following instructions are only available in aarch64 now, because the corresponding
target_featurecannot be found in the available features of arm:vcadd_rot、vcmla、vdotThe feature
i8mmis not valid:vmmla、vusmmla: https://rust.godbolt.org/z/8GbKW5ef4LLVM ERROR(Can be reproduced in godbolt):
vsm4e: https://rust.godbolt.org/z/xhT1xvGTPLLVM ERROR(Normal in gotbolt, but
LLVM ERROR: Cannot select: intrinsicraises at runtime)vsudot、vusdot: https://rust.godbolt.org/z/aMnEvab3nvqshlu: https://rust.godbolt.org/z/hvGhrhdMTNot implmented in LLVM and cannot be implemented manually:
vmull_p64(for arm)、vsm3、vrax1q_u64、vxarq_u64、vrnd32、vrnd64、vsha512Amanieu commentedon Oct 21, 2021
On LLVM's ARM backend,
vcadd_rotandvcmlaare under thev8.3afeature.vdotis under thedotprodfeature. I got this information fromllvm-project/llvm/lib/Target/ARM/ARMInstrNEON.td.Already discussed in rust-lang/rust#90079.
Use
llvm.aarch64.crypto.sm4ekeyinstead ofllvm.aarch64.sve.sm4ekey.You need to make you test function
pubin godbolt, otherwise it will be optimized away as unreachable by rustc before LLVM.vsudot/vusdotrequire thei8mmtarget feature.vqshluseems to work fine in godbolt after changing thepub.These all seem to exist in LLVM at least for AArch64. For ARM we can just leave these out for now.
SparrowLii commentedon Oct 25, 2021
Hope someone can help implement the remaining instructions.
SparrowLii commentedon Nov 9, 2021
@Amanieu
v8.5afeature is non-runtime detected so we can't use#[simd_test(enable = "neon,v8.5a")]. So how do we add tests for instructions that usev8.5a, likevrnd32xandvrnd64x?hkratz commentedon Nov 9, 2021
@SparrowLii Shouldn't that work with the
frinttsfeature?SparrowLii commentedon Nov 9, 2021
Looks useful: https://rust.godbolt.org/z/894W8cndG
Amanieu commentedon Nov 9, 2021
LLVM only supports
frinttson AArch64, so it's fine to not support this intrinsic on ARM.