[arch] internal/simdgen: add dot products

2 views
Skip to first unread message

Junyang Shao (Gerrit)

unread,
Jun 3, 2025, 8:54:27 PM (7 days ago) Jun 3
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Junyang Shao has uploaded the change for review

Commit message

internal/simdgen: add dot products
Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9

Change diff

diff --git a/internal/simdgen/categories.yaml b/internal/simdgen/categories.yaml
index ad5325f..6afbd9d 100644
--- a/internal/simdgen/categories.yaml
+++ b/internal/simdgen/categories.yaml
@@ -261,6 +261,20 @@
commutative: "false"
masked: "true"
extension: "AVX512.*" # VPOPCNT instructions are AVX512 (BITALG or VPOPCNTDQ)
+- go: PairDotProd
+ commutative: "true"
+ extension: "AVX.*"
+ documentation: "Multiply the elements and add the pairs together"
+- go: MaskedPairDotProd
+ masked: "true"
+ commutative: "true"
+ extension: "AVX.*"
+ documentation: "Multiply the elements and add the pairs together"
+# QuadDotProd, i.e. VPDPBUSD(S) are operations with src/dst on the same register, we are not supporting this as of now.
+- go: DotProdBroadcast
+ commutative: "true"
+ extension: "AVX.*"
+ documentation: "Multiply the elements and add the pairs together; the result is a broadcast of the dot product; imm8 = 127;"
- go: Max
commutative: "true"
extension: "AVX.*"
diff --git a/internal/simdgen/go.yaml b/internal/simdgen/go.yaml
index a6e70e2..4e88cc6 100644
--- a/internal/simdgen/go.yaml
+++ b/internal/simdgen/go.yaml
@@ -472,6 +472,36 @@
go: $t
out:
- *any
+- go: PairDotProd
+ asm: VPMADDWD
+ in:
+ - &int
+ go: $t
+ base: int
+ - *int
+ out:
+ - &int2 # The elemBits are different
+ go: $t2
+ base: int
+- go: MaskedPairDotProd
+ asm: VPMADDWD
+ in:
+ - class: mask
+ - *int
+ - *int
+ out:
+ - *int2
+- go: DotProdBroadcast
+ asm: VDPPD
+ in:
+ - &float
+ go: $t
+ base: float
+ - *float
+ - class: immediate
+ const: 127 # make sure the control bits [4:5] are all 1
+ out:
+ - *float
- go: Max
asm: "V?PMAXS[BWDQ]"
in: &2int
diff --git a/internal/simdgen/ops/MLOps/categories.yaml b/internal/simdgen/ops/MLOps/categories.yaml
new file mode 100644
index 0000000..30376cb
--- /dev/null
+++ b/internal/simdgen/ops/MLOps/categories.yaml
@@ -0,0 +1,15 @@
+!sum
+- go: PairDotProd
+ commutative: "true"
+ extension: "AVX.*"
+ documentation: "Multiply the elements and add the pairs together"
+- go: MaskedPairDotProd
+ masked: "true"
+ commutative: "true"
+ extension: "AVX.*"
+ documentation: "Multiply the elements and add the pairs together"
+# QuadDotProd, i.e. VPDPBUSD(S) are operations with src/dst on the same register, we are not supporting this as of now.
+- go: DotProdBroadcast
+ commutative: "true"
+ extension: "AVX.*"
+ documentation: "Multiply the elements and add the pairs together; the result is a broadcast of the dot product; imm8 = 127;"
diff --git a/internal/simdgen/ops/MLOps/go.yaml b/internal/simdgen/ops/MLOps/go.yaml
new file mode 100644
index 0000000..a126bba
--- /dev/null
+++ b/internal/simdgen/ops/MLOps/go.yaml
@@ -0,0 +1,31 @@
+!sum
+- go: PairDotProd
+ asm: VPMADDWD
+ in:
+ - &int
+ go: $t
+ base: int
+ - *int
+ out:
+ - &int2 # The elemBits are different
+ go: $t2
+ base: int
+- go: MaskedPairDotProd
+ asm: VPMADDWD
+ in:
+ - class: mask
+ - *int
+ - *int
+ out:
+ - *int2
+- go: DotProdBroadcast
+ asm: VDPPD
+ in:
+ - &float
+ go: $t
+ base: float
+ - *float
+ - class: immediate
+ const: 127 # make sure the control bits [4:5] are all 1
+ out:
+ - *float
\ No newline at end of file

Change information

Files:
  • M internal/simdgen/categories.yaml
  • M internal/simdgen/go.yaml
  • A internal/simdgen/ops/MLOps/categories.yaml
  • A internal/simdgen/ops/MLOps/go.yaml
Change size: M
Delta: 4 files changed, 90 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: arch
Gerrit-Branch: master
Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
Gerrit-Change-Number: 678515
Gerrit-PatchSet: 1
Gerrit-Owner: Junyang Shao <shaoj...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Junyang Shao (Gerrit)

unread,
Jun 3, 2025, 8:58:56 PM (7 days ago) Jun 3
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from David Chase

Junyang Shao uploaded new patchset

Junyang Shao uploaded patch set #2 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: arch
Gerrit-Branch: master
Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
Gerrit-Change-Number: 678515
Gerrit-PatchSet: 2
Gerrit-Owner: Junyang Shao <shaoj...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Attention: David Chase <drc...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Junyang Shao (Gerrit)

unread,
Jun 7, 2025, 9:28:04 PM (3 days ago) Jun 7
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from David Chase

Junyang Shao uploaded new patchset

Junyang Shao uploaded patch set #10 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: arch
Gerrit-Branch: master
Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
Gerrit-Change-Number: 678515
Gerrit-PatchSet: 10
unsatisfied_requirement
satisfied_requirement
open
diffy

David Chase (Gerrit)

unread,
Jun 9, 2025, 8:01:23 PM (2 days ago) Jun 9
to Junyang Shao, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Junyang Shao

David Chase voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Junyang Shao
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: arch
Gerrit-Branch: master
Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
Gerrit-Change-Number: 678515
Gerrit-PatchSet: 10
Gerrit-Owner: Junyang Shao <shaoj...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Attention: Junyang Shao <shaoj...@google.com>
Gerrit-Comment-Date: Mon, 09 Jun 2025 17:01:05 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

David Chase (Gerrit)

unread,
Jun 9, 2025, 8:47:20 PM (2 days ago) Jun 9
to Junyang Shao, goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com
Attention needed from Junyang Shao

David Chase added 2 comments

File internal/simdgen/ops/MLOps/categories.yaml
Line 5, Patchset 10 (Latest): documentation: "Multiply the elements and add the pairs together"
David Chase . unresolved

", yielding a vector of half as many elements with twice the input element size"

Line 14, Patchset 10 (Latest): documentation: "Multiply the elements and add the pairs together with saturation"
David Chase . unresolved

"Multiply the elements and saturated-add the signed-unsigned pairs together with saturation, yielding a vector of half as many elements with twice the input element size."

I went looking at the documentation for this instruction, and it is detailed and weird and we probably need an uglier name -- specifically the unsigned-signed operands, and that it operates 2-by-2 instead of 4-by-4 (SVE, different, because of course it is). And thus, because it is signed-unsigned, it is also NOT commutative.

Open in Gerrit

Related details

Attention is currently required from:
  • Junyang Shao
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: arch
    Gerrit-Branch: master
    Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
    Gerrit-Change-Number: 678515
    Gerrit-PatchSet: 10
    Gerrit-Owner: Junyang Shao <shaoj...@google.com>
    Gerrit-Reviewer: David Chase <drc...@google.com>
    Gerrit-Attention: Junyang Shao <shaoj...@google.com>
    Gerrit-Comment-Date: Mon, 09 Jun 2025 17:47:17 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Junyang Shao (Gerrit)

    unread,
    Jun 9, 2025, 10:15:29 PM (2 days ago) Jun 9
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Junyang Shao

    Junyang Shao uploaded new patchset

    Junyang Shao uploaded patch set #13 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Junyang Shao
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: newpatchset
      Gerrit-Project: arch
      Gerrit-Branch: master
      Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
      Gerrit-Change-Number: 678515
      Gerrit-PatchSet: 13
      unsatisfied_requirement
      open
      diffy

      Junyang Shao (Gerrit)

      unread,
      Jun 9, 2025, 11:47:13 PM (2 days ago) Jun 9
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Junyang Shao

      Junyang Shao uploaded new patchset

      Junyang Shao uploaded patch set #14 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Junyang Shao
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: newpatchset
      Gerrit-Project: arch
      Gerrit-Branch: master
      Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
      Gerrit-Change-Number: 678515
      Gerrit-PatchSet: 14
      unsatisfied_requirement
      open
      diffy

      Junyang Shao (Gerrit)

      unread,
      Jun 9, 2025, 11:47:37 PM (2 days ago) Jun 9
      to goph...@pubsubhelper.golang.org, Go LUCI, David Chase, golang-co...@googlegroups.com
      Attention needed from David Chase

      Junyang Shao added 2 comments

      File internal/simdgen/ops/MLOps/categories.yaml
      Line 5, Patchset 10: documentation: "Multiply the elements and add the pairs together"
      David Chase . resolved

      ", yielding a vector of half as many elements with twice the input element size"

      Junyang Shao

      Done

      Line 14, Patchset 10: documentation: "Multiply the elements and add the pairs together with saturation"
      David Chase . resolved

      "Multiply the elements and saturated-add the signed-unsigned pairs together with saturation, yielding a vector of half as many elements with twice the input element size."

      I went looking at the documentation for this instruction, and it is detailed and weird and we probably need an uglier name -- specifically the unsigned-signed operands, and that it operates 2-by-2 instead of 4-by-4 (SVE, different, because of course it is). And thus, because it is signed-unsigned, it is also NOT commutative.

      Junyang Shao

      Thanks for noticing the commutativity issue. I have also updated the name; 2-by-2 is in the name's "Pair" part so it should have distinguished them from SVE.

      Also updated the documentation.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • David Chase
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: arch
        Gerrit-Branch: master
        Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
        Gerrit-Change-Number: 678515
        Gerrit-PatchSet: 14
        Gerrit-Owner: Junyang Shao <shaoj...@google.com>
        Gerrit-Reviewer: David Chase <drc...@google.com>
        Gerrit-Attention: David Chase <drc...@google.com>
        Gerrit-Comment-Date: Mon, 09 Jun 2025 20:47:34 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: David Chase <drc...@google.com>
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        David Chase (Gerrit)

        unread,
        Jun 10, 2025, 10:34:38 PM (3 hours ago) Jun 10
        to Junyang Shao, goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com
        Attention needed from Junyang Shao

        David Chase voted and added 1 comment

        Votes added by David Chase

        Code-Review+2
        Commit-Queue+1

        1 comment

        File internal/simdgen/.gitignore
        Line 1, Patchset 15 (Latest):testdata/
        .gemini*
        David Chase . resolved

        Ideally, this small unrelated change would be in its own small CL. Once we get to a more stable world, if there are bugs that creep in, it's easier to debug and rollback CLs if they are small (if possible) and single-purpose.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Junyang Shao
        Submit Requirements:
        • requirement satisfiedCode-Review
        • requirement satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: arch
        Gerrit-Branch: master
        Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
        Gerrit-Change-Number: 678515
        Gerrit-PatchSet: 15
        Gerrit-Owner: Junyang Shao <shaoj...@google.com>
        Gerrit-Reviewer: David Chase <drc...@google.com>
        Gerrit-Attention: Junyang Shao <shaoj...@google.com>
        Gerrit-Comment-Date: Tue, 10 Jun 2025 19:34:35 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Junyang Shao (Gerrit)

        unread,
        Jun 10, 2025, 10:47:44 PM (2 hours ago) Jun 10
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Junyang Shao

        Junyang Shao uploaded new patchset

        Junyang Shao uploaded patch set #16 to this change.
        Following approvals got outdated and were removed:
        • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Junyang Shao
        Submit Requirements:
        • requirement satisfiedCode-Review
        • requirement satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newpatchset
        Gerrit-Project: arch
        Gerrit-Branch: master
        Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
        Gerrit-Change-Number: 678515
        Gerrit-PatchSet: 16
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Junyang Shao (Gerrit)

        unread,
        Jun 10, 2025, 11:03:01 PM (2 hours ago) Jun 10
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from David Chase and Junyang Shao

        Junyang Shao uploaded new patchset

        Junyang Shao uploaded patch set #17 to this change.
        Following approvals got outdated and were removed:
        • Code-Review: +2 by David Chase
        Open in Gerrit

        Related details

        Attention is currently required from:
        • David Chase
        • Junyang Shao
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newpatchset
        Gerrit-Project: arch
        Gerrit-Branch: master
        Gerrit-Change-Id: I20506eb889979ea5f390b36615f4cf934fc418c9
        Gerrit-Change-Number: 678515
        Gerrit-PatchSet: 17
        Gerrit-Owner: Junyang Shao <shaoj...@google.com>
        Gerrit-Reviewer: David Chase <drc...@google.com>
        Gerrit-Attention: Junyang Shao <shaoj...@google.com>
        Gerrit-Attention: David Chase <drc...@google.com>
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages