Skip to content

Conversation

@guosran
Copy link
Collaborator

@guosran guosran commented Dec 19, 2025

This PR addresses two improvements to the mapping algorithm:

  1. Fix canReachLocInTime BFS to model register-based waiting

    • Previously: Only tracked tile-level visits without time awareness
    • Now: Uses (tile, time) state tracking to allow register waiting
    • Aligns with tryRouteDataMove's routing behavior
    • Both link traversal and register waiting are properly modeled
  2. Refactor calculateAward with tunable parameters

    • Separated tile-based awards from time-based awards
    • Added constants for tuning: AWARD_PROXIMITY_SCALE, AWARD_BACKWARD_PROXIMITY_SCALE, AWARD_BASE_MULTIPLIER, AWARD_CRITICAL_BONUS_DIV (all set to 1 for now)
    • Improved proximity calculation for producers and backward users
    • Better handling of critical ops on recurrence paths

Test updates:

  • Updated backtrack-config from 'simple' to 'customized' (5,3)
  • Compiled II improvements:
    • nested_loop: 17 → 13 (23.5% improvement)
    • branch_for: 5 → 4 (20% improvement)
    • fusion: 14 → 13 and 15 → 12

…ulateAward

This PR addresses two improvements to the mapping algorithm:

1. Fix canReachLocInTime BFS to model register-based waiting
   - Previously: Only tracked tile-level visits without time awareness
   - Now: Uses (tile, time) state tracking to allow register waiting
   - Aligns with tryRouteDataMove's routing behavior
   - Both link traversal and register waiting are properly modeled

2. Refactor calculateAward with tunable parameters
   - Separated tile-based awards from time-based awards
   - Added constants for tuning: AWARD_PROXIMITY_SCALE,
     AWARD_BACKWARD_PROXIMITY_SCALE, AWARD_BASE_MULTIPLIER,
     AWARD_CRITICAL_BONUS_DIV (all set to 1 for now)
   - Improved proximity calculation for producers and backward users
   - Better handling of critical ops on recurrence paths

Test updates:
- Updated backtrack-config from 'simple' to 'customized' (5,3)
- Compiled II improvements:
  - nested_loop: 17 → 13 (23.5% improvement)
  - branch_for: 5 → 4 (20% improvement)
  - fusion: 14 → 13 and 15 → 12
Copy link
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 improves the mapping algorithm by fixing the canReachLocInTime BFS to properly model register-based waiting and refactoring calculateAward to separate tile-based from time-based scoring with tunable parameters. The changes result in significant compiled II improvements across multiple test cases.

Key changes:

  • Fixed canReachLocInTime to use (tile, time) state tracking instead of tile-only tracking, allowing register waiting to be properly modeled
  • Refactored calculateAward to separate proximity-based tile scoring from time-step scoring with tunable constants (all set to 1 for now)
  • Test updates reflecting II improvements: nested_loop (17→13), branch_for (5→4), fusion (14→13, 15→12)

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/NeuraDialect/Mapping/mapping_util.cpp Core algorithm changes: BFS state tracking fix and award calculation refactoring with tunable constants
test/c2llvm2mlir/nested_loop/test.mlir Updated expected compiled_ii from 17 to 13
test/neura/fusion/test.mlir Updated expected compiled_ii values (14→13, 15→12)
test/neura/for_loop/relu_test.mlir Updated expected mapping output formatting
test/neura/ctrl/branch_for.mlir Updated expected compiled_ii from 5 to 4 and formatting
test/mapping_quality/branch_for.mlir Updated expected compiled_ii from 5 to 4 with expanded output
test/e2e/relu/relu_kernel.mlir Updated expected mapping locations and formatting
test/e2e/histogram/histogram_kernel.mlir Updated expected mapping locations and formatting
test/e2e/fir/fir_kernel_vec.mlir Updated expected mapping locations
test/e2e/fir/fir_kernel.mlir Updated expected mapping locations
test/e2e/bicg/bicg_kernel.mlir Updated expected YAML output with expanded mappings
test/code_gen/test_code_generate.mlir Updated expected compiled_ii from 6 to 5

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@guosran
Copy link
Collaborator Author

guosran commented Dec 19, 2025

This is a follow-up of PR #195 .

@guosran
Copy link
Collaborator Author

guosran commented Dec 19, 2025

Pull request overview

This PR improves the mapping algorithm by fixing the canReachLocInTime BFS to properly model register-based waiting and refactoring calculateAward to separate tile-based from time-based scoring with tunable parameters. The changes result in significant compiled II improvements across multiple test cases.

Key changes:

  • Fixed canReachLocInTime to use (tile, time) state tracking instead of tile-only tracking, allowing register waiting to be properly modeled
  • Refactored calculateAward to separate proximity-based tile scoring from time-step scoring with tunable constants (all set to 1 for now)
  • Test updates reflecting II improvements: nested_loop (17→13), branch_for (5→4), fusion (14→13, 15→12)

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/NeuraDialect/Mapping/mapping_util.cpp Core algorithm changes: BFS state tracking fix and award calculation refactoring with tunable constants
test/c2llvm2mlir/nested_loop/test.mlir Updated expected compiled_ii from 17 to 13
test/neura/fusion/test.mlir Updated expected compiled_ii values (14→13, 15→12)
test/neura/for_loop/relu_test.mlir Updated expected mapping output formatting
test/neura/ctrl/branch_for.mlir Updated expected compiled_ii from 5 to 4 and formatting
test/mapping_quality/branch_for.mlir Updated expected compiled_ii from 5 to 4 with expanded output
test/e2e/relu/relu_kernel.mlir Updated expected mapping locations and formatting
test/e2e/histogram/histogram_kernel.mlir Updated expected mapping locations and formatting
test/e2e/fir/fir_kernel_vec.mlir Updated expected mapping locations
test/e2e/fir/fir_kernel.mlir Updated expected mapping locations
test/e2e/bicg/bicg_kernel.mlir Updated expected YAML output with expanded mappings
test/code_gen/test_code_generate.mlir Updated expected compiled_ii from 6 to 5
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Thank u Copilot T^T

@guosran guosran merged commit 75b6fbc into main Dec 20, 2025
1 check passed
@guosran guosran deleted the fix/canReach-refactor-award branch December 20, 2025 02:59
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