[StaticLogicToCalyx] Predicate registers for prologue/epilogue execution
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
Currently, `StaticLogicToCalyx` will explicitly emit the set of group activations required for the prologue and epilogue of a pipeline. E.g., a pipeline with 4 stages will emit a schedule such as (excluding the group that evaluates pipeline continuation `%cont`):
```mlir
calyx.control {
calyx.seq {
calyx.par {
calyx.enable @stage0
}
calyx.par {
calyx.enable @stage0
calyx.enable @stage1
}
calyx.par {
calyx.enable @stage0
calyx.enable @stage1
calyx.enable @stage2
}
calyx.while %cont {
calyx.par {
calyx.enable @stage0
calyx.enable @stage1
calyx.enable @stage2
calyx.enable @stage3
}
}
calyx.par {
calyx.enable @stage1
calyx.enable @stage2
calyx.enable @stage3
}
calyx.par {
calyx.enable @stage2
calyx.enable @stage3
}
calyx.par {
calyx.enable @stage3
}
}
}
```
One alternative to this is to employ rotating predicate registers, known from e.g. [software pipelining](https://www.ele.uva.es/~jesman/BigSeti/ftp/Microprocesadores/Intel/IA-64/Presentaciones/ia-64_notes.pdf).
In this model, the execution of each stage is predicated by a bit in a predicate register. Every cycle while the pipeline runs, a new '1' is rotated into the predicate register. Once the pipeline no longer continues (epilogue), '0's are shifted into the predicate register.
This could be integrated by guarding group enablement with the predicate in the control schedule using an `if` statement:
```mlir
%r_pred.in, %r_pred.write_en, %r_pred.clk, %r_pred.reset, %r_pred.out, %r_pred.done = calyx.register @r_pred : i4, i1, i1, i1, i4, i1
calyx.group @update_pred {
// Shift pipeline continuation state into predicate register
calyx.assign %r_pred.in = {%r_pred.out[2:0], %cont} : i4
calyx.assign %r_pred.write_en = %true : i1
}
calyx.control {
calyx.seq {
calyx.while %cont {
calyx.par {
calyx.if %r_pred.out[0] { calyx.enable @stage0 }
calyx.if %r_pred.out[1] { calyx.enable @stage1 }
calyx.if %r_pred.out[2] { calyx.enable @stage2 }
calyx.if %r_pred.out[3] { calyx.enable @stage3 }
calyx.enable @update_pred
}
}
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing StaticLogicToCalyx's prologue and epilogue schedule generation and reviewing the existing Calyx control structure shown in the issue. Compare that flow with the proposed rotating predicate-register approach, including predicate updates and conditional stage enables. Done means the alternative is designed and integrated into StaticLogicToCalyx with its behavior validated against the pipeline schedule.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100