Skip to content

Conversation

@guosran
Copy link
Collaborator

@guosran guosran commented Jan 30, 2026

Summary

The MapCTOnCGRAArrayPass performs spatial mapping of taskflow.task operations onto a 2D CGRA grid. It optimizes task placement and SRAM assignment to minimize inter-tile communication and memory access latency.

Core Mechanism

  • Graph-Based Modeling: Constructs a bipartite Task-Memory Graph to track SSA dependencies between tasks and shared memory access.

  • Iterative Optimization: Employs a Coordinate Descent strategy that alternates between:

    1. Task Placement: Mapping tasks to grid tiles based on proximity to SSA producers and associated SRAMs.
    2. SRAM Assignment: Positioning SRAMs at the rounded centroid of all tasks accessing that specific memory.
  • Heuristic Scoring: Uses a weighted scoring function considering SSA proximity, memory distance, and grid load balancing.

  • The result for 'multi_nested_loop` is shown below:

final_mapped_graph

@guosran guosran marked this pull request as ready for review January 30, 2026 02:09
Copilot AI review requested due to automatic review settings January 30, 2026 02:09
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 introduces a dependency-analysis pass and a spatial placement pass for Minimized Canonicalized Tasks (MCTs) onto a 2D multi-CGRA grid, plus tests that validate the new placement attributes on several kernels.

Changes:

  • Add AnalyzeMCTDependencyPass to detect SSA and memory (RAW/WAR/WAW) dependencies between MCTs and to identify same-header fusion candidates.
  • Add PlaceMCTOnCGRAPass implementing a critical-path–driven placement heuristic with adjacency-aware scoring and basic memory/SRAM assignment, and register both passes in the Taskflow pass pipeline and build system.
  • Extend multi-CGRA Taskflow tests (parallel-nested, multi-nested, irregular-loop) with new RUN lines that invoke the placement pass and FileCheck the resulting taskflow.task placement attributes.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/multi-cgra/taskflow/parallel-nested/parallel-nested.mlir Adds a placement pipeline invocation and PLACEMENT checks for 2 tasks’ CGRA coordinates and counts.
test/multi-cgra/taskflow/multi-nested/multi-nested.mlir Adds placement pipeline and PLACEMENT checks for 5 tasks’ CGRA coordinates and counts in a more complex nested-loop scenario.
test/multi-cgra/taskflow/irregular-loop/irregular-loop.mlir Extends the irregular-loop test with a placement pipeline and PLACEMENT checks for 3 tasks’ CGRA coordinates and counts.
lib/TaskflowDialect/Transforms/PlaceMCTOnCGRAPass.cpp Implements the CGRA placer, including counter-chain extraction, dependency graph construction, ALAP-based task prioritization, heuristic scoring, placement annotation, and memory/SRAM mapping.
lib/TaskflowDialect/Transforms/CMakeLists.txt Registers the new analysis and placement passes with the Taskflow transforms library build.
lib/TaskflowDialect/Transforms/AnalyzeMCTDependencyPass.cpp Implements MCT dependency analysis, printing detailed per-task counter-chain and read/write sets plus a dependency summary.
include/TaskflowDialect/TaskflowPasses.td Declares the analyze-mct-dependency and place-mct-on-cgra passes with documentation used by MLIR’s pass infrastructure.
include/TaskflowDialect/TaskflowPasses.h Declares factory functions for constructing the new Taskflow passes.

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

@guosran guosran marked this pull request as draft January 30, 2026 02:22
Copy link

Copilot AI commented Jan 30, 2026

@guosran I've opened a new pull request, #255, to work on those changes. Once the pull request is ready, I'll request review from you.

@guosran guosran marked this pull request as ready for review January 30, 2026 02:51
@guosran guosran requested a review from ShangkunLi January 30, 2026 02:51
@guosran guosran force-pushed the cgra-placement branch 3 times, most recently from c657850 to 58700e7 Compare January 31, 2026 22:41
@guosran guosran force-pushed the cgra-placement branch 2 times, most recently from 13d2632 to a955784 Compare February 2, 2026 02:05
- Fix SRAM ID encoding for large grids\n- Add successors to SSA proximity score\n- Remove load balance metric\n- Improve error handling with assert\n- Fix comments and variable naming\n- Ensure SSA dependencies use value inputs only\n- Update tests for new placement logic
…lity and structure

- Rename CGRAPlacer to TaskMapper\n- Rename mapping_info to task_mapping_info\n- Use readable SRAM locations {row, col} in task_mapping_info\n- Provide full task lines in test cases
…mments on mapping info readability and encoding
…ncy terminology to dependency_depth, and improve SRAM mapping readability
@ShangkunLi ShangkunLi requested a review from tancheng February 6, 2026 04:02
@ShangkunLi
Copy link
Collaborator

@guosran Before merging, plz sync with the main branch, and double-check whether I missed any format checking (e.g., comment ends with a period, comment starts with the description style).

@guosran guosran merged commit 00a0518 into main Feb 6, 2026
1 check failed
@guosran guosran deleted the cgra-placement branch February 6, 2026 04:19
@guosran guosran restored the cgra-placement branch February 6, 2026 04:37
@guosran guosran mentioned this pull request Feb 6, 2026
guosran added a commit that referenced this pull request Feb 6, 2026
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.

4 participants