[Libre-soc-bugs] [Bug 632] Potentially share Vector Math libraries with Rust's project portable SIMD (`std::simd`)

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Mon May 3 12:21:35 BST 2021


https://bugs.libre-soc.org/show_bug.cgi?id=632

--- Comment #8 from Jacob Lifshay <programmerjake at gmail.com> ---
>From https://github.com/rust-lang/stdsimd/issues/109#issuecomment-831196244
Got all the vector traits wired up for use with scalars (where all vectors are
length 1 for testing purposes or otherwise) and with generating demo compiler
IR. Still need to wire up `std::simd` support.

https://salsa.debian.org/Kazan-team/vector-math/-/blob/7975aa9639f3a5a702b130a7cf992ffe71c86e2a/src/ir.rs#L1547
The following Rust:
```rust
fn f<Ctx: Context>(ctx: Ctx, a: Ctx::VecU8, b: Ctx::VecF32) -> Ctx::VecF64 {
    let a: Ctx::VecF32 = a.into();
    (a - (a + b - ctx.make(5f32)).floor()).to()
}
```
(the `to()` function is a replacement for the `as` keyword)

Generates the following demo IR:
```
function(in<arg_0>: vec<U8>, in<arg_1>: vec<F32>) -> vec<F64> {
    op_0: vec<F32> = Cast in<arg_0>
    op_1: vec<F32> = Add op_0, in<arg_1>
    op_2: vec<F32> = Sub op_1, splat(0x40A00000_f32)
    op_3: vec<F32> = Floor op_2
    op_4: vec<F32> = Sub op_0, op_3
    op_5: vec<F64> = Cast op_4
    Return op_5
}
```

Opinions on ease of use for writing functions like `f`?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list