[llvm-dev] [cfe-dev] RFC: Matrix math support
Florian Hahn via llvm-dev
llvm-dev at lists.llvm.org
Fri Nov 22 06:18:02 PST 2019
> On Nov 19, 2019, at 21:24, Richard Smith <richard at metafoo.co.uk> wrote:
> Support in Clang
> We are also planning to expose the matrix support in Clang via a matrix type on the C/C++ level (similar to the ext_vector_type attribute) together with a set of matrix builtins. Similar to the LLVM part, we would like to propose a pragmatic solution for common matrix operations, while being flexible enough to allow iterative improvements to accommodate additional requirements. The main motivation for the matrix support on the Clang side is to give users a way to
> Guarantee generating high-quality code for matrix operations and trees of matrix operations. For isolated operations, we can guarantee vector code generation suitable for the target. For trees of operations, the proposed value type helps with eliminating temporary loads & stores.
> Make use of specialized matrix ISA extensions, like the new matrix instructions in ARM v8.6 or various proprietary matrix accelerators, in their C/C++ code.
> Move optimisations from matrix wrapper libraries into the compiler. We use it internally to simplify an Eigen-style matrix library, by relying on LLVM for generating tiled & fused loops for matrix operations.
> We propose adding a new matrix value type, that can be declared via a `matrix_type` attribute. Alternatively we could also generalise the existing ext_vector_type attribute ( <https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors>), if that is preferred. Initially, the matrix type supports 2 dimensions (rows & columns). For example, a 4x4 float matrix would be declared as `typedef float m4x4_t __attribute__((matrix_type(4, 4)));`.
> Hi Florian,
> You can find Clang's policy for accepting language extensions described at http://clang.llvm.org/get_involved.html <http://clang.llvm.org/get_involved.html>
> This extension clearly satisfies point 2, and I'm happy to trust that we can iterate to satisfying points 6 and 7. I would like to hear your thoughts on the other criteria.
Thank you very much for taking a look! We are working on a clang-focused update to the proposal to get a discussion rolling on the Clang integration. Thanks for pointing me to the policy for language extensions, we will make sure to cover the points mentioned there.
With Thanksgiving coming up in the US, it will probably take us until after the holidays to share the update.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev