Skip to content

Testbench#172

Merged
n0thingNoob merged 7 commits intomainfrom
testbench
Oct 24, 2025
Merged

Testbench#172
n0thingNoob merged 7 commits intomainfrom
testbench

Conversation

@n0thingNoob
Copy link
Copy Markdown
Collaborator

This pull request introduces several improvements and extensions to the Neura architecture and code generation pipeline. The main changes are the addition of a local_id property for registers to distinguish local register identifiers from global ones, updates to register creation and usage to support local IDs, enhancements to mapping and code generation to track and use local register IDs, and the addition of new LLVM-to-Neura operation conversion patterns. It also adds support for including the compiled initiation interval (compiled_ii) in array configuration outputs.

Register ID improvements:

  • Added a local_id property to the Register class, updated its constructor, and provided getter/setter methods. Register creation now assigns both global and local IDs, making register identification more robust. (include/NeuraDialect/Architecture/Architecture.h, lib/NeuraDialect/Architecture/Architecture.cpp) [1] [2] [3] [4] [5]
  • Updated mapping state encoding to include both global and local register IDs in the mapping dictionary output. (lib/NeuraDialect/Mapping/MappingState.cpp)

Code generation and mapping updates:

  • Modified code generation logic to use local_register_id instead of global IDs when collecting and mapping register steps, ensuring correct local register references in output. (lib/NeuraDialect/Transforms/GenerateCodePass.cpp) [1] [2]

LLVM-to-Neura operation conversion:

  • Added new rewrite patterns to convert several LLVM operations to their Neura dialect equivalents, including XOR to OR, AND to MUL, FNeg to FSub, LShr to Shl (with negative shift), and Select to arithmetic ops. These patterns are registered in the conversion pipeline. (lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp) [1] [2]

Array configuration and output enhancements:

  • Added a compiled_ii field to ArrayConfig, updated output routines to include it in YAML and ASM files if available, and provided a helper to extract it from function attributes. (lib/NeuraDialect/Transforms/GenerateCodePass.cpp) [1] [2] [3] [4] [5] [6]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the Neura architecture and code generation pipeline by introducing local register identifiers alongside global IDs, expanding LLVM-to-Neura operation conversion patterns, and adding compiled initiation interval (II) tracking in array configurations.

Key changes:

  • Introduced local_id property for registers to provide per-tile local register identification separate from global IDs
  • Added five new LLVM-to-Neura conversion patterns (XOR→OR, AND→MUL, FNeg→FSub, LShr→Shl, Select→arithmetic ops)
  • Added compiled_ii field to array configurations with corresponding YAML and ASM output support

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
include/NeuraDialect/Architecture/Architecture.h Added local_id member and getter/setter methods to Register class
lib/NeuraDialect/Architecture/Architecture.cpp Updated Register constructor to accept local_id; modified register creation to assign both global and local IDs
lib/NeuraDialect/Mapping/MappingState.cpp Enhanced mapping state encoding to include both global and local register IDs in dictionary output
lib/NeuraDialect/Transforms/GenerateCodePass.cpp Modified code generation to use local_register_id; added compiled_ii support to ArrayConfig and output functions
lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp Added five new conversion patterns and registered them in the conversion pipeline
test/neura/ctrl/branch_for.mlir Updated test expectations to include compiled_ii field
test/mapping_quality/branch_for.mlir Updated test expectations to include compiled_ii field
test/e2e/histogram/histogram_kernel.mlir Updated test expectations to include local_register_id attributes and adjusted ASM output expectations
test/e2e/fir/fir_kernel_vec.mlir Updated test expectations to include local_register_id attributes and adjusted ASM output expectations
test/e2e/fir/fir_kernel.mlir Updated test expectations to include local_register_id attributes and adjusted ASM output expectations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@n0thingNoob
Copy link
Copy Markdown
Collaborator Author

n0thingNoob commented Oct 23, 2025

I forgot I have added some conversion rules to the pass. Let me fix that.

- Removed LlvmXOrToNeuraOr conversion rule
- Removed LlvmAndToNeuraMul conversion rule
- Removed LlvmFNegToNeuraFSub conversion rule
- Removed LlvmLShrToNeuraShl conversion rule
- Removed LlvmSelectToNeuraOps conversion rule
- Removed corresponding pattern registrations

These rules were added for FFT testing and are not needed in the main codebase.
- Add per_tile_register_id field to Register class
- Update MappingState to output both global ID and per_tile_register_id
- Modify GenerateCodePass to use local register IDs in ASM/YAML output
- Add compiled_ii information to YAML and ASM output
- Update test files to expect per_tile_register_id and local register IDs
- Refactor Architecture.cpp to remove recreateRegisterFileCluster and enhance createRegisterFileCluster
Remove commented-out FFT-related conversion rules from LlvmToNeuraPass.cpp to keep codebase clean
@n0thingNoob n0thingNoob merged commit da08c0e into main Oct 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants