-
Notifications
You must be signed in to change notification settings - Fork 309
s390x: add nnp-assist intrinsics
#1996
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
base: main
Are you sure you want to change the base?
Conversation
folkertdev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @uweigand
| // On processors implementing the IBM z16 architecture, only the value 0 is supported. | ||
| static_assert_uimm_bits!(B, 0); | ||
|
|
||
| vclfnls(a, B) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this equivalent to
https://godbolt.org/z/dGaf4P7sa
Clearly that optimizes horribly at the moment. If the const value being 0 does the obvious thing, I believe all of these could be implemented in terms of simpler simd primitives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if currently only 0 is supported, we can just use SIMD primitives, as the assertion will ensure no other value is passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, though currently it seems unspecified what the conversion method is (I think there is only one implementation that actually makes sense, but then why is the IMM argument even there?).
Also currently the SIMD primitives don't optimize into the instruction that this intrinsic should map to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AI accelerator unit operates on its own private data types. In particular, it uses a 16-bit floating point type which is neither IEEE-16 nor bfloat16, but a proprietary format. In order to prepare input/output data to be used with the accelerator, applications need to convert standard (IEEE) data types to and from this private data type; for this purpose, the ISA provides these conversion instructions (mapped to compiler intrinsics).
In principle, the accelerator might support multiple different private data types, and the immediate operand of these intrinsics identifies which of those types the conversion should target. This is not specified by the ISA but may differ between processor generations. However, all current processors only support a single private data type, identified by the immediate value 0.
So in practice, the immediate will always be 0 today. I'm not convinced this ought to be enforced by the compiler - if a future processor adds a second type, it might be good if we could use the intrinsic without having to update the compiler.
Either way, whatever the immediate value is, there is no possibility to open-code the conversion with standard LLVM IR - the private floating-point format is unknown to LLVM! This absolutely has to map to the LLVM builtin (and thus the special instruction).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know. I've changed the code to accept the full 0..=15 range there.
cbff50d to
ea90026
Compare
Because `qemu` does not support these (yet), I haven't added any runtime tests
ea90026 to
0d5c015
Compare
|
@uweigand does this look good now? |
Looks good to me know. There is one question remaining in my mind: for That precedent was created at a time when we did not have any |
|
I suspect these functions will continue to be unstable for a while, so we could change this later if |
Sounds good to me, thanks. |
tracking issue: rust-lang/rust#135681
Because
qemudoes not support these (yet), I haven't added any runtime tests