Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/asm: support Advanced Matrix Extensions (AMX) in Go Assembler #61079

Open
henkjan-sneller opened this issue Jun 29, 2023 · 10 comments · May be fixed by #61782
Open

cmd/asm: support Advanced Matrix Extensions (AMX) in Go Assembler #61079

henkjan-sneller opened this issue Jun 29, 2023 · 10 comments · May be fixed by #61782
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@henkjan-sneller
Copy link

The Go assembler (shipped with 1.20.5) currently lacks support for Advanced Matrix Extensions (AMX), particularly the sub-extensions AMX-TILE, AMX-INT8, and AMX-BF16.

As a workaround, we have been using byte sequences to generate the required instructions. However, for the sake of our mental stability, we would love to use proper instructions. @golang/compiler could you please add these 12 AMX instructions.

@gopherbot gopherbot added this to the Proposal milestone Jun 29, 2023
@ianlancetaylor ianlancetaylor changed the title proposal: support Advanced Matrix Extensions (AMX) in Go Assembler cmd/asm: support Advanced Matrix Extensions (AMX) in Go Assembler Jun 30, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jun 30, 2023
@ianlancetaylor
Copy link
Contributor

This doesn't need to be a proposal, so taking it out of the proposal process.

@ianlancetaylor ianlancetaylor modified the milestones: Proposal, Backlog Jun 30, 2023
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 30, 2023
@cagedmantis
Copy link
Contributor

/cc @golang/compiler

@anton-kuklin
Copy link
Contributor

anton-kuklin commented Jul 11, 2023

Would love to work on that.

@cherrymui
Copy link
Member

@anton-kuklin that would be great. Thanks! (I don't know of anybody currently working on this.)

@anton-kuklin
Copy link
Contributor

Sure, starting my work.

@anton-kuklin
Copy link
Contributor

anton-kuklin commented Jul 17, 2023

Quick update on my progress. During the investigation of how to implement this feature I discovered that there's a tool x86avgen. It generates corresponding optables based on a provided csv file, e.g. this or this. After that I discovered, that there's a tool x86spec which actually downloads the latest intel doc and parses it to generate corresponding csv file mentioned previously.

However, there's a problem. Currently this tool can't parse properly the latest documentation with added AMX commands, due to the unhandled header.
For example:

p.1440: reading TILELOADD/TILELOADDT1-Load Tile: unexpected header: "CPUID Feature\nFlag"
["Opcode/Instruction" "Op/En" "64/32-Bit Mode" "CPUID Feature\nFlag" "Description"]
["VEX.128.F2.0F38.W0 4B !(11):rrr:100\nTILELOADD tmm1, sibmem" "A" "V/N.E." "AMX-TILE" "Load data into tmm1 as specified by information\nin sibmem."]
["VEX.128.66.0F38.W0 4B !(11):rrr:100\nTILELOADDT1 tmm1, sibmem" "A" "V/N.E." "AMX-TILE" "Load data into tmm1 as specified by information\nin sibmem with hint to optimize data caching."]

To add AMX commands I first need to fix this parser (which I will work on). Do I need to create a separate issue for it, or I can fix it as part of this one?

CC: @cherrymui

@gopherbot
Copy link

Change https://go.dev/cl/510555 mentions this issue: x86spec: fix header parsing

@anton-kuklin
Copy link
Contributor

Hey @cherrymui, any chance you can give it a look? It should become pretty straightforward, after we will sort out the PR mentioned above.

anton-kuklin added a commit to anton-kuklin/go that referenced this issue Aug 5, 2023
Added instructions: LDTILECFG, STTILECFG, TDPBF16PS,
TDPBSSD, TDPBSUD, TDPBUSD, TDPBUUD, TILELOADD,
TILELOADDT1, TILESTORED

Fixes: golang#61079
@anton-kuklin anton-kuklin linked a pull request Aug 5, 2023 that will close this issue
@gopherbot
Copy link

Change https://go.dev/cl/516277 mentions this issue: cmd/asm: add x86 AMX instructions

@anton-kuklin
Copy link
Contributor

I've created an initial PR, however there's a number of questions, which had to be resolved before it will be ready, so it will take some time. I will ask questions in gerrit.

anton-kuklin added a commit to anton-kuklin/go that referenced this issue Aug 7, 2023
Added instructions LDTILECFG, STTILECFG, TDPBF16PS,
TDPBSSD, TDPBSUD, TDPBUSD, TDPBUUD, TILELOADD,
TILELOADDT1, TILESTORED

Fixes: golang#61079
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

Successfully merging a pull request may close this issue.

6 participants