Skip to content

Conversation

@kvederni
Copy link
Contributor

This change adds intrinsics for MMA sparse. The implementation is based on PTX ISA version 8.8.

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Jul 28, 2025

@llvm/pr-subscribers-llvm-ir

Author: Kirill Vedernikov (kvederni)

Changes

This change adds intrinsics for MMA sparse. The implementation is based on PTX ISA version 8.8.


Patch is 31.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/150950.diff

4 Files Affected:

  • (modified) llvm/include/llvm/IR/IntrinsicsNVVM.td (+183-6)
  • (modified) llvm/lib/Target/NVPTX/NVPTXIntrinsics.td (+78-4)
  • (added) llvm/test/CodeGen/NVPTX/wmma-ptx87-sm120a.py (+12)
  • (modified) llvm/test/CodeGen/NVPTX/wmma.py (+252-15)
diff --git a/llvm/include/llvm/IR/IntrinsicsNVVM.td b/llvm/include/llvm/IR/IntrinsicsNVVM.td
index 967d1663f237b..c4f3e1b394c8e 100644
--- a/llvm/include/llvm/IR/IntrinsicsNVVM.td
+++ b/llvm/include/llvm/IR/IntrinsicsNVVM.td
@@ -170,7 +170,7 @@ class StrJoin<string sep, list<string> str_list> {
 // Geom: m<M>n<N>k<K>. E.g. m8n32k16
 // Frag: [a|b|c|d] ([x1|x2|x4] for ldmatrix)
 // PtxEltType: PTX type for the element.
-class WMMA_REGS<string Geom, string Frag, string PtxEltType> {
+class WMMA_REGS<string Geom, string Frag, string PtxEltType, bit IsSparse = false> {
   string geom = Geom;
   string frag = Frag;
   string ptx_elt_type = PtxEltType;
@@ -178,6 +178,54 @@ class WMMA_REGS<string Geom, string Frag, string PtxEltType> {
   string gf = Geom#":"#Frag;
   string ft = frag#":"#ptx_elt_type;
   list<LLVMType> regs = !cond(
+    // mma sparse ops use other fragments for some arguments
+    !and(!eq(gft, "m16n8k16:a:bf16"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k16:a:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 2),
+    !and(!eq(gft, "m16n8k32:a:bf16"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k32:a:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 4),
+    !and(!eq(gft, "m16n8k32:b:bf16"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k32:b:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 4),
+    !and(!eq(gft, "m16n8k32:c:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 2),
+    !and(!eq(gft, "m16n8k32:c:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k32:d:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 2),
+    !and(!eq(gft, "m16n8k32:d:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k16:a:tf32"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k16:b:tf32"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k16:c:tf32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k16:d:tf32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k8:a:tf32"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k32:a:u8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k32:a:s8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k64:a:u8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:s8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:e4m3"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:e5m2"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:e3m2"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:e2m3"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:e2m1"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:u8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:s8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:e4m3"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:e5m2"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:e3m2"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:e2m3"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:e2m1"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:c:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 2),
+    !and(!eq(gft, "m16n8k64:c:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k64:d:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 2),
+    !and(!eq(gft, "m16n8k64:d:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:u4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k64:a:s4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k128:a:u4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:a:s4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:a:e2m1"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:b:u4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:b:s4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:b:e2m1"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:c:s32"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:c:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k128:d:s32"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:d:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
     // mma fp ops use smaller fragments than wmma fp ops
     !eq(gft,"m8n8k4:a:f16") : !listsplat(llvm_v2f16_ty, 2),
     !eq(gft,"m8n8k4:b:f16") : !listsplat(llvm_v2f16_ty, 2),
@@ -362,6 +410,12 @@ class WMMA_NAME_LDST<string Op, WMMA_REGS Frag, string Layout, int WithStride> {
 
 class MMA_SIGNATURE<WMMA_REGS A, WMMA_REGS B, WMMA_REGS C, WMMA_REGS D> {
   list<WMMA_REGS> id_frags = !cond(
+     // FP8/F8F6F4 ops are identified by A,B inputs & accomulator & result type.
+     !or(!eq(A.ptx_elt_type, "e4m3"),
+         !eq(A.ptx_elt_type, "e5m2"),
+         !eq(A.ptx_elt_type, "e3m2"),
+         !eq(A.ptx_elt_type, "e2m3"),
+         !eq(A.ptx_elt_type, "e2m1")): [D, A, B, C],
      // FP16 ops are identified by accumulator & result type.
      !eq(A.ptx_elt_type, "f16") : [D, C],
      // other ops are identified by input types.
@@ -397,6 +451,19 @@ class MMA_NAME<string ALayout, string BLayout, int Satfinite, string b1op,
                   # signature;
 }
 
+class MMA_SP_NAME<string Metadata, string Kind, int Satfinite,
+                  WMMA_REGS A, WMMA_REGS B,
+                  WMMA_REGS C, WMMA_REGS D> {
+  string signature = MMA_SIGNATURE<A, B, C, D>.ret;
+  string record = "int_nvvm_mma"
+                  # "_" # !subst("::", "_", Metadata)
+                  # "_" # A.geom
+                  # "_row_col"
+                  # !if(!ne(Kind, ""), !strconcat("_", !subst("::", "_", Kind)), "")
+                  # !if(Satfinite, "_satfinite", "")
+                  # signature;
+}
+
 class LDMATRIX_NAME<WMMA_REGS Frag, int Trans> {
   string intr = "llvm.nvvm.ldmatrix.sync.aligned"
                 # "." # Frag.geom
@@ -424,21 +491,22 @@ class STMATRIX_NAME<WMMA_REGS Frag, int Trans> {
 //   TypeN: PTX type of the corresponding fragment's element.
 //   TypeB and TypeD may be empty if it must match that of TypeA or TypeC.
 class MMA_OPS<list<string> Geom, list<string> TypeA, list<string> TypeB,
-            list<string> TypeC, list<string> TypeD> {
+            list<string> TypeC, list<string> TypeD, bit IsSparse = false> {
   list<list<WMMA_REGS>> ret =
      !foldl([]<list<WMMA_REGS>>, Geom, t1, geom, !listconcat(t1,
      !foldl([]<list<WMMA_REGS>>, TypeA, t2, type_a, !listconcat(t2,
      !foldl([]<list<WMMA_REGS>>, !if(!size(TypeB), TypeB, [type_a]), t3, type_b, !listconcat(t3,
      !foldl([]<list<WMMA_REGS>>, TypeC, t4, type_c, !listconcat(t4,
      !foldl([]<list<WMMA_REGS>>, !if(!size(TypeD), TypeD, [type_c]), t5, type_d, !listconcat(t5,
-            [[WMMA_REGS<geom, "a", type_a>,
-              WMMA_REGS<geom, "b", type_b>,
-              WMMA_REGS<geom, "c", type_c>,
-              WMMA_REGS<geom, "d", type_d>]]))))))))));
+            [[WMMA_REGS<geom, "a", type_a, IsSparse>,
+              WMMA_REGS<geom, "b", type_b, IsSparse>,
+              WMMA_REGS<geom, "c", type_c, IsSparse>,
+              WMMA_REGS<geom, "d", type_d, IsSparse>]]))))))))));
    // Debugging aid for readable representation of the list above.
    list<list<string>> ops = !foreach(x, ret, [x[0].gft, x[1].gft, x[2].gft, x[3].gft]);
 }
 
+
 class MMA_LDST_OPS<list<string> Geom, list<string> Frags, list<string> Types> {
   list<WMMA_REGS> ret =
      !foldl([]<WMMA_REGS>, Geom, t1, geom, !listconcat(t1,
@@ -522,6 +590,30 @@ class NVVM_MMA_OPS {
             tf32_mma_ops, bf16_mma_ops, f64_mma_ops,
             fp_mma_ops, int_mma_ops, subint_mma_ops, bit_mma_ops);
 
+  list<list<WMMA_REGS>> bf16_mma_sp_ops = MMA_OPS<
+            ["m16n8k16", "m16n8k32"],
+            ["bf16"], [], ["f32"], [], true>.ret;
+  list<list<WMMA_REGS>> tf32_mma_sp_ops = MMA_OPS<
+            ["m16n8k8", "m16n8k16"],
+            ["tf32"], [], ["f32"], [], true>.ret;
+  list<list<WMMA_REGS>> fp_mma_sp_ops = MMA_OPS<
+            ["m16n8k16", "m16n8k32"],
+            ["f16"], [], ["f16", "f32"], ["f16", "f32"], true>.ret;
+  list<list<WMMA_REGS>> fp8_mma_sp_ops = MMA_OPS<
+            ["m16n8k64"],
+            ["e4m3", "e5m2", "e3m2", "e2m3", "e2m1"],
+            ["e4m3", "e5m2", "e3m2", "e2m3", "e2m1"],
+            ["f16", "f32"], ["f16", "f32"], true>.ret;
+  list<list<WMMA_REGS>> subint_mma_sp_ops = MMA_OPS<
+            ["m16n8k64", "m16n8k128"],
+            ["s4", "u4"], ["s4", "u4"], ["s32"], [], true>.ret;
+  list<list<WMMA_REGS>> int_mma_sp_ops = MMA_OPS<
+            ["m16n8k32", "m16n8k64"],
+            ["s8", "u8"], ["s8", "u8"], ["s32"], [], true>.ret;
+  list<list<WMMA_REGS>> all_mma_sp_ops = !listconcat(
+            bf16_mma_sp_ops, tf32_mma_sp_ops, fp_mma_sp_ops, fp8_mma_sp_ops,
+            subint_mma_sp_ops, int_mma_sp_ops);
+
   list<WMMA_REGS> ldst_ab_ops = MMA_LDST_OPS<
             ["m16n16k16", "m32n8k16", "m8n32k16"],
             ["a", "b"], ["f16", "u8", "s8", "bf16"]>.ret;
@@ -728,6 +820,68 @@ class NVVM_STMATRIX_SUPPORTED<WMMA_REGS frag, bit trans> {
   );
 }
 
+
+// Returns true if this combination of layout/kind/satf for MMA.SP ops is supported;
+// false otherwise.
+// E.g.
+// if NVVM_MMA_SP_SUPPORTED<...>.ret then
+//   def : FOO<>; // The record will only be defined for supported ops.
+//
+class NVVM_MMA_SP_SUPPORTED<list<WMMA_REGS> frags, string metadata,
+                            string kind, int satf> {
+  // MMA.SP ops check both layouts.
+  string a_type = frags[0].ptx_elt_type;
+  string b_type = frags[1].ptx_elt_type;
+  string c_type = frags[2].ptx_elt_type;
+  string d_type = frags[3].ptx_elt_type;
+  string geom = frags[0].geom;
+
+  bit is_int = !or(!eq(a_type, "s8"),
+                   !eq(a_type, "u8"),
+                   !eq(a_type, "s4"),
+                   !eq(a_type, "u4"));
+
+  bit ret = !cond(
+
+    // Limit satf to valid types
+    !and(!eq(satf, 1),
+         !eq(is_int, 0)): false,
+
+    // f16/bf16/tf32 requires A and B to be the same type.
+    !and(!or(!eq(a_type, "f16"),
+             !eq(a_type, "bf16"),
+             !eq(a_type, "tf32")),
+         !ne(a_type, b_type)): false,
+
+    // m16n8k16 and m16n8k32 requires C and D to be the same type.
+    !and(!or(!eq(geom, "m16n8k16"),
+             !eq(geom, "m16n8k32")),
+         !ne(c_type, d_type)): false,
+
+    !and(!eq(kind, ""),
+         !or(!eq(a_type, "e3m2"),
+             !eq(a_type, "e2m3"),
+             !eq(a_type, "e2m1"),
+             !eq(b_type, "e3m2"),
+             !eq(b_type, "e2m3"),
+             !eq(b_type, "e2m1"))): false,
+
+    !and(!eq(kind, ""),
+         !eq(geom, "m16n8k64"),
+         !or(!eq(c_type, "f16"),
+             !eq(d_type, "f16"))): false,
+
+    !and(!ne(kind, ""),
+         !or(!eq(metadata, "sp"),
+             !ne(geom, "m16n8k64"),
+             !eq(is_int, 1))): false,
+
+    // All other are OK.
+    true: true
+  );
+}
+
+
 class SHFL_INFO<bit sync, string mode, string type, bit return_pred> {
   string Suffix = !if(sync, "sync_", "")
                   # mode # "_"
@@ -2001,6 +2155,29 @@ foreach layout_a = ["row", "col"] in {
   } // layout_b
 } // layout_a
 
+// MMA.SP
+class NVVM_MMA_SP<WMMA_REGS A, WMMA_REGS B, WMMA_REGS C, WMMA_REGS D>
+  : Intrinsic<D.regs,
+              !listconcat(A.regs, B.regs, C.regs, [llvm_i32_ty], [llvm_i32_ty])> {
+    int pos = !size(!listconcat(A.regs, B.regs, C.regs, [llvm_i32_ty]));
+    let IntrProperties = [IntrNoMem, IntrNoCallback, ImmArg<ArgIndex<pos>>,
+                          Range<ArgIndex<pos>, 0, 4>];
+}
+
+foreach metadata = ["sp", "sp::ordered_metadata"] in {
+  foreach kind = ["", "kind::f8f6f4"] in {
+    foreach satf = [0, 1] in {
+      foreach op = NVVM_MMA_OPS.all_mma_sp_ops in {
+        if NVVM_MMA_SP_SUPPORTED<op, metadata, kind, satf>.ret then {
+          def MMA_SP_NAME<metadata, kind, satf,
+                          op[0], op[1], op[2], op[3]>.record
+            : NVVM_MMA_SP<op[0], op[1], op[2], op[3]>;
+        }
+      } // op
+    } // satf
+  } // kind
+} // metadata
+
 // LDMATRIX
 class NVVM_LDMATRIX<WMMA_REGS Frag, int Transposed>
   : Intrinsic<Frag.regs, [llvm_anyptr_ty],
diff --git a/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td b/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
index 0a00220d94289..a2b29a17537e9 100644
--- a/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ b/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -4637,10 +4637,15 @@ def INT_PTX_SREG_WARPSIZE :
 // In addition to target-independent fields provided by WMMA_REGS, it adds
 // the fields commonly used to implement specific PTX instruction -- register
 // types and names, constraints, parts of assembly, etc.
-class WMMA_REGINFO<WMMA_REGS r, string op>
-      : WMMA_REGS<r.geom, r.frag, r.ptx_elt_type> {
+class WMMA_REGINFO<WMMA_REGS r, string op, string metadata = "", string kind = "">
+      : WMMA_REGS<r.geom, r.frag, r.ptx_elt_type, !eq(op, "mma.sp")> {
   // NVPTX register types used to carry fragment data.
   NVPTXRegClass regclass = !cond(
+    !eq(ptx_elt_type, "e4m3") : B32,
+    !eq(ptx_elt_type, "e5m2") : B32,
+    !eq(ptx_elt_type, "e3m2") : B32,
+    !eq(ptx_elt_type, "e2m3") : B32,
+    !eq(ptx_elt_type, "e2m1") : B32,
     !eq(ptx_elt_type, "f16") : B32,
     !eq(ptx_elt_type, "f32") : B32,
     !eq(ptx_elt_type, "f64") : B64,
@@ -4673,6 +4678,18 @@ class WMMA_REGINFO<WMMA_REGS r, string op>
   // longer the case, we can concat all per-fragment predicates to enforce that
   // all fragments of the instruction are viable.
   list<Predicate> Predicates = !cond(
+    !or(!eq(ptx_elt_type, "e3m2"),
+        !eq(ptx_elt_type, "e2m3"),
+        !eq(ptx_elt_type, "e2m1"),
+        !ne(kind, "")) : [hasSM120a, hasPTX<87>],
+
+    !or(!eq(ptx_elt_type, "e4m3"),
+        !eq(ptx_elt_type, "e5m2")) : [hasSM<89>, hasPTX<84>],
+
+    !and(!eq(op, "mma.sp"),
+         !ne(metadata, "sp")) : [hasSM<80>, hasPTX<85>],
+    !eq(op, "mma.sp") : [hasSM<80>, hasPTX<71>],
+
     // fp16 -> fp16/fp32 @ m16n16k16
     !and(!eq(geom, "m16n16k16"),
          !or(!eq(ptx_elt_type, "f16"),
@@ -4777,7 +4794,8 @@ class BuildPatternI<Intrinsic Intr, dag Ins> {
   // Build a dag pattern that matches the intrinsic call.
   dag ret = !foreach(tmp, Ins,
                           !subst(ADDR, addr,
-                          !subst(ins, Intr, tmp)));
+                          !subst(ins, Intr,
+                          !subst(i32imm, timm, tmp))));
 }
 
 // Same as above, but uses PatFrag instead of an Intrinsic.
@@ -5011,6 +5029,62 @@ defset list<WMMA_INSTR> MMAs  = {
 } // defset
 }
 
+// MMA SP
+class MMA_SP<WMMA_REGINFO FragA, WMMA_REGINFO FragB,
+             WMMA_REGINFO FragC, WMMA_REGINFO FragD,
+             string Metadata, string Kind, int Satfinite>
+  : WMMA_INSTR<MMA_SP_NAME<Metadata, Kind, Satfinite,
+                           FragA, FragB, FragC, FragD>.record,
+               [FragA.Ins, FragB.Ins, FragC.Ins,
+                (ins B32:$metadata, i32imm:$selector)]>,
+    // Requires does not seem to have effect on Instruction w/o Patterns.
+    // We set it here anyways and propagate to the Pat<> we construct below.
+    Requires<!listconcat(FragA.Predicates,
+                         FragB.Predicates,
+                         FragC.Predicates,
+                         FragD.Predicates)> {
+  let OutOperandList = FragD.Outs;
+  let InOperandList = !con(Args, (ins MmaCode:$ptx));
+  string TypeList = "." # FragD.ptx_elt_type
+                    # "." # FragA.ptx_elt_type
+                    # "." # FragB.ptx_elt_type
+                    # "." # FragC.ptx_elt_type;
+  let AsmString = "mma"
+                  # "." # Metadata
+                  # ".sync.aligned."
+                  # FragA.geom
+                  # ".row.col"
+                  # !if(!ne(Kind, ""), "." # Kind, "")
+                  # !if(Satfinite, ".satfinite", "")
+                  # TypeList # "\n\t\t"
+                  # FragD.regstring # ",\n\t\t"
+                  # FragA.regstring # ",\n\t\t"
+                  # FragB.regstring # ",\n\t\t"
+                  # FragC.regstring # ",\n\t\t"
+                  # "$metadata" # ",\n\t\t"
+                  # "$selector" # ";";
+}
+
+let isConvergent = true in {
+defset list<WMMA_INSTR> MMA_SPs = {
+  foreach metadata = ["sp", "sp::ordered_metadata"] in {
+    foreach kind = ["", "kind::f8f6f4"] in {
+      foreach satf = [0, 1] in {
+        foreach op = NVVM_MMA_OPS.all_mma_sp_ops in {
+          if NVVM_MMA_SP_SUPPORTED<op, metadata, kind, satf>.ret then {
+            def : MMA_SP<WMMA_REGINFO<op[0], "mma.sp", metadata, kind>,
+                         WMMA_REGINFO<op[1], "mma.sp", metadata, kind>,
+                         WMMA_REGINFO<op[2], "mma.sp", metadata, kind>,
+                         WMMA_REGINFO<op[3], "mma.sp", metadata, kind>,
+                         metadata, kind, satf>;
+          }
+        } // op
+      } // satf
+    } // kind
+  } // metadata
+} // defset
+}
+
 //
 // ldmatrix.sync.aligned.m8n8[|.trans][|.shared].b16
 //
@@ -5092,7 +5166,7 @@ class MMA_PAT<WMMA_INSTR wi>
         Requires<wi.Predicates>;
 
 // Build intrinsic->instruction patterns for all MMA instructions.
-foreach mma = !listconcat(MMAs, WMMAs, MMA_LDSTs, LDMATRIXs, STMATRIXs) in
+foreach mma = !listconcat(MMAs, WMMAs, MMA_LDSTs, LDMATRIXs, STMATRIXs, MMA_SPs) in
   def : MMA_PAT<mma>;
 
 multiclass MAPA<string suffix, Intrinsic Intr> {
diff --git a/llvm/test/CodeGen/NVPTX/wmma-ptx87-sm120a.py b/llvm/test/CodeGen/NVPTX/wmma-ptx87-sm120a.py
new file mode 100644
index 0000000000000..ae781df0116fd
--- /dev/null
+++ b/llvm/test/CodeGen/NVPTX/wmma-ptx87-sm120a.py
@@ -0,0 +1,12 @@
+# Check all variants of instructions supported by PTX87 on SM120a
+# RUN: %python %s --ptx=87 --gpu-arch=120 --aa > %t-ptx87-sm_120a.ll
+# RUN: llc < %t-ptx87-sm_120a.ll -mtriple=nvptx64 -mcpu=sm_120a -mattr=+ptx87 \
+# RUN:           | FileCheck %t-ptx87-sm_120a.ll
+# RUN: %if ptxas-12.7 %{                                                  \
+# RUN: llc < %t-ptx87-sm_120a.ll -mtriple=nvptx64 -mcpu=sm_120a -mattr=+ptx87 \
+# RUN:           | %ptxas-verify -arch=sm_120a                              \
+# RUN: %}
+
+import wmma
+
+wmma.main()
diff --git a/llvm/test/CodeGen/NVPTX/wmma.py b/llvm/test/CodeGen/NVPTX/wmma.py
index 2eb3c3dbb4c39..283c94714282b 100644
--- a/llvm/test/CodeGen/NVPTX/wmma.py
+++ b/llvm/test/CodeGen/NVPTX/wmma.py
@@ -15,6 +15,11 @@ class MMAType:
     def __init__(self, ptx_type):
         self.ptx_type = ptx_type
         self.llvm_type = {
+            "e4m3" : "i32",
+            "e5m2" : "i32",
+            "e3m2" : "i32",
+            "e2m3" : "i32",
+            "e2m1" : "i32",
             "f16": "<2 x half>",
             "f32": "float",
             "f64": "double",
@@ -43,7 +48,7 @@ def __repr__(self):
 
 
 class MMAFrag:
-    def __init__(self, geom, frag, ptx_elt_type):
+    def __init__(self, geom, frag, ptx_elt_type, is_mma_sparse = False):
         self.geom = geom
         self.frag = frag
         self.mma_type = MMAType(ptx_elt_type)
@@ -79,12 +84,53 @@ def __init__(self, geom, frag, ptx_elt_type):
             "m16n8k16:b:s8": 1,
             "m16n8k16:c:s32": 4,
             "m16n8k16:d:s32": 4,
-            "m16n8k32:a:u8": 4,
-            "m16n8k32:a:s8": 4,
+            "m16n8k32:a:u8": 2 if is_mma_sparse else 4,
+            "m16n8k32:a:s8": 2 if is_mma_sparse else 4,
             "m16n8k32:b:u8": 2,
             "m16n8k32:b:s8": 2,
             "m16n8k32:c:s32": 4,
             "m16n8k32:d:s32": 4,
+            # mma sp
+            "m16n8k32:a:bf16"...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Jul 28, 2025

@llvm/pr-subscribers-backend-nvptx

Author: Kirill Vedernikov (kvederni)

Changes

This change adds intrinsics for MMA sparse. The implementation is based on PTX ISA version 8.8.


Patch is 31.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/150950.diff

4 Files Affected:

  • (modified) llvm/include/llvm/IR/IntrinsicsNVVM.td (+183-6)
  • (modified) llvm/lib/Target/NVPTX/NVPTXIntrinsics.td (+78-4)
  • (added) llvm/test/CodeGen/NVPTX/wmma-ptx87-sm120a.py (+12)
  • (modified) llvm/test/CodeGen/NVPTX/wmma.py (+252-15)
diff --git a/llvm/include/llvm/IR/IntrinsicsNVVM.td b/llvm/include/llvm/IR/IntrinsicsNVVM.td
index 967d1663f237b..c4f3e1b394c8e 100644
--- a/llvm/include/llvm/IR/IntrinsicsNVVM.td
+++ b/llvm/include/llvm/IR/IntrinsicsNVVM.td
@@ -170,7 +170,7 @@ class StrJoin<string sep, list<string> str_list> {
 // Geom: m<M>n<N>k<K>. E.g. m8n32k16
 // Frag: [a|b|c|d] ([x1|x2|x4] for ldmatrix)
 // PtxEltType: PTX type for the element.
-class WMMA_REGS<string Geom, string Frag, string PtxEltType> {
+class WMMA_REGS<string Geom, string Frag, string PtxEltType, bit IsSparse = false> {
   string geom = Geom;
   string frag = Frag;
   string ptx_elt_type = PtxEltType;
@@ -178,6 +178,54 @@ class WMMA_REGS<string Geom, string Frag, string PtxEltType> {
   string gf = Geom#":"#Frag;
   string ft = frag#":"#ptx_elt_type;
   list<LLVMType> regs = !cond(
+    // mma sparse ops use other fragments for some arguments
+    !and(!eq(gft, "m16n8k16:a:bf16"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k16:a:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 2),
+    !and(!eq(gft, "m16n8k32:a:bf16"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k32:a:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 4),
+    !and(!eq(gft, "m16n8k32:b:bf16"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k32:b:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 4),
+    !and(!eq(gft, "m16n8k32:c:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 2),
+    !and(!eq(gft, "m16n8k32:c:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k32:d:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 2),
+    !and(!eq(gft, "m16n8k32:d:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k16:a:tf32"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k16:b:tf32"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k16:c:tf32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k16:d:tf32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k8:a:tf32"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k32:a:u8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k32:a:s8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k64:a:u8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:s8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:e4m3"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:e5m2"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:e3m2"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:e2m3"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:e2m1"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:u8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:s8"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:e4m3"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:e5m2"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:e3m2"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:e2m3"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:b:e2m1"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k64:c:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 2),
+    !and(!eq(gft, "m16n8k64:c:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k64:d:f16"), !eq(IsSparse, true)) : !listsplat(llvm_v2f16_ty, 2),
+    !and(!eq(gft, "m16n8k64:d:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k64:a:u4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k64:a:s4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 2),
+    !and(!eq(gft, "m16n8k128:a:u4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:a:s4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:a:e2m1"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:b:u4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:b:s4"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:b:e2m1"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:c:s32"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:c:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
+    !and(!eq(gft, "m16n8k128:d:s32"), !eq(IsSparse, true)) : !listsplat(llvm_i32_ty, 4),
+    !and(!eq(gft, "m16n8k128:d:f32"), !eq(IsSparse, true)) : !listsplat(llvm_float_ty, 4),
     // mma fp ops use smaller fragments than wmma fp ops
     !eq(gft,"m8n8k4:a:f16") : !listsplat(llvm_v2f16_ty, 2),
     !eq(gft,"m8n8k4:b:f16") : !listsplat(llvm_v2f16_ty, 2),
@@ -362,6 +410,12 @@ class WMMA_NAME_LDST<string Op, WMMA_REGS Frag, string Layout, int WithStride> {
 
 class MMA_SIGNATURE<WMMA_REGS A, WMMA_REGS B, WMMA_REGS C, WMMA_REGS D> {
   list<WMMA_REGS> id_frags = !cond(
+     // FP8/F8F6F4 ops are identified by A,B inputs & accomulator & result type.
+     !or(!eq(A.ptx_elt_type, "e4m3"),
+         !eq(A.ptx_elt_type, "e5m2"),
+         !eq(A.ptx_elt_type, "e3m2"),
+         !eq(A.ptx_elt_type, "e2m3"),
+         !eq(A.ptx_elt_type, "e2m1")): [D, A, B, C],
      // FP16 ops are identified by accumulator & result type.
      !eq(A.ptx_elt_type, "f16") : [D, C],
      // other ops are identified by input types.
@@ -397,6 +451,19 @@ class MMA_NAME<string ALayout, string BLayout, int Satfinite, string b1op,
                   # signature;
 }
 
+class MMA_SP_NAME<string Metadata, string Kind, int Satfinite,
+                  WMMA_REGS A, WMMA_REGS B,
+                  WMMA_REGS C, WMMA_REGS D> {
+  string signature = MMA_SIGNATURE<A, B, C, D>.ret;
+  string record = "int_nvvm_mma"
+                  # "_" # !subst("::", "_", Metadata)
+                  # "_" # A.geom
+                  # "_row_col"
+                  # !if(!ne(Kind, ""), !strconcat("_", !subst("::", "_", Kind)), "")
+                  # !if(Satfinite, "_satfinite", "")
+                  # signature;
+}
+
 class LDMATRIX_NAME<WMMA_REGS Frag, int Trans> {
   string intr = "llvm.nvvm.ldmatrix.sync.aligned"
                 # "." # Frag.geom
@@ -424,21 +491,22 @@ class STMATRIX_NAME<WMMA_REGS Frag, int Trans> {
 //   TypeN: PTX type of the corresponding fragment's element.
 //   TypeB and TypeD may be empty if it must match that of TypeA or TypeC.
 class MMA_OPS<list<string> Geom, list<string> TypeA, list<string> TypeB,
-            list<string> TypeC, list<string> TypeD> {
+            list<string> TypeC, list<string> TypeD, bit IsSparse = false> {
   list<list<WMMA_REGS>> ret =
      !foldl([]<list<WMMA_REGS>>, Geom, t1, geom, !listconcat(t1,
      !foldl([]<list<WMMA_REGS>>, TypeA, t2, type_a, !listconcat(t2,
      !foldl([]<list<WMMA_REGS>>, !if(!size(TypeB), TypeB, [type_a]), t3, type_b, !listconcat(t3,
      !foldl([]<list<WMMA_REGS>>, TypeC, t4, type_c, !listconcat(t4,
      !foldl([]<list<WMMA_REGS>>, !if(!size(TypeD), TypeD, [type_c]), t5, type_d, !listconcat(t5,
-            [[WMMA_REGS<geom, "a", type_a>,
-              WMMA_REGS<geom, "b", type_b>,
-              WMMA_REGS<geom, "c", type_c>,
-              WMMA_REGS<geom, "d", type_d>]]))))))))));
+            [[WMMA_REGS<geom, "a", type_a, IsSparse>,
+              WMMA_REGS<geom, "b", type_b, IsSparse>,
+              WMMA_REGS<geom, "c", type_c, IsSparse>,
+              WMMA_REGS<geom, "d", type_d, IsSparse>]]))))))))));
    // Debugging aid for readable representation of the list above.
    list<list<string>> ops = !foreach(x, ret, [x[0].gft, x[1].gft, x[2].gft, x[3].gft]);
 }
 
+
 class MMA_LDST_OPS<list<string> Geom, list<string> Frags, list<string> Types> {
   list<WMMA_REGS> ret =
      !foldl([]<WMMA_REGS>, Geom, t1, geom, !listconcat(t1,
@@ -522,6 +590,30 @@ class NVVM_MMA_OPS {
             tf32_mma_ops, bf16_mma_ops, f64_mma_ops,
             fp_mma_ops, int_mma_ops, subint_mma_ops, bit_mma_ops);
 
+  list<list<WMMA_REGS>> bf16_mma_sp_ops = MMA_OPS<
+            ["m16n8k16", "m16n8k32"],
+            ["bf16"], [], ["f32"], [], true>.ret;
+  list<list<WMMA_REGS>> tf32_mma_sp_ops = MMA_OPS<
+            ["m16n8k8", "m16n8k16"],
+            ["tf32"], [], ["f32"], [], true>.ret;
+  list<list<WMMA_REGS>> fp_mma_sp_ops = MMA_OPS<
+            ["m16n8k16", "m16n8k32"],
+            ["f16"], [], ["f16", "f32"], ["f16", "f32"], true>.ret;
+  list<list<WMMA_REGS>> fp8_mma_sp_ops = MMA_OPS<
+            ["m16n8k64"],
+            ["e4m3", "e5m2", "e3m2", "e2m3", "e2m1"],
+            ["e4m3", "e5m2", "e3m2", "e2m3", "e2m1"],
+            ["f16", "f32"], ["f16", "f32"], true>.ret;
+  list<list<WMMA_REGS>> subint_mma_sp_ops = MMA_OPS<
+            ["m16n8k64", "m16n8k128"],
+            ["s4", "u4"], ["s4", "u4"], ["s32"], [], true>.ret;
+  list<list<WMMA_REGS>> int_mma_sp_ops = MMA_OPS<
+            ["m16n8k32", "m16n8k64"],
+            ["s8", "u8"], ["s8", "u8"], ["s32"], [], true>.ret;
+  list<list<WMMA_REGS>> all_mma_sp_ops = !listconcat(
+            bf16_mma_sp_ops, tf32_mma_sp_ops, fp_mma_sp_ops, fp8_mma_sp_ops,
+            subint_mma_sp_ops, int_mma_sp_ops);
+
   list<WMMA_REGS> ldst_ab_ops = MMA_LDST_OPS<
             ["m16n16k16", "m32n8k16", "m8n32k16"],
             ["a", "b"], ["f16", "u8", "s8", "bf16"]>.ret;
@@ -728,6 +820,68 @@ class NVVM_STMATRIX_SUPPORTED<WMMA_REGS frag, bit trans> {
   );
 }
 
+
+// Returns true if this combination of layout/kind/satf for MMA.SP ops is supported;
+// false otherwise.
+// E.g.
+// if NVVM_MMA_SP_SUPPORTED<...>.ret then
+//   def : FOO<>; // The record will only be defined for supported ops.
+//
+class NVVM_MMA_SP_SUPPORTED<list<WMMA_REGS> frags, string metadata,
+                            string kind, int satf> {
+  // MMA.SP ops check both layouts.
+  string a_type = frags[0].ptx_elt_type;
+  string b_type = frags[1].ptx_elt_type;
+  string c_type = frags[2].ptx_elt_type;
+  string d_type = frags[3].ptx_elt_type;
+  string geom = frags[0].geom;
+
+  bit is_int = !or(!eq(a_type, "s8"),
+                   !eq(a_type, "u8"),
+                   !eq(a_type, "s4"),
+                   !eq(a_type, "u4"));
+
+  bit ret = !cond(
+
+    // Limit satf to valid types
+    !and(!eq(satf, 1),
+         !eq(is_int, 0)): false,
+
+    // f16/bf16/tf32 requires A and B to be the same type.
+    !and(!or(!eq(a_type, "f16"),
+             !eq(a_type, "bf16"),
+             !eq(a_type, "tf32")),
+         !ne(a_type, b_type)): false,
+
+    // m16n8k16 and m16n8k32 requires C and D to be the same type.
+    !and(!or(!eq(geom, "m16n8k16"),
+             !eq(geom, "m16n8k32")),
+         !ne(c_type, d_type)): false,
+
+    !and(!eq(kind, ""),
+         !or(!eq(a_type, "e3m2"),
+             !eq(a_type, "e2m3"),
+             !eq(a_type, "e2m1"),
+             !eq(b_type, "e3m2"),
+             !eq(b_type, "e2m3"),
+             !eq(b_type, "e2m1"))): false,
+
+    !and(!eq(kind, ""),
+         !eq(geom, "m16n8k64"),
+         !or(!eq(c_type, "f16"),
+             !eq(d_type, "f16"))): false,
+
+    !and(!ne(kind, ""),
+         !or(!eq(metadata, "sp"),
+             !ne(geom, "m16n8k64"),
+             !eq(is_int, 1))): false,
+
+    // All other are OK.
+    true: true
+  );
+}
+
+
 class SHFL_INFO<bit sync, string mode, string type, bit return_pred> {
   string Suffix = !if(sync, "sync_", "")
                   # mode # "_"
@@ -2001,6 +2155,29 @@ foreach layout_a = ["row", "col"] in {
   } // layout_b
 } // layout_a
 
+// MMA.SP
+class NVVM_MMA_SP<WMMA_REGS A, WMMA_REGS B, WMMA_REGS C, WMMA_REGS D>
+  : Intrinsic<D.regs,
+              !listconcat(A.regs, B.regs, C.regs, [llvm_i32_ty], [llvm_i32_ty])> {
+    int pos = !size(!listconcat(A.regs, B.regs, C.regs, [llvm_i32_ty]));
+    let IntrProperties = [IntrNoMem, IntrNoCallback, ImmArg<ArgIndex<pos>>,
+                          Range<ArgIndex<pos>, 0, 4>];
+}
+
+foreach metadata = ["sp", "sp::ordered_metadata"] in {
+  foreach kind = ["", "kind::f8f6f4"] in {
+    foreach satf = [0, 1] in {
+      foreach op = NVVM_MMA_OPS.all_mma_sp_ops in {
+        if NVVM_MMA_SP_SUPPORTED<op, metadata, kind, satf>.ret then {
+          def MMA_SP_NAME<metadata, kind, satf,
+                          op[0], op[1], op[2], op[3]>.record
+            : NVVM_MMA_SP<op[0], op[1], op[2], op[3]>;
+        }
+      } // op
+    } // satf
+  } // kind
+} // metadata
+
 // LDMATRIX
 class NVVM_LDMATRIX<WMMA_REGS Frag, int Transposed>
   : Intrinsic<Frag.regs, [llvm_anyptr_ty],
diff --git a/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td b/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
index 0a00220d94289..a2b29a17537e9 100644
--- a/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ b/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -4637,10 +4637,15 @@ def INT_PTX_SREG_WARPSIZE :
 // In addition to target-independent fields provided by WMMA_REGS, it adds
 // the fields commonly used to implement specific PTX instruction -- register
 // types and names, constraints, parts of assembly, etc.
-class WMMA_REGINFO<WMMA_REGS r, string op>
-      : WMMA_REGS<r.geom, r.frag, r.ptx_elt_type> {
+class WMMA_REGINFO<WMMA_REGS r, string op, string metadata = "", string kind = "">
+      : WMMA_REGS<r.geom, r.frag, r.ptx_elt_type, !eq(op, "mma.sp")> {
   // NVPTX register types used to carry fragment data.
   NVPTXRegClass regclass = !cond(
+    !eq(ptx_elt_type, "e4m3") : B32,
+    !eq(ptx_elt_type, "e5m2") : B32,
+    !eq(ptx_elt_type, "e3m2") : B32,
+    !eq(ptx_elt_type, "e2m3") : B32,
+    !eq(ptx_elt_type, "e2m1") : B32,
     !eq(ptx_elt_type, "f16") : B32,
     !eq(ptx_elt_type, "f32") : B32,
     !eq(ptx_elt_type, "f64") : B64,
@@ -4673,6 +4678,18 @@ class WMMA_REGINFO<WMMA_REGS r, string op>
   // longer the case, we can concat all per-fragment predicates to enforce that
   // all fragments of the instruction are viable.
   list<Predicate> Predicates = !cond(
+    !or(!eq(ptx_elt_type, "e3m2"),
+        !eq(ptx_elt_type, "e2m3"),
+        !eq(ptx_elt_type, "e2m1"),
+        !ne(kind, "")) : [hasSM120a, hasPTX<87>],
+
+    !or(!eq(ptx_elt_type, "e4m3"),
+        !eq(ptx_elt_type, "e5m2")) : [hasSM<89>, hasPTX<84>],
+
+    !and(!eq(op, "mma.sp"),
+         !ne(metadata, "sp")) : [hasSM<80>, hasPTX<85>],
+    !eq(op, "mma.sp") : [hasSM<80>, hasPTX<71>],
+
     // fp16 -> fp16/fp32 @ m16n16k16
     !and(!eq(geom, "m16n16k16"),
          !or(!eq(ptx_elt_type, "f16"),
@@ -4777,7 +4794,8 @@ class BuildPatternI<Intrinsic Intr, dag Ins> {
   // Build a dag pattern that matches the intrinsic call.
   dag ret = !foreach(tmp, Ins,
                           !subst(ADDR, addr,
-                          !subst(ins, Intr, tmp)));
+                          !subst(ins, Intr,
+                          !subst(i32imm, timm, tmp))));
 }
 
 // Same as above, but uses PatFrag instead of an Intrinsic.
@@ -5011,6 +5029,62 @@ defset list<WMMA_INSTR> MMAs  = {
 } // defset
 }
 
+// MMA SP
+class MMA_SP<WMMA_REGINFO FragA, WMMA_REGINFO FragB,
+             WMMA_REGINFO FragC, WMMA_REGINFO FragD,
+             string Metadata, string Kind, int Satfinite>
+  : WMMA_INSTR<MMA_SP_NAME<Metadata, Kind, Satfinite,
+                           FragA, FragB, FragC, FragD>.record,
+               [FragA.Ins, FragB.Ins, FragC.Ins,
+                (ins B32:$metadata, i32imm:$selector)]>,
+    // Requires does not seem to have effect on Instruction w/o Patterns.
+    // We set it here anyways and propagate to the Pat<> we construct below.
+    Requires<!listconcat(FragA.Predicates,
+                         FragB.Predicates,
+                         FragC.Predicates,
+                         FragD.Predicates)> {
+  let OutOperandList = FragD.Outs;
+  let InOperandList = !con(Args, (ins MmaCode:$ptx));
+  string TypeList = "." # FragD.ptx_elt_type
+                    # "." # FragA.ptx_elt_type
+                    # "." # FragB.ptx_elt_type
+                    # "." # FragC.ptx_elt_type;
+  let AsmString = "mma"
+                  # "." # Metadata
+                  # ".sync.aligned."
+                  # FragA.geom
+                  # ".row.col"
+                  # !if(!ne(Kind, ""), "." # Kind, "")
+                  # !if(Satfinite, ".satfinite", "")
+                  # TypeList # "\n\t\t"
+                  # FragD.regstring # ",\n\t\t"
+                  # FragA.regstring # ",\n\t\t"
+                  # FragB.regstring # ",\n\t\t"
+                  # FragC.regstring # ",\n\t\t"
+                  # "$metadata" # ",\n\t\t"
+                  # "$selector" # ";";
+}
+
+let isConvergent = true in {
+defset list<WMMA_INSTR> MMA_SPs = {
+  foreach metadata = ["sp", "sp::ordered_metadata"] in {
+    foreach kind = ["", "kind::f8f6f4"] in {
+      foreach satf = [0, 1] in {
+        foreach op = NVVM_MMA_OPS.all_mma_sp_ops in {
+          if NVVM_MMA_SP_SUPPORTED<op, metadata, kind, satf>.ret then {
+            def : MMA_SP<WMMA_REGINFO<op[0], "mma.sp", metadata, kind>,
+                         WMMA_REGINFO<op[1], "mma.sp", metadata, kind>,
+                         WMMA_REGINFO<op[2], "mma.sp", metadata, kind>,
+                         WMMA_REGINFO<op[3], "mma.sp", metadata, kind>,
+                         metadata, kind, satf>;
+          }
+        } // op
+      } // satf
+    } // kind
+  } // metadata
+} // defset
+}
+
 //
 // ldmatrix.sync.aligned.m8n8[|.trans][|.shared].b16
 //
@@ -5092,7 +5166,7 @@ class MMA_PAT<WMMA_INSTR wi>
         Requires<wi.Predicates>;
 
 // Build intrinsic->instruction patterns for all MMA instructions.
-foreach mma = !listconcat(MMAs, WMMAs, MMA_LDSTs, LDMATRIXs, STMATRIXs) in
+foreach mma = !listconcat(MMAs, WMMAs, MMA_LDSTs, LDMATRIXs, STMATRIXs, MMA_SPs) in
   def : MMA_PAT<mma>;
 
 multiclass MAPA<string suffix, Intrinsic Intr> {
diff --git a/llvm/test/CodeGen/NVPTX/wmma-ptx87-sm120a.py b/llvm/test/CodeGen/NVPTX/wmma-ptx87-sm120a.py
new file mode 100644
index 0000000000000..ae781df0116fd
--- /dev/null
+++ b/llvm/test/CodeGen/NVPTX/wmma-ptx87-sm120a.py
@@ -0,0 +1,12 @@
+# Check all variants of instructions supported by PTX87 on SM120a
+# RUN: %python %s --ptx=87 --gpu-arch=120 --aa > %t-ptx87-sm_120a.ll
+# RUN: llc < %t-ptx87-sm_120a.ll -mtriple=nvptx64 -mcpu=sm_120a -mattr=+ptx87 \
+# RUN:           | FileCheck %t-ptx87-sm_120a.ll
+# RUN: %if ptxas-12.7 %{                                                  \
+# RUN: llc < %t-ptx87-sm_120a.ll -mtriple=nvptx64 -mcpu=sm_120a -mattr=+ptx87 \
+# RUN:           | %ptxas-verify -arch=sm_120a                              \
+# RUN: %}
+
+import wmma
+
+wmma.main()
diff --git a/llvm/test/CodeGen/NVPTX/wmma.py b/llvm/test/CodeGen/NVPTX/wmma.py
index 2eb3c3dbb4c39..283c94714282b 100644
--- a/llvm/test/CodeGen/NVPTX/wmma.py
+++ b/llvm/test/CodeGen/NVPTX/wmma.py
@@ -15,6 +15,11 @@ class MMAType:
     def __init__(self, ptx_type):
         self.ptx_type = ptx_type
         self.llvm_type = {
+            "e4m3" : "i32",
+            "e5m2" : "i32",
+            "e3m2" : "i32",
+            "e2m3" : "i32",
+            "e2m1" : "i32",
             "f16": "<2 x half>",
             "f32": "float",
             "f64": "double",
@@ -43,7 +48,7 @@ def __repr__(self):
 
 
 class MMAFrag:
-    def __init__(self, geom, frag, ptx_elt_type):
+    def __init__(self, geom, frag, ptx_elt_type, is_mma_sparse = False):
         self.geom = geom
         self.frag = frag
         self.mma_type = MMAType(ptx_elt_type)
@@ -79,12 +84,53 @@ def __init__(self, geom, frag, ptx_elt_type):
             "m16n8k16:b:s8": 1,
             "m16n8k16:c:s32": 4,
             "m16n8k16:d:s32": 4,
-            "m16n8k32:a:u8": 4,
-            "m16n8k32:a:s8": 4,
+            "m16n8k32:a:u8": 2 if is_mma_sparse else 4,
+            "m16n8k32:a:s8": 2 if is_mma_sparse else 4,
             "m16n8k32:b:u8": 2,
             "m16n8k32:b:s8": 2,
             "m16n8k32:c:s32": 4,
             "m16n8k32:d:s32": 4,
+            # mma sp
+            "m16n8k32:a:bf16"...
[truncated]

This change adds intrinsics for MMA sparse. The implementation is based
on PTX ISA version 8.8.
@github-actions
Copy link

github-actions bot commented Jul 29, 2025

✅ With the latest revision this PR passed the Python code formatter.

@durga4github
Copy link
Contributor

@Artem-B , Please help with a review.

@kvederni
Copy link
Contributor Author

@Artem-B, could you please help with the review?

Copy link
Member

@Artem-B Artem-B left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the existing code/tests that handles all MMA instruction variants growing rather unwieldy, the PR looks OK. Refactoring/improving can be done separately.

Comment on lines +181 to +190
!cond(
// mma sparse ops use other fragments for some arguments
!eq(gft,"m16n8k16:a:bf16") : !listsplat(llvm_i32_ty, 2),
!eq(gft,"m16n8k16:a:f16") : !listsplat(llvm_v2f16_ty, 2),
!eq(gft,"m16n8k16:b:bf16") : !listsplat(llvm_i32_ty, 2),
!eq(gft,"m16n8k16:b:f16") : !listsplat(llvm_v2f16_ty, 2),
!eq(gft,"m16n8k16:c:f16") : !listsplat(llvm_v2f16_ty, 2),
!eq(gft,"m16n8k16:c:f32") : !listsplat(llvm_float_ty, 4),
!eq(gft,"m16n8k16:d:f16") : !listsplat(llvm_v2f16_ty, 2),
!eq(gft,"m16n8k16:d:f32") : !listsplat(llvm_float_ty, 4),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes me wonder if we may come up with a more concise way of handling this.

E.g. define a record for each known geometry (and sparsiness effectively becomes part of the geometry), and then attempt to cast to the record that would be expected to exist for the given geometry, and extract the register list (and possibly other per-geometry parameters from there). This way we'll avoid repetitive eq and listsplat.

// if NVVM_MMA_SP_SUPPORTED<...>.ret then
// def : FOO<>; // The record will only be defined for supported ops.
//
class NVVM_MMA_SP_SUPPORTED<list<WMMA_REGS> frags, string metadata,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That may be another bit of info that could be set in a per-geom record.

make_mma_ops(["m16n8k16", "m16n8k32"], ["bf16"], [], ["f32"], [], True)
+ make_mma_ops(["m16n8k8", "m16n8k16"], ["tf32"], [], ["f32"], [], True)
+ make_mma_ops(
["m16n8k16", "m16n8k32"], ["f16"], [], ["f16", "f32"], ["f16", "f32"], True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: wrap long line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@schwarzschild-radius schwarzschild-radius merged commit ee7826b into llvm:main Aug 22, 2025
9 checks passed
@github-actions
Copy link

@kvederni Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@schwarzschild-radius
Copy link
Contributor

Merged the change on behalf of @kvederni

Other than the existing code/tests that handles all MMA instruction variants growing rather unwieldy, the PR looks OK. Refactoring/improving can be done separately.

Will let him address the comment on refactoring in a follow-up change

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 22, 2025

LLVM Buildbot has detected a new failure on builder arc-builder running on arc-worker while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/3/builds/20965

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/X86/sse2-intrinsics-fast-isel.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/buildbot/worker/arc-folder/build/bin/llc < /buildbot/worker/arc-folder/llvm-project/llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll -show-mc-encoding -fast-isel -mtriple=i386-unknown-unknown -mattr=+sse2 | /buildbot/worker/arc-folder/build/bin/FileCheck /buildbot/worker/arc-folder/llvm-project/llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll --check-prefixes=CHECK,X86,SSE,X86-SSE # RUN: at line 2
+ /buildbot/worker/arc-folder/build/bin/FileCheck /buildbot/worker/arc-folder/llvm-project/llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll --check-prefixes=CHECK,X86,SSE,X86-SSE
+ /buildbot/worker/arc-folder/build/bin/llc -show-mc-encoding -fast-isel -mtriple=i386-unknown-unknown -mattr=+sse2
LLVM ERROR: Cannot select: intrinsic %llvm.x86.sse2.clflush
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /buildbot/worker/arc-folder/build/bin/llc -show-mc-encoding -fast-isel -mtriple=i386-unknown-unknown -mattr=+sse2
1.	Running pass 'Function Pass Manager' on module '<stdin>'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@test_mm_clflush'
 #0 0x0000000002336558 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/buildbot/worker/arc-folder/build/bin/llc+0x2336558)
 #1 0x0000000002333465 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007f0ece795630 __restore_rt sigaction.c:0:0
 #3 0x00007f0ecd4e53d7 raise (/usr/lib64/libc.so.6+0x363d7)
 #4 0x00007f0ecd4e6ac8 abort (/usr/lib64/libc.so.6+0x37ac8)
 #5 0x000000000072114d llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0
 #6 0x00000000020c1719 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/buildbot/worker/arc-folder/build/bin/llc+0x20c1719)
 #7 0x00000000020c624a llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/buildbot/worker/arc-folder/build/bin/llc+0x20c624a)
 #8 0x0000000000965d47 (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
 #9 0x00000000020bcf7f llvm::SelectionDAGISel::DoInstructionSelection() (/buildbot/worker/arc-folder/build/bin/llc+0x20bcf7f)
#10 0x00000000020cccd0 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/buildbot/worker/arc-folder/build/bin/llc+0x20cccd0)
#11 0x00000000020d097a llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/buildbot/worker/arc-folder/build/bin/llc+0x20d097a)
#12 0x00000000020d15d5 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/buildbot/worker/arc-folder/build/bin/llc+0x20d15d5)
#13 0x00000000020bc78f llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/buildbot/worker/arc-folder/build/bin/llc+0x20bc78f)
#14 0x0000000001211f47 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000000001867c12 llvm::FPPassManager::runOnFunction(llvm::Function&) (/buildbot/worker/arc-folder/build/bin/llc+0x1867c12)
#16 0x0000000001867fb1 llvm::FPPassManager::runOnModule(llvm::Module&) (/buildbot/worker/arc-folder/build/bin/llc+0x1867fb1)
#17 0x0000000001868bc7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/buildbot/worker/arc-folder/build/bin/llc+0x1868bc7)
#18 0x0000000000803232 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x00000000007295b6 main (/buildbot/worker/arc-folder/build/bin/llc+0x7295b6)
#20 0x00007f0ecd4d1555 __libc_start_main (/usr/lib64/libc.so.6+0x22555)
#21 0x00000000007f9456 _start (/buildbot/worker/arc-folder/build/bin/llc+0x7f9456)
/buildbot/worker/arc-folder/llvm-project/llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll:399:14: error: SSE-LABEL: expected string not found in input
; SSE-LABEL: test_mm_bsrli_si128:
             ^
<stdin>:170:21: note: scanning from here
test_mm_bslli_si128: # @test_mm_bslli_si128
                    ^
<stdin>:178:9: note: possible intended match here
 .globl test_mm_bsrli_si128 # 
        ^

Input file: <stdin>
Check file: /buildbot/worker/arc-folder/llvm-project/llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll

-dump-input=help explains the following input dump.
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 22, 2025

LLVM Buildbot has detected a new failure on builder llvm-nvptx-nvidia-win running on as-builder-8 while building llvm at step 7 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/54/builds/12041

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/NVPTX/wmma-ptx71-sm80.py' FAILED ********************
Exit Code: 4294967295

Command Output (stdout):
--
# RUN: at line 2
"C:\Python310\python.exe" C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\llvm-project\llvm\test\CodeGen\NVPTX\wmma-ptx71-sm80.py --ptx=71 --gpu-arch=80 > C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll
# executed command: 'C:\Python310\python.exe' 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\llvm-project\llvm\test\CodeGen\NVPTX\wmma-ptx71-sm80.py' --ptx=71 --gpu-arch=80
# RUN: at line 3
c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\filecheck.exe C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll < C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll            --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,ALTFLOAT,DOUBLE,PTX65MMA,PTX65LDMATRIX,PTX71MMA
# executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\filecheck.exe' 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll' --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,ALTFLOAT,DOUBLE,PTX65MMA,PTX65LDMATRIX,PTX71MMA
# RUN: at line 5
c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\filecheck.exe C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll < C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll            --check-prefixes=INTRINSICS
# executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\filecheck.exe' 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll' --check-prefixes=INTRINSICS
# RUN: at line 7
c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llc.exe < C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71            | c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\filecheck.exe C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll
# executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llc.exe' -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71
# executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\filecheck.exe' 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll'
# RUN: at line 9
c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llc.exe < C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\NVPTX\Output\wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71            | c:/buildbot/latest-cuda/bin/ptxas.exe -arch=sm_60 -c - -arch=sm_80
# executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llc.exe' -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71
# executed command: c:/buildbot/latest-cuda/bin/ptxas.exe -arch=sm_60 -c - -arch=sm_80
# .---command stdout------------
# | ptxas warning : incompatible redefinition for option 'gpu-name', the last value of this option was used
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38569; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38609; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38649; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38689; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38737; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38785; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38825; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38865; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38905; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38945; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 38993; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39041; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39077; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39111; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39145; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39179; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39217; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39257; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39297; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39337; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39381; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39423; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39465; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39465; error   : Argument 6 of instruction 'Sparse mma': value '2' out of range, expected to be in range [0..1]
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39507; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\lit-tmp-wqd1bo0y/tmpxft_000074e4_00000000-0_stdin, line 39507; error   : Argument 6 of instruction 'Sparse mma': value '3' out of range, expected to be in range [0..1]
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 22, 2025

LLVM Buildbot has detected a new failure on builder llvm-nvptx64-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/23469

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/NVPTX/wmma-ptx71-sm80.py' FAILED ********************
Exit Code: 255

Command Output (stderr):
--
"/usr/bin/python3" /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/NVPTX/wmma-ptx71-sm80.py --ptx=71 --gpu-arch=80 > /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll # RUN: at line 2
+ /usr/bin/python3 /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/NVPTX/wmma-ptx71-sm80.py --ptx=71 --gpu-arch=80
/home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/NVPTX/wmma.py:1270: SyntaxWarning: invalid escape sequence '\.'
  """
/home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll < /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll            --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,ALTFLOAT,DOUBLE,PTX65MMA,PTX65LDMATRIX,PTX71MMA # RUN: at line 3
+ /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,ALTFLOAT,DOUBLE,PTX65MMA,PTX65LDMATRIX,PTX71MMA
/home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll < /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll            --check-prefixes=INTRINSICS # RUN: at line 5
+ /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll --check-prefixes=INTRINSICS
/home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/llc < /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71            | /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll # RUN: at line 7
+ /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/llc -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71
+ /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll
/home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/llc < /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71            | /usr/local/cuda/bin/ptxas -arch=sm_60 -c - -arch=sm_80 # RUN: at line 9
+ /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/llc -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71
+ /usr/local/cuda/bin/ptxas -arch=sm_60 -c - -arch=sm_80
ptxas warning : incompatible redefinition for option 'gpu-name', the last value of this option was used
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38569; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38609; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38649; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38689; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38737; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38785; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38825; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38865; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38905; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38945; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 38993; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39041; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39077; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39111; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39145; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39179; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39217; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39257; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39297; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39337; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39381; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39423; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39465; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39465; error   : Argument 6 of instruction 'Sparse mma': value '2' out of range, expected to be in range [0..1]
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39507; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39507; error   : Argument 6 of instruction 'Sparse mma': value '3' out of range, expected to be in range [0..1]
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39553; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39601; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39649; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/lit-tmp-g8hraboa/tmpxft_0032dae9_00000000-0_stdin, line 39697; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 22, 2025

LLVM Buildbot has detected a new failure on builder llvm-nvptx-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/180/builds/23613

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/NVPTX/wmma-ptx71-sm80.py' FAILED ********************
Exit Code: 255

Command Output (stderr):
--
"/usr/bin/python3" /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/NVPTX/wmma-ptx71-sm80.py --ptx=71 --gpu-arch=80 > /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll # RUN: at line 2
+ /usr/bin/python3 /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/NVPTX/wmma-ptx71-sm80.py --ptx=71 --gpu-arch=80
/home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/NVPTX/wmma.py:1270: SyntaxWarning: invalid escape sequence '\.'
  """
/home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll < /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll            --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,ALTFLOAT,DOUBLE,PTX65MMA,PTX65LDMATRIX,PTX71MMA # RUN: at line 3
+ /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,ALTFLOAT,DOUBLE,PTX65MMA,PTX65LDMATRIX,PTX71MMA
/home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll < /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll            --check-prefixes=INTRINSICS # RUN: at line 5
+ /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll --check-prefixes=INTRINSICS
/home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/llc < /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71            | /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll # RUN: at line 7
+ /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/llc -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71
+ /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll
/home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/llc < /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/CodeGen/NVPTX/Output/wmma-ptx71-sm80.py.tmp-ptx71-sm_80.ll -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71            | /usr/local/cuda/bin/ptxas -arch=sm_60 -c - -arch=sm_80 # RUN: at line 9
+ /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/llc -mtriple=nvptx64 -mcpu=sm_80 -mattr=+ptx71
+ /usr/local/cuda/bin/ptxas -arch=sm_60 -c - -arch=sm_80
ptxas warning : incompatible redefinition for option 'gpu-name', the last value of this option was used
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38569; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38609; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38649; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38689; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38737; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38785; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38825; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38865; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38905; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38945; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 38993; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39041; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39077; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39111; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39145; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39179; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39217; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39257; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39297; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39337; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39381; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39423; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39465; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39465; error   : Argument 6 of instruction 'Sparse mma': value '2' out of range, expected to be in range [0..1]
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39507; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39507; error   : Argument 6 of instruction 'Sparse mma': value '3' out of range, expected to be in range [0..1]
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39553; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39601; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39649; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
ptxas /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/lit-tmp-5fga53z3/tmpxft_0035d126_00000000-0_stdin, line 39697; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
...

@schwarzschild-radius
Copy link
Contributor

The build seems to be failing in the ptxas verify step with the following error:

# | ptxas c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\lit-tmp-u8i0xye3/tmpxft_0000352c_00000000-0_stdin, line 41681; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\lit-tmp-u8i0xye3/tmpxft_0000352c_00000000-0_stdin, line 41681; error   : Argument 6 of instruction 'Sparse mma': value '3' out of range, expected to be in range [0..0]
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\lit-tmp-u8i0xye3/tmpxft_0000352c_00000000-0_stdin, line 41729; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\lit-tmp-u8i0xye3/tmpxft_0000352c_00000000-0_stdin, line 41777; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\lit-tmp-u8i0xye3/tmpxft_0000352c_00000000-0_stdin, line 41777; error   : Argument 6 of instruction 'Sparse mma': value '1' out of range, expected to be in range [0..0]
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\lit-tmp-u8i0xye3/tmpxft_0000352c_00000000-0_stdin, line 41825; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\lit-tmp-u8i0xye3/tmpxft_0000352c_00000000-0_stdin, line 41825; error   : Argument 6 of instruction 'Sparse mma': value '2' out of range, expected to be in range [0..0]
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\lit-tmp-u8i0xye3/tmpxft_0000352c_00000000-0_stdin, line 41873; info    : Advisory: Modifier '.sp::ordered_metadata' should be used on instruction 'mma' instead of modifier '.sp' as it is expected to have substantially reduced performance on some future architectures
# | ptxas c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\lit-tmp-u8i0xye3/tmpxft_0000352c_00000000-0_stdin, line 41873; error   : Argument 6 of instruction 'Sparse mma': value '3' out of range, expected to be in range [0..0]

@kvederni has raised another PR (#154984) to fix it

schwarzschild-radius pushed a commit that referenced this pull request Aug 22, 2025
This PR fixes NVPTX tests in LLVM testing by adding more limitations for a sparsity selector in sparse MMA intrinsics. The previous PR that is merged to llvm:main is [PR150950](#150950). The merge
to llvm:main is d9c6b7b
@schwarzschild-radius
Copy link
Contributor

commit 533cc9a should fix the build failures occurred in the post merge build checks

llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Aug 22, 2025
…. (#154984)

This PR fixes NVPTX tests in LLVM testing by adding more limitations for a sparsity selector in sparse MMA intrinsics. The previous PR that is merged to llvm:main is [PR150950](llvm/llvm-project#150950). The merge
to llvm:main is d9c6b7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants