[Mlir-commits] [mlir] [MLIR][NVVM] Update dot.accumulate NVVM Ops (PR #140518)
Srinivasa Ravi
llvmlistbot at llvm.org
Thu May 22 21:48:15 PDT 2025
================
@@ -3508,6 +3508,66 @@ def NVVM_DotAccumulate4WayOp : NVVM_Op<"dot.accumulate.4way"> {
}];
}
+def NVVM_DotAccumulate2WayOp : NVVM_Op<"dot.accumulate.2way"> {
+ let summary = "Two-way 16-bit to 8-bit dot product-accumulate instruction";
+ let description = [{
+ Performs a two-way 16-bit to 8-bit dot-product which is accumulated in a
+ 32-bit result.
+ Operand `a` is a vector of two 16-bit elements and operand `b` a vector
+ of four 8-bit elements between which the dot product is computed.
+
+ The `a_type` and `b_type` attributes specify the type of the elements in `a`
+ and `b` respectively.
+ If `a_type` or `b_type` is `s`, then the elements in the corresponding
+ vector are sign-extended to 32-bit before the dot product is computed.
+ If `a_type` or `b_type` is `u`, then the elements in the corresponding
+ vector are zero-extended to 32-bit instead.
+
+ The `hi` boolean attribute specifies which two bytes of `b` are used for
+ the dot product. If `hi` is true, then the dot product is computed between
+ `a` and elements at indices 2 and 3 of `b`. If `hi` is false, then the dot
+ product is computed between `a` and elements at indices 0 and 1 of `b`.
+ By default, `hi` is false.
+
+ Operand `c` is a 32-bit integer to which the result is accumulated. It is
+ treated as holding a signed integer if any of `a_type` or `b_type` is
+ signed.
+
+ [For more information, see PTX ISA](https://docs.nvidia.com/cuda/parallel-thread-execution/#integer-arithmetic-instructions-dp2a)
+ }];
+
+ let arguments = (ins
+ VectorOfLengthAndType<[2], [I16]>:$a,
+ DotAccumulateTypeAttr:$a_type,
+ VectorOfLengthAndType<[4], [I8]>:$b,
+ DotAccumulateTypeAttr:$b_type,
+ I32:$c,
+ DefaultValuedAttr<BoolAttr, "false">:$hi
+ );
+
+ let results = (outs I32:$res);
+
+ let assemblyFormat = "$a $a_type `,` $b $b_type `,` $c attr-dict `:` type($a) `,` type($b)";
+
+ let extraClassDeclaration = [{
+ static llvm::Intrinsic::ID
+ getIntrinsicIDAndArgs(Operation &op, LLVM::ModuleTranslation &mt,
+ llvm::IRBuilderBase &builder,
+ llvm::SmallVector<llvm::Value *> &args);
+ llvm::Value* getPackedArg(llvm::Value* arg, llvm::IRBuilderBase& builder);
----------------
Wolfram70 wrote:
Changed both Ops to use `getIntrinsicIDAndArgs` and made this a static function within `NVVMDialect.cpp` in the latest revision, thanks!
https://github.com/llvm/llvm-project/pull/140518
More information about the Mlir-commits
mailing list