[libre-riscv-dev] Vector Operations Extension (cross, dot, length, lerp, slerp)

lkcl luke.leighton at gmail.com
Mon Sep 16 10:39:48 BST 2019


On Mon, Sep 16, 2019 at 9:44 AM Jacob Lifshay <programmerjake at gmail.com> 
wrote:

> I definitely think SLERP shouldn't be a HW instruction, it is not used
> often enough and has several trig function calls as well as having
> dozens of flops worth of computation per subvector.

ok.

> normalize is about my limit for internal complexity that I think might
> be worth-while to implement as a HW instruction.

hypot tends to exist, which is fairly close to "distance".  hypot takes two 
scalars, and distance, len, normalise and hypot are all related.  which 
one(s) are the best to do as ops and which as pseudo-ops, i really don't 
know.

> dot product definitely can be a HW instruction,

it typically needs extra internal accuracy for the accumulated result.  if 
done in pure assembler you need a 64-bit accumulator to handle 32-bit ops, 
which is a pain.

> and cross product might.
>
> cross product should be able to be implemented with a four shuffles,
> one element-wise multiply, and one element-wise mulsub:
>
> vec3 a, b; // elements in order a.x, a.y, a.z
> // compute a cross b:
> vec3 t1 = a.yzx; // produce vector [a.y, a.z, a.x]
> vec3 t2 = b.zxy;
> vec3 t3 = a.zxy;
> vec3 t4 = b.yzx;
> vec3 p = t3 * t4;
> vec3 cross = t1 * t2 - p;

ok will put that on the page.

l.


More information about the libre-riscv-dev mailing list