This is an archive of the discontinued LLVM Phabricator instance.

[mlir][gpu] Add support for unsigned integer extend in vector to gpu.subgroup_mma lowering
ClosedPublic

Authored by qedawkins on Feb 13 2023, 8:31 AM.

Details

Summary

Unsigned integer types are supported in subgroup mma ops by matching
against arith.extui ops. This allows for subgroup_mma_compute ops with
mixed signedness which requires later conversions to handle this. SPIR-V
cooperative matrix ops support this while the lowering to WMMA does not.

Diff Detail

Event Timeline

qedawkins created this revision.Feb 13 2023, 8:31 AM
qedawkins requested review of this revision.Feb 13 2023, 8:31 AM
antiagainst accepted this revision.Feb 13 2023, 10:05 AM

LG, thanks!

mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
543

Nit: use a ternary operator to select between IntegerType::Signed and IntegerType::Unsigned to avoid duplication?

This revision is now accepted and ready to land.Feb 13 2023, 10:05 AM
ThomasRaoux accepted this revision.Feb 13 2023, 10:09 AM
qedawkins added inline comments.Feb 13 2023, 10:51 AM
mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
543

InferFragType is templated and would require a cast anyway so it's not clear to me that this is better. Would it be preferred to put this in its own templated function and update elType etc. by reference instead?

qedawkins added inline comments.Feb 13 2023, 9:53 PM
mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
543

@antiagainst gentle bump on this comment. If it's not a problem then I'll land this.

ThomasRaoux added inline comments.Feb 13 2023, 11:25 PM
mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
543

Feel free to remove the template from InferFragType and make it:

static const char *inferFragType(Operation* op) {
  assert(op->getNumResults() == 1);
  for (Operation *users : op->getUsers()) {
    auto contract = dyn_cast<vector::ContractionOp>(users);
    if (!contract)
      continue;
    if (contract.getLhs() == op.getResult(0))
      return "AOp";
    if (contract.getRhs() == op.getResult(0))
      return "BOp";
  }
  return "COp";
}
qedawkins updated this revision to Diff 497346.EditedFeb 14 2023, 8:38 AM

rebase and address comment

ThomasRaoux added inline comments.Feb 14 2023, 8:39 AM
mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
502

can you assert than op has exactly 1 result?

qedawkins updated this revision to Diff 497347.Feb 14 2023, 8:45 AM

assert exactly one result

ThomasRaoux accepted this revision.Feb 14 2023, 8:45 AM
This revision was automatically updated to reflect the committed changes.
qedawkins marked an inline comment as done.