Roadmap / LLVM IR constructs

The mul instruction

Area
LLVM IR constructs
Kind
construct
Level
L3, the top level.
Evidence present above the level
None above the level.
Evidence
Reference
LLVM LangRef 24.0.0git #mul-instruction
Quote
The ‘mul’ instruction returns the product of its two operands.
Lean declarations
  • MojoProof.LLVM.Parser.inst
  • MojoProof.LLVM.Inst
  • MojoProof.Sem.exec
  • MojoProof.Sem.intBin
  • MojoProof.Sym.exec_bin
Corpus files

5 kernel files (.ll) in the corpus.

Tests
  • MojoProofTest.Rule
  • MojoProofTest.Corpus
  • MojoProofTest.Modelled
Upstream issue
None filed.
Depends on
No other card.

Rule

LangRef's section on mul (the quote is the first sentence of its overview). The importer reads mul as Inst.bin with BinOp.mul (Parser.inst); the semantics gives it a meaning in MojoProof.Sem.exec, with MojoProof.Sem.intBin. MojoProofTest/Modelled.lean runs a kernel of it (its row mul), and the run returns. The block checker (MojoProof/Sym/Rules.lean): Sym.exec_bin.

Corpus

112 of the 116 corpus files use it (5957 uses); corpus lists the first 5 in path order.

The programs of the library's mojo_kernel theorems use it (tests/corpus/vadd/vadd_vector_addition_vector_addition6A6A_793e5fe36a195e73.nvptx.ll, tests/corpus/vmul/vector_multiply_vector_multiply_vector_multiply6A6A_227fc544da3deaff.nvptx.ll, tests/corpus/vsub/vector_subtraction_vector_subtraction_vector_subtr6A6A_a0b4d9d2b6e652e1.nvptx.ll).

GPU runs

A conformance test, not a proof. The records of GPU runs of corpus kernels whose IR uses it: tests/gpu/naive/record.txt, tests/gpu/vadd/record.txt, tests/gpu/vmul/record.txt, tests/gpu/vsub/record.txt. In each, the grid evaluator ran the imported corpus program on the inputs of the GPU run, and its output buffer agreed with the GPU's, bit for bit over the whole buffer, on every launch the record lists. That covers the forms of the construct those kernels use, on those inputs and launches, and nothing else.

Proved kernels

Used by a proved kernel, not proved on its own. The kernel cards with L2 evidence whose Kernel.Sound theorems are about a program whose IR uses it, with those theorems: naive-matmul (MojoProofTest.NaiveKernel.correct, MojoProofTest.NaiveOff.correct); vadd (MojoProof.Kernels.vadd.correct); vmul (MojoProof.Kernels.vmul.correct); vsub (MojoProof.Kernels.vsub.correct). A theorem's program is the corpus file mojo_import or mojo_corpus binds it to; the other files a kernel card cites do not count. Each such theorem covers the forms of the construct in the IR of the program it is about, at the launches and on the memories its premises admit.

Out of scope

Forms of the instruction the corpus does not use are read by the same parser case, but no corpus file exercises them. That the semantics gives mul the meaning LLVM gives it rests on reading LangRef (docs/TRUST.md T7), and on the GPU runs above for their inputs, not on a check against LLVM.

Open

L3 is the top of the construct ladder. It says the construct is used by a proved kernel, not that it has a theorem of its own: the forms of it that no proved kernel's IR uses are covered by no theorem.