-
Notifications
You must be signed in to change notification settings - Fork 89
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
Would it be possible to list RISC-V intrinsics in ways other than using the C programming language? #107
Comments
rust-lang/stdarch#913 is the issue currently open to track the integration. Would be nice if there is a way to automatically generate the bindings. |
LLVM uses RISCVVEmitter.cpp to read riscv_vector.td and generate the bindings from C intrinsic to clang builtin (riscv_vector.h) ex.
maybe it's a good way to use it generate the bindings. |
It is quite large and quite deep inside llvm, would be great to look if the python generator that is mentioned in few places could be repurposed for that. |
I have a new way to implement intrinsics in languages that supports template or generics. I wrote an example here: https://github.com/luojia65/rust-rvv-intrinsics/blob/main/examples/vadd.rs . Specially: let vl = vsetvl::<vint8mf8_t>(n);
let vs1 = vlv(a_ptr, vl);
let vs2 = vlv(b_ptr, vl);
let vd = vaddvv(vs1, vs2, vl);
vsv(c_ptr, vd, vl); This way of implementing intrinsics significantly reduce amount of functions (less code size, build faster), get rid of always having to define the type of intermediate variables, and checks error more conveniently. It's useful to write generic codes where original C code only define them as different functions. For checking error on build time, if I wrote wrong type for vector operations (vint16mf4_t, but correct type should be vint8mf?_t to add 8-bit vectors), it will raise error: (In this situation if adding different vector is needed, it should use vector cast functions) |
We will be releasing script to generate the intrinsic function for current C intrinsic API-s in the v1.0 release. This request is duplicate to #105 asking for |
Hello! I recently noticed how intrinsics are used in high performance CPU-bound applications. Using intrinsic functions in other architectures can allow us to use SIMD or vector conveniently in programming languages. RISC-V's V extension is more flexible, if it is written only in C programming language, it is convenient, but also includes a relevantly large amount of functions.
If we pick a language to declare intrinsic functions for one architecture, we may assume this language should be simple, expressive and relevantly widely used. Or in other words:
For another replacement we choose Rust, for it's a systems programming language, at most time low cost in abstraction, widely used (of course, support RISC-V) and have lots of stable language features like const generics. We may assume ways in Rust to describe RISC-V intrinsic functions, to provide an alternative when C programming language is not applicable.
What other concerns and issues would we met if RISC-V's V intrinsic docs is provided along with other programming languages? Thank you!
The text was updated successfully, but these errors were encountered: