Repository navigation
New mmt4d builtin with general code and some assembly kernels (i8mm, dotprod) - #10339
Conversation
963f8e7 to
1896715
Compare
First part of #10339 for review.
1896715 to
8f7b9e1
Compare
8f7b9e1 to
3172e3f
Compare
|
Next PR in the queue is #10389, fleshing out |
| #else | ||
| (void)params; | ||
| #endif | ||
| return 0; |
There was a problem hiding this comment.
(resolved on discord - keeping 0 because NULL requires including some standard header and this is a place where even stdint.h is off-limits)
There was a problem hiding this comment.
"even stdint.h is off-limits" - makes me so happy :)
|
|
||
| #include "iree/builtins/ukernel/mmt4d_tile_generic.h" | ||
|
|
||
| // In order to be helpful as a reference for future architecture-specific |
There was a problem hiding this comment.
this is cool! often in reference implementations they're implemented so differently from the optimized ones that it's hard to correlate the two - this should be much easier for people to take and translate than needing to look at a different arch-specific implementation and translate that
There was a problem hiding this comment.
yup, this kind of meta issue is somewhat important here, the hope being that over time this will get ported by to other archs by other people.
OK, I wanted to slice this down further for review (I only split #10366), but that's proving a bit of work and I wonder if the context from having this all in one shot might actually be helpful to understand the design.
Anyway, the diff breaks down into these areas:
iree/modules/vmvx/module.c: The main change here is thatiree_vmvx_mmt4dis un-typed i.e. the types become a runtime enum, de-duplicating the code between the two mmt4d functions there. This required some changes to theMAP_BUFFER_*macros, adding_UNTYPEDflavors. The general idea is that when one only needs a type to get itssizeof, one may as well be taking the size and not the type.iree/builtins/ukernel/BUILD/CMake changes - there is a general refactoring there, independent of the mmt4d-specific impl changes. I've tried to suggest a structure that future builtin kernels might want to follow, but the existingelementwisestuff didn't fit well, it's special in multiple ways: it implements its own shims, and it only has generic not actual architecture-specific code yet.iree/builtins/ukernel/{mmt4d.h, mmt4d_types.h}- Some general, cheap declarations are moved to a new headermmt4d_types.hwhich is what the internal implementation files want to#include, whilemmt4d.hbecomes the user-facing API header. This split avoids circular dependencies.iree/builtins/ukernel/mmt4d.c- the general implementation of mmt4d. Start reading from the entry point and you'll see the idea. Pasting it here for convenience:The the idea is: first we select a tile function pointer, which might be some ARM assembly or some generic slow code; then we call the universal implementation
iree_ukernel_mmt4d_using_tile_funcwith it.iree/builtins/ukernel/mmt4d_tile_generic.c- the generic tile implementation.iree/builtins/ukernel/arm_64/- the ARM64 tile implementations.Design thoughts:
Compared to ruy, the indirect call into the optimized kernel occurs at finer granularity: only the innermost loop is implemented by the asm kernel, all loops above that are generic code. This means that compared to ruy, we are changing the trade-off a little more towards optimizing for code size, possibly away from aggressive performance optimization. It's partly due to my understanding that this new trade-off is a better match for what we're trying to build here, and partly having learned from ruy's experience going maybe a little too deep in its direction. Can elaborate on request but too much to say for a github PR description (@silvasean and I just had an hour-long rehash of these topics so it's refreshed in my memory).