-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
RISC V vector predication support intrinsics support #7119
Conversation
useful for RISC V, but it may be a simpler, better optimized path, for Halide vector operations in general. Add support for a maximum vector size that might be larger than the native vector size. RISC V vector LMUL support is an example of an architecture supporting this.
promotion contexts.
vector predication intrinsics.
improving the calling convention and naming of the new routines to generate the intrinsics.
caveperson programmer habits die hard. Improve comments.
concatenation into one line.
Change TODO(zalman) to TODO(zvookin) uniformly. Few other cleanups.
strided load for dense case. Add some comments.
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.
Looks good, mostly nits
@steven-johnson Do the buildbots test RISC-V cross-compilation? If so, this PR should probably make an addition to simd_op_check, to check for the added vector instructions in this PR. |
Not currently, no. We should definitely add that. |
Added an issue for simd_op_check coverage. #7122 |
Yeah, I'd rant that not having the rounding mode flags in the intrinsic at
the start is badly broken, but it's sort of how things are with LLVM and
RISC V. Really they ought to be in the opcode, but you know, bits are
expensive. I put in references to a couple PRs for LLVM but it doesn't
look like there is recent movement on this.
…On Tue, Oct 25, 2022 at 2:09 PM Andrew Adams ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/CodeGen_RISCV.cpp
<#7119 (comment)>:
> + llvm::Function *wrapper =
+ llvm::Function::Create(wrapper_ty, llvm::GlobalValue::InternalLinkage,
+ wrapper_name, module.get());
+ llvm::BasicBlock *block =
+ llvm::BasicBlock::Create(module->getContext(), "entry", wrapper);
+ llvm::IRBuilderBase::InsertPoint here = builder->saveIP();
+ builder->SetInsertPoint(block);
+
+ // Set vector fixed-point rounding flag if needed for intrinsic.
+ bool round_down = intrin.flags & RISCVIntrinsic::RoundDown;
+ bool round_up = intrin.flags & RISCVIntrinsic::RoundUp;
+ if (round_down || round_up) {
+ internal_assert(!(round_down && round_up));
+ llvm::Value *rounding_mode = llvm::ConstantInt::get(xlen_type, round_down ? 2 : 0);
+ // TODO: When LLVM finally fixes the instructions to take rounding modes,
+ // this will have to change to passing the rounding mode to the intrinsic.
Is there an existing LLVM issue for it? Having to use inline assembly to
use any of the ops that rely on a rounding flag seems ... unfinished.
—
Reply to this email directly, view it on GitHub
<#7119 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALOUFEADYCC7HI3PIWVT6LWFBEARANCNFSM6AAAAAARNTLZIE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
std::variant for mask was not handled correctly.
arg, or result type if no vector argument.
intrinsic. (Needed for loads.) Fix result type of vector predication reductions.
Had to do a number of bug fixes on the vector predication work as I messed up on the test coverage previously. It works better with the code in this branch... |
I believe I have addressed the feedback raised. In a couple cases, by opening tracking issues, but mostly by incorporating the changes suggested or fixing the problems raised. If I've missed anything please let me know. I also did some better testing. Obviously that should get rolled into the real tests, which is effectively the simd_op_check issue. This should be ready to land. |
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.
LGTM pending green
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.
Also LGTM with a nit
widths in RISC V intrinsics.
I improved naming and comments around the handling of all the integer type widths. |
Vector efficiency improvement oer code review feedback.
Turn on vector predication support for RISC V. (First architecture to use this code. Bug fixes included here.) Add architecture specific vector intrinsics support as well. Should not affect anything outside of RISC V.
Have RISC V use LLVM vector predication intrinsics and add support for some architecture specific intrinsics.