-
Notifications
You must be signed in to change notification settings - Fork 16
Vector mapping
(This is a work in progress.)
A Vector Mapping associates a scalar function (scalarFn) with a vector function (vectorFn) along with constraints under which RV may use the vector function to vectorize calls to the scalar function. The vector mapping also encodes the result Vector Shape of the function.
If maskPos >= 0 then the vector function has an additional vector predicate parameter at position maskPos.
In that case the vector mask parameter must have <W x i1> type and is implicitly assumed to be varying.
The argShapes encode the Vector Shape of each vector function parameter. The vector function will only be used if each the vector function parameter is compatible with the shape of the passed-in value at the call site. E.g. this disqualifies a vector mapping if the passed-in value has a varying shape but the argShape for that argument is consecutive.
Note that argShapes is indexed by the scalar parameter index. If maskPos <= 0 that means that a scalar parameter at position i maps to the vector function parameter at position i. However, if the vector function has a predicate parameter then the vector parameter index for all following parameters are shifted by one, that is the scalar parameter at position i is mapped to vector function parameter i+1 for i >= maskPos and maskPos >= 0.
The call predicate mode of a vector mapping encodes whether and how a function call can be vectorized in a predicated context. As such the call predicate mode restricts the applicability of the vector function. RV currently supports three CallPredicateModes. Note that all of these modes are compatible with predicated vector functions (maskPos >= 0).
-
UnpredicatedThe vector function does not support predication at all. The function will only be vectorized if RV can guarantee that the predicate is all-true (ie. that the block predicate is uniform). This should be the safe default for vector functions of which there is no knowledge of their behavior and that do not have a predicate argument. -
PredicateArgThe vector function has a mandatory mask parameter. This should be the default if a predicata parameter exists (e.g. those resulting from the "inbranch" clause in OpenMP 4.x). -
SafeWithoutPredicateIt is safe to use this vector function in all call contexts, regardless of the predicate. This should be used for functions that can safely run with lanes initialized toundefeven though the vector function internally assumes that all vector lanes are active.