[libre-riscv-dev] variable length vector types in shader compiler for Kazan

Luke Kenneth Casson Leighton lkcl at lkcl.net
Tue Oct 9 04:04:10 BST 2018


---
crowd-funded eco-conscious hardware: https://www.crowdsupply.com/eoma68

On Tue, Oct 9, 2018 at 3:45 AM Jacob Lifshay <programmerjake at gmail.com> wrote:
>
> I'm currently creating a wrapper for LLVM to make it easier to port the
> rest of the shader compiler

 that's interesting.  by wrapper, do you mean a converter, which takes
one LLVM format as input (IR for example) and morphs it into another?

> to use different versions of LLVM and possibly
> to use a different JIT compiler backend like GCC's jit or cranelift as well
> as isolating backend-specific oddities like LLVM not having a built-in bool
> type (they use a 1-bit integer for that, leading to messiness when loading
> or storing)

 yuk!

> and LLVM not currently having a vector reduce instruction.

 vectorisation being fairly new, that doesn't surprise me.  oh hang
on, i'm sure i saw something like that for llvm on the phabricator
thing, from ARM...  no, it was splat-vector:
https://reviews.llvm.org/D47775

> As part of creating the wrapper, I am creating the code used for creating
> vector types. This is what I have so far:
>
> /// length of a vector
> pub enum VectorLength {
>     /// fixed length vector
>     Fixed {
>         /// length in elements
>         length: u32,
>     },
>     /// variable length vector
>     Variable {
>         /// base length in elements which the runtime vector length is a
> multiple of
>         base_length: u32,
>     },
> }

 that looks quite straightforward / reasonable.

> // <snip>
> /// trait for building types
> pub trait TypeBuilder<'a> {
>     // <snip>
>     /// build a vector
>     fn build_vector(&self, element: Self::Type, length: VectorLength) ->
> Self::Type;
> }
>
> I tried to design it based off of the in-progress ARM SVE implementation
> for LLVM as that appears to be what LLVM might settle on.

 sensible.

> Meanwhile, the backends can select the variable vector length multiplier
> statically and then switch to dynamic lengths when LLVM's implementation
> lands.

btw i spoke to robin kruppe, he has an implementation of the
vectorisation IR RFC he posted back in april, he's waiting for the RVV
WG to create a repo, if they don't do that in a reasonable timeframe
he'll set up a personal repo for the branch / work instead.

l.



More information about the libre-riscv-dev mailing list