Simulate Contended XY Routing of Messages Across a Core Mesh

Last updated: November 29, 2026

Quick Overview

Single-flit messages are injected at given cycles and travel on a 2D mesh using XY routing (fix x, then y), one hop per cycle, with each directed link carrying at most one flit per cycle. When flits compete for a link, the one that has waited longest wins, then lower id; return each message's delivery cycle.

Cerebras
Coding & Algorithms
Software Engineer
Cerebras
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Single-flit messages are injected at given cycles and travel on a 2D mesh using XY routing (fix x, then y), one hop per cycle, with each directed link carrying at most one flit per cycle. When flits compete for a link, the one that has waited longest wins, then lower id; return each message's delivery cycle.

Performance modeling of on-wafer communication is part of how compiler and architecture teams estimate whether a placement will hit its throughput target. The interviewer is looking for a correct cycle-level simulation, clear tie-breaking, and awareness of where contention models break down.

What the Interviewer Expects
  • Implements XY next-hop logic correctly
  • Groups contenders by directed link each cycle and applies the stated tie-break
  • Handles messages whose source equals destination and late injections
  • Skips idle cycles instead of looping through them
  • Analyzes complexity in terms of cycles and active flits
Key Topics to Cover
discrete simulation
XY routing
contention
hash grouping
performance modeling
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you add per-node input buffers of limited depth?
  • How would you scale this to millions of messages (event-driven instead of cycle-stepped)?
  • Why is XY routing deadlock-free on a mesh?
  • How would you use this simulator to compare two placements?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Each message: id, source (x, y), destination (x, y), inject cycle. A flit ready at a node at cycle t may cross one link during cycle t and arrives at cycle t+1. Each directed link (node to neighbor) c...

High-Level Design

Cycle-stepped simulation. Each active flit stores position and ready (the cycle it arrived at its current node, or its inject time). At cycle t, every flit with ready at most t wants the link (pos, ...


Submit Your Answer
Markdown supported

Related Questions