Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
82c4a77
Enforce single-read-port constraint in mapping algorithm
guosran Mar 18, 2026
4afbfdd
Enforce register-file intra-index constraint for mov vs compute
guosran Mar 19, 2026
dda69d8
feat: Implement register file occupancy tracking in MappingState, add…
guosran Mar 19, 2026
d26c4cc
Replaced autos with explicit data types
guosran Mar 19, 2026
cc551ee
feat: Enhance register occupancy tracking and add CGRA placement util…
guosran Mar 21, 2026
d6ee173
Replace RegClusterOccupyStatus with Operation* for register occupancy…
guosran Mar 22, 2026
4f64662
Fix shell command error messages in MLIR fusion test cases
guosran Mar 23, 2026
02d974f
Split reg_file map into read/write; allow same-register sharing; upda…
guosran Mar 23, 2026
af2cc0a
Implement read/write separation for register occupancy tracking
guosran Mar 24, 2026
b18095e
Merge remote-tracking branch 'origin/main' into feature/register-bypa…
guosran Mar 24, 2026
cba04b5
Resolved conflicts and implemented feedbacks
guosran Mar 24, 2026
6fb1032
Update mapping utilities and state, refresh test files.
guosran Mar 24, 2026
dac5ca8
Updated tests
guosran Mar 24, 2026
55cd94b
Refactor code for improved readability and consistency in MappingStat…
guosran Mar 25, 2026
7c0d4ef
Refactor mapping_util.cpp for improved type clarity and consistency
guosran Mar 25, 2026
d288203
Refactor MLIR test cases and add script for updating CHECK lines
guosran Mar 25, 2026
228105e
Refactor MappingState and mapping_util for improved clarity and consi…
guosran Mar 25, 2026
82cf52f
Enhance function signatures in MappingState and mapping_util for impr…
guosran Mar 25, 2026
103f489
Delete update_test_checks.py
guosran Mar 25, 2026
411f39f
Remove accidentally committed = file
guosran Mar 25, 2026
d9f4461
Update Zeonica_Testbench submodule to main branch
guosran Mar 25, 2026
2ccd34e
Sync Zeonica_Testbench submodule to match main branch (1e98cf0)
guosran Mar 25, 2026
1f90f12
Merge remote-tracking branch 'origin/main' into feature/register-bypa…
guosran Mar 25, 2026
872e387
Resolved merge conflicts
guosran Mar 25, 2026
6676bab
Fix formatting in comments for clarity in MappingState.cpp and fir_ke…
guosran Mar 26, 2026
048e313
Update tests
guosran Mar 26, 2026
76182e4
Edit variable names
guosran Mar 26, 2026
8510547
Rename `op` parameter to `move_op`
guosran Mar 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions include/NeuraDialect/Mapping/MappingState.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "mlir/IR/Operation.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <unordered_map>
#include <vector>

namespace mlir {
Expand Down Expand Up @@ -57,6 +58,17 @@ template <> struct hash<mlir::neura::MappingLoc> {
namespace mlir {
namespace neura {

// Tracks per-time-slot occupancy of a register cluster (RegisterFile).
// Used to enforce the constraint: if a bypass (MOV) and a computation read from
// the same cluster at the same time step, they must use the identical register.
struct RegClusterOccupyStatus {
int mov_count = 0; // number of MOV ops reading from this cluster
int compute_count = 0; // number of compute ops reading from this cluster

// Returns true if the cluster slot is occupied by any op (mov or compute).
bool alreadyOccupied() const { return mov_count > 0 || compute_count > 0; }
};

// Tracks placement and routing of ops on the CGRA.
class MappingState {
public:
Expand Down Expand Up @@ -152,6 +164,11 @@ class MappingState {
const std::map<Operation *, std::vector<MappingLoc>> &getOpToLocs() const {
return this->op_to_locs;
}
const std::unordered_map<RegisterFile *,
std::unordered_map<int, RegClusterOccupyStatus>> &
getRegFileOccupyRecords() const {
return this->reg_file_occupy_records;
}

// Setters for state information.
void setOccupiedLocs(
Expand All @@ -166,6 +183,12 @@ class MappingState {
const std::map<Operation *, std::vector<MappingLoc>> &op_to_locs) {
this->op_to_locs = op_to_locs;
}
void setRegFileOccupyRecords(
const std::unordered_map<RegisterFile *,
std::unordered_map<int, RegClusterOccupyStatus>>
&records) {
this->reg_file_occupy_records = records;
}

private:
// Initiation interval.
Expand All @@ -178,6 +201,31 @@ class MappingState {
std::map<MappingLoc, std::vector<std::pair<int, Operation *>>> occupied_locs;
std::map<MappingLoc, Operation *> loc_to_op;
std::map<Operation *, std::vector<MappingLoc>> op_to_locs;

// Record table for register cluster occupancy, keyed by (RegisterFile*,
// time_step % II). Updated incrementally on every bind/reserve/unbind/release
// so that isAvailableAcrossTime() can answer cluster-conflict queries in O(1)
// instead of scanning all sibling registers across all time steps.
std::unordered_map<RegisterFile *,
std::unordered_map<int, RegClusterOccupyStatus>>
reg_file_occupy_records;

// Returns true if op is a routing bypass (data_mov or ctrl_mov).
static bool isMovOp(Operation *op);

// Increments the appropriate counter in reg_file_occupy_records for a
// register location when op is bound/reserved there.
void addToRegFileRecord(Register *reg, int time_step, Operation *op);

// Decrements the appropriate counter in reg_file_occupy_records for a
// register location when op is unbound/released from there.
void removeFromRegFileRecord(Register *reg, int time_step, Operation *op);

// Returns true if placing op (mov or compute) onto reg at the given
// canonical time slot would violate the cluster read constraint.
bool violatesClusterReadConstraint(RegisterFile *reg_file, Register *reg,
int canonical_time_step,
bool is_mov) const;
};

} // namespace neura
Expand All @@ -199,6 +247,9 @@ class MappingStateSnapshot {
std::map<MappingLoc, std::vector<std::pair<int, Operation *>>> occupied_locs;
std::map<MappingLoc, Operation *> loc_to_op;
std::map<Operation *, std::vector<MappingLoc>> op_to_locs;
std::unordered_map<RegisterFile *,
std::unordered_map<int, RegClusterOccupyStatus>>
reg_file_occupy_records;
};
} // namespace neura
} // namespace mlir
Expand Down
Loading
Loading