Conversation
There was a problem hiding this comment.
Pull request overview
Updates Neura’s codegen to correctly resolve diagonal link directions when targeting a king-mesh (8-neighbor) topology, and adds a dedicated lit test + architecture spec to validate diagonal operands in generated YAML/ASM outputs.
Changes:
- Extend
Topology::getDirBetween/invertDirto handleNORTHEAST/NORTHWEST/SOUTHEAST/SOUTHWEST. - Add a king-mesh test architecture YAML for lit-based codegen testing.
- Add a new codegen lit test that checks diagonal direction evidence in emitted YAML/ASM.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
lib/NeuraDialect/Transforms/GenerateCodePass.cpp |
Adds diagonal direction resolution/inversion for king-mesh link operands. |
test/arch_spec/architecture_king_mesh.yaml |
Introduces a king-mesh topology architecture spec for tests. |
test/code_gen/test_code_generate_king_mesh.mlir |
Adds a new lit test ensuring diagonals are emitted (and not incorrectly treated as LOCAL). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
BTW, why do we need king-mesh? I thought our evaluations are only running on mesh. |
I am currently working on a case study and found that mapping is quite difficult with a mesh-only topology. @ShangkunLi mentioned that it works on a king mesh, but I noticed that the generated ASM and YAML were missing the proper directions for diagonal connections. |
For which kernel? I thought we can now map most kernels you are working on. |
@n0thingNoob introduces a synthetic function composed of two Considering we also need to support codegen for king-mesh architectures, we decided to make this pr. |
|
The |
A single large DFG for mapping, though with bad performance (i.e., compiled II = 28). |
King Mesh Diagonal Codegen Update
Background
GenerateCodePasspreviously handled only 4-neighbor directions:EASTWESTNORTHSOUTHWhen running on a
king_meshtopology (8-neighbor connectivity), diagonal links could be resolved asLOCALor mapped incorrectly in generated outputs. This caused mismatches between mapping/link intent and emitted instruction operands in:tmp-generated-instructions.yamltmp-generated-instructions.asmWhat Was Changed
1) Direction support in codegen
File updated:
dataflow/lib/NeuraDialect/Transforms/GenerateCodePass.cppChanges:
Topology::getDirBetween(...)to support diagonal directions:(1, 1) -> NORTHEAST(-1, 1) -> NORTHWEST(1, -1) -> SOUTHEAST(-1, -1) -> SOUTHWESTTopology::invertDir(...)accordingly:NORTHEAST <-> SOUTHWESTNORTHWEST <-> SOUTHEASTLOCALsemantics unchanged for true local/no-link scenarios.2) Dedicated king-mesh architecture spec for tests
New file:
dataflow/test/arch_spec/architecture_king_mesh.yamlThis file is copied from the regular test architecture and sets:
multi_cgra_defaults.base_topology: "king_mesh"per_cgra_defaults.base_topology: "king_mesh"3) New codegen test
New file:
dataflow/test/code_gen/test_code_generate_king_mesh.mlirTest behavior:
architecture_king_mesh.yamlMAPPING)--implicit-check-not=LOCALfor YAML/ASM to catch accidental fallbackVerification Summary
The new king-mesh codegen test passes:
llvm-lit -v dataflow/test/code_gen/test_code_generate_king_mesh.mlirManual inspection of generated artifacts confirms diagonal operands are emitted as expected (e.g.,
NORTHEAST,NORTHWEST,SOUTHEAST,SOUTHWEST) instead of incorrectLOCAL.