You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently tried to wrap RVV intrinsic types and functions into templates, but I found it painful. In addition to the changes proposed here, I would like to propose a new way to define intrinsic types.
The specific naming can be discussed further. I haven't given it much thought.
Motivation
The amount of RVV intrinsic types is huge. Sometimes we may want to parameterize these types, so that we can choose proper types automatically and do some compile-time evaluations. A parameterized representation also simplifies function APIs.
Design
The syntax is similar to the vector extension of GCC. For example, if we want to obtain a vint32m1_t, we can write
Available in C language. Although it is not in standard C, vector extensions and overloaded intrinsic functions are not either.
It makes RVV intrinsic types much easier to use in templates. To wrap it into templates, we can simply write
template<classE, __lmul L>
structrvv_intrin {
static_assert(sizeof(E) * L >= ELEN);
using type [[__gnu__::__rvv_lmul__(L)]] = E;
using element_type = E;
inlineconstexprstatic __lmul lmul = L;
};
This is way too better than a bunch of specializations or if constexprs, both for compilers and humans.
Compatibility
We can let types defined by attributes be aliases of existing types like vint32m1_t, so that it is backward compatible. Or reversely, let existing types be aliases of types defined by attributes.
The text was updated successfully, but these errors were encountered:
I recently tried to wrap RVV intrinsic types and functions into templates, but I found it painful. In addition to the changes proposed here, I would like to propose a new way to define intrinsic types.
The specific naming can be discussed further. I haven't given it much thought.
Motivation
The amount of RVV intrinsic types is huge. Sometimes we may want to parameterize these types, so that we can choose proper types automatically and do some compile-time evaluations. A parameterized representation also simplifies function APIs.
Design
The syntax is similar to the vector extension of GCC. For example, if we want to obtain a
vint32m1_t
, we can writeor in C++ style
where
__m1
is an enum defined likeMask types are similar.
Benefits
Available in C language. Although it is not in standard C, vector extensions and overloaded intrinsic functions are not either.
It makes RVV intrinsic types much easier to use in templates. To wrap it into templates, we can simply write
This is way too better than a bunch of specializations or
if constexpr
s, both for compilers and humans.Compatibility
We can let types defined by attributes be aliases of existing types like
vint32m1_t
, so that it is backward compatible. Or reversely, let existing types be aliases of types defined by attributes.The text was updated successfully, but these errors were encountered: