Skip to content

Data Move Register Bypass#286

Closed
guosran wants to merge 2 commits intomainfrom
feature/data-mov-register-bypass
Closed

Data Move Register Bypass#286
guosran wants to merge 2 commits intomainfrom
feature/data-mov-register-bypass

Conversation

@guosran
Copy link
Copy Markdown
Collaborator

@guosran guosran commented Mar 17, 2026

Summary

This PR addresses issue #283 by enforcing the register-bank (RegisterFile) read constraint directly in the mapper’s global availability check. When a routing bypass (MOV) and a computation both read from the same register cluster on the same tile at the same time slot, they are forced to use the identical intra-index register, while MOV-only traffic remains unconstrained.

Changes

  • Updated MappingState::isAvailableAcrossTime in MappingState.cpp to detect MOV vs compute accesses within the same RegisterFile and reject conflicting mixed accesses across different sibling registers in the same time slot.
  • Kept behavior unchanged for different register clusters and for MOV-only cases.

…instruction

Remove explicit egress instructions for DATA_MOV reg->outport movements.
The VectorCGRA hardware provides a direct bypass path from register banks
to the routing crossbar, so no FU slot is needed for these movements.
CTRL_MOV operations retain their explicit egress instructions.

Add validateRegReadConstraints() to enforce the single-read-port hardware
constraint: if a routing bypass and a computation both read from the same
register cluster on the same tile at the same time step, they must read
the identical register (same intra-index within the cluster).

Update DFG collectHopRewrites() to skip node creation for DATA_MOV
operations that no longer have corresponding instructions.

Update YAML/ASM FileCheck patterns in 16 test files to reflect the new
code generation output (first 50 lines, each PE block starts a new
// ASM: / // YAML: check).

Made-with: Cursor
@tancheng
Copy link
Copy Markdown
Contributor

hmmm,

Remove explicit egress instructions for DATA_MOV reg->outport movements.

I thought we still need the MOV instruction. (Bypass is done via the MOV instruction, CCing @Jackcuii to clarify.) What we need is just to enforce the mapper:

  • "if a routing bypass and a computation both read from the same register cluster on the same tile at the same time step, they must read the identical register (same intra-index within the cluster)."
  • if they are in different cluster, no such constraint
  • if reg -> port doesn't happen together with any computation, no such constraint

Add validateRegReadConstraints() to enforce the hardware constraint:
if a reg->outport routing bypass and a computation both read from the
same register cluster (same tile, same time step), they must read the
identical register. No constraint if from different clusters or if
reg->port doesn't happen together with any computation.

Track bypass reads via BypassRead struct during DATA_MOV expansion.
The MOV instruction itself is kept unchanged.

Update YAML/ASM FileCheck patterns in 5 affected test files.

Made-with: Cursor
@guosran
Copy link
Copy Markdown
Collaborator Author

guosran commented Mar 18, 2026

hmmm,

Remove explicit egress instructions for DATA_MOV reg->outport movements.

I thought we still need the MOV instruction. (Bypass is done via the MOV instruction, CCing @Jackcuii to clarify.) What we need is just to enforce the mapper:

  • "if a routing bypass and a computation both read from the same register cluster on the same tile at the same time step, they must read the identical register (same intra-index within the cluster)."
  • if they are in different cluster, no such constraint
  • if reg -> port doesn't happen together with any computation, no such constraint

Thank you for the clarification! I have reverted the excessive changes.

@tancheng
Copy link
Copy Markdown
Contributor

@guosran guosran force-pushed the feature/data-mov-register-bypass branch 2 times, most recently from f536c64 to 62971d3 Compare March 18, 2026 04:50
@guosran
Copy link
Copy Markdown
Collaborator Author

guosran commented Mar 18, 2026

Shouldn't we work on mapping algorithm? i.e., sth like:

https://github.com/coredac/dataflow/blob/c5e1f508ff06ae88a62aa5f495e240a53b7aafc5/lib/NeuraDialect/Mapping/mapping_util.cpp#L594

Sry my bad, I have rewrote the code in mapping_utils and reverted previous edits.

@guosran guosran marked this pull request as draft March 18, 2026 04:59
@guosran guosran force-pushed the feature/data-mov-register-bypass branch from 62971d3 to 4df691e Compare March 18, 2026 05:02
@guosran guosran marked this pull request as ready for review March 18, 2026 05:02
Register *mlir::neura::getAvailableRegister(const MappingState &state,
Tile *tile, int start_time,
int exclusive_end_time) {
// Collect registers occupied by computations (non-MOV operations) on this
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

// Collects

return reg;
for (int t = start_time; t < exclusive_end_time; ++t) {
auto op = state.getOpAt({reg, t});
if (!op.has_value()) continue;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't like one liner for if, can we make this be:

if (!op.has_value()) {
  continue;
}

if (!op.has_value()) continue;
Operation *mapped_op = op.value();
if (isa<neura::DataMovOp>(mapped_op) || isa<neura::CtrlMovOp>(mapped_op))
continue;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

if (!op.has_value()) continue;
Operation *mapped_op = op.value();
if (isa<neura::DataMovOp>(mapped_op) || isa<neura::CtrlMovOp>(mapped_op))
continue;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

for (Register *reg : tile->getRegisters()) {
if (!state.isAvailableAcrossTimeInRange(reg, start_time,
exclusive_end_time))
continue;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

bool conflict = false;
for (Register *comp_reg : computation_regs) {
if (comp_reg->getRegisterFile() != candidate_file)
continue;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

}

for (Register *reg : tile->getRegisters()) {
if (!state.isAvailableAcrossTimeInRange(reg, start_time,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of collects the registers for non-MOV ops first, can we just update the isAvailableAcrossTime()? https://github.com/coredac/dataflow/blob/c5e1f508ff06ae88a62aa5f495e240a53b7aafc5/lib/NeuraDialect/Mapping/MappingState.cpp#L118

checking whether it is a register, and whether the register's cluster has any other register is occupied for either mov or compute?

@Jackcuii
Copy link
Copy Markdown
Collaborator

hmmm,

Remove explicit egress instructions for DATA_MOV reg->outport movements.

I thought we still need the MOV instruction. (Bypass is done via the MOV instruction, CCing @Jackcuii to clarify.) What we need is just to enforce the mapper:

  • "if a routing bypass and a computation both read from the same register cluster on the same tile at the same time step, they must read the identical register (same intra-index within the cluster)."
  • if they are in different cluster, no such constraint
  • if reg -> port doesn't happen together with any computation, no such constraint

Yes~ We use mov to represent the bypass.

@guosran guosran force-pushed the feature/data-mov-register-bypass branch from 4df691e to 62971d3 Compare March 19, 2026 05:58
@guosran guosran closed this Mar 19, 2026
@guosran guosran deleted the feature/data-mov-register-bypass branch March 19, 2026 06:11
@guosran
Copy link
Copy Markdown
Collaborator Author

guosran commented Mar 19, 2026

Sorry there is a branch is too messy... I will create a new PR.

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