WIP: Add support for AMX instructions #5780
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently done as a pass before the 2d ramps are flattened. After that the loads are converted to a concat of multiple loads and it is hard to get the strides from the index expressions, mainly because Halide is cautious about overflows so can't simplify the expressions back to simple
base + i * stride
indexes it started with.Introduces an AMXTile type, so that the tiles that have to be stored by Halide are of the right type, and so that LLVM can
alloca
the right thing. Trying to use<i32 x 256>
causes problems as Halide tries to break the loads and stores into multiple vector loads. This type doesn't really need to be externally available, but I'm not sure if there's a way to have an internal only type. For the tiles that do not need to be stored (ie used directly in a tile matmul intrinsic) we don't need to use the AMX type, which should allow us to use the overloaded intrinsics to select the right instruction for the datatypes.Currently (ab)uses the way Halide calls intrinsics, but these tile intrinsics are needed to load and store from memory, so the default
call->setDoesNotAccessMemory();
is not valid. I'm not too sure how to handle this in better. There are also some hacks to get thetile_store
intrinsic to work, as it really should returnvoid
, but Halide makes some assumptions about the return types ofCall
Exprs which caused problems.