Skip to content

Vector shape

Simon Moll edited this page Oct 11, 2018 · 3 revisions

Vector shapes

The vector shapes encodes how the values that each thread (vector lane) sees are related. RV distinguishes two kinds of shapes: strided shapes and varying shapes. The canonical representation of a value with a specific vector shape is the data type that RV will use to vectorize it.

Strided shapes

Strided shapes indicate that lanes are related by a constant stride s and that the first lane is always a multiple of an alignment constant a. That is if v is the value of the first lane then v+l*s is the value of the l-th lane and v is divisible by a. If s==0 then this a uniform shape. The canonical representation of a strided value is a scalar type (the same type as in the scalar code, e.g. a strided float value will be vectorized as a float value that holds the value of the first lane).

Varying shapes

Varying shapes indicate that there is no identified relation between the lanes of a value. Varying shapes still know about alignment. In their case, the alignment applies independently to all lanes (e.g. each lane is an independent multiple of the alignment a). The canonical representation of a varying value is a vector type (e.g. a varying float value will be vectorized as a <W x float> value where W is the vector width. Each element of the vector holds the value of the corresponding lane. In WFV mode, varying shapes on the vector function's arguments may only be used if the type is a valid LLVM-vector element type. RV is otherwise able to represent varying values that have a non-vectorizable type.

Pointers

Vector shapes for pointers are type agnostic: all pointer shapes refer to the numerical address that the pointer holds (i.e as if it were an i8*-type. For example, a pointer with a vector shape stride of 4 has a stride of 4 bytes and would qualify for a consecutive memory access if the actual data type is i32.

Clone this wiki locally