Skip to content

Add optimal graph coloring to minimize shared FIFO buffer allocations#7

Open
potatoeeh wants to merge 1 commit intoARM-software:mainfrom
potatoeeh:optimal-graph-coloring
Open

Add optimal graph coloring to minimize shared FIFO buffer allocations#7
potatoeeh wants to merge 1 commit intoARM-software:mainfrom
potatoeeh:optimal-graph-coloring

Conversation

@potatoeeh
Copy link
Copy Markdown

The CMSIS-Stream scheduler uses nx.coloring.greedy_color() to assign shared buffers to FIFOs via graph coloring. This greedy heuristic can use more colors (buffers) than the graph's chromatic number.

This adds an exact backtracking-based coloring algorithm (optimal_coloring) that finds the minimum number of colors. Because the solver is expensive on large graphs, it includes a configurable visit budget (max_visits, default 131072). If the budget is exceeded, the function returns None, allowing the caller to fall back to the existing greedy algorithm.

Two-tier coloring strategy:

  1. Try exact backtracking (optimal, but potentially expensive)
  2. If budget exceeded, fall back to greedy (suboptimal, but fast)

Also adds Tests/test_optimal_coloring.py exercising correctness, greedy-vs-optimal gap, and budget fallback behavior.

The CMSIS-Stream scheduler uses nx.coloring.greedy_color() to assign
shared buffers to FIFOs via graph coloring. This greedy heuristic can
use more colors (buffers) than the graph's chromatic number.

This adds an exact backtracking-based coloring algorithm
(optimal_coloring) that finds the minimum number of colors. Because
the solver is expensive on large graphs, it includes a configurable
visit budget (max_visits, default 131072). If the budget is exceeded,
the function returns None, allowing the caller to fall back to the
existing greedy algorithm.

Two-tier coloring strategy:
1. Try exact backtracking (optimal, but potentially expensive)
2. If budget exceeded, fall back to greedy (suboptimal, but fast)

Also adds Tests/test_optimal_coloring.py exercising correctness,
greedy-vs-optimal gap, and budget fallback behavior.
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.

1 participant