Calyx in 2022 #804
Replies: 5 comments 16 replies
-
Is the essential idea here to generate LLVM/MLIR C++ data structures from Rust? I wonder if others folks would be interested in this. I imagine this would also be a massive undertaking.
The CIRCT-based parser conforms (for the most part) with the syntax used in MLIR (LangRef). I don't think diverging from this is a good idea. |
Beta Was this translation helpful? Give feedback.
-
I'm mostly interested in a solution that lives at the FSMD level of abstraction. I think that when you start looking about expanding Calyx the language, this is where I start to think about MLIR as being part of the solution. These other levels of abstraction (e.g. handshake) solve a different problem than the FSMD aspect. Maybe we need to start to decouple Calyx the language from the MLIR dialect that represents FSMD stuff in MLIR? |
Beta Was this translation helpful? Give feedback.
-
I think alot of the core semantic questions are very interesting, too. :) |
Beta Was this translation helpful? Give feedback.
-
The big thing I'd like to see is a lowering from the Calyx MLIR dialect to CIRCT's hardware dialects. I think "Reimplement everything in CIRCT" makes it sounds a bit scary, but this seem like a worthwhile strategy in the long term. I think @stephenneuendorffer was alluding to this, but when you are in MLIR, expanding the "language" amounts to mixing in new dialects. This is a really cool thing. Also, CIRCT has a pretty solid set of optimizations and a Verilog emitter that quite robust and only getting more mature. It would be great to take advantage of these on the backend. Tactically, I think we already have a decent start from @cgyurgyik to build on incrementally. As far as I understand, the core passes implemented in the original Calyx paper are currently implemented in CIRCT. Next step would be to take the lowered Calyx IR and translate that to CIRCT's HW/Comb/Seq dialects. I can't commit to working on this full-, or even part- time, but this is something I am personally interested in working on. I think once a thin path is fleshed out, we can pile on more interesting things incrementally (e.g. rewrite the compile control pass to use the new top-down algorithm, add other interesting passes, etc.). |
Beta Was this translation helpful? Give feedback.
-
One more idea I've had brewing about Calyx... Has anyone given any thought to extensible/user-defined primitives? As far as I understand, the primitive libraries used thus far are hand-coded Verilog. I am thinking about a world where Calyx is more deeply integrated in CIRCT. It could be really interesting to let users plug primitive libraries into Calyx that are themselves implemented using other CIRCT tools. For example, one could write the library using PyCDE, Chisel, Edith, or whatever generator framework can connect to CIRCT, and flows targetting Calyx could use primitives from such a library. I'm asking about this because the scheduling infrastructure in CIRCT depends heavily on exactly what primitives you have and their properties, and I'm looking ahead to where I might want to define some new primitives for use with the scheduling tools and Calyx. |
Beta Was this translation helpful? Give feedback.
-
Calyx has come a long way since been published in 2020. We've built a lot of new tools, frontends, and passes on top of Calyx, all of which has been summarized in our previous blog post. The goal of this post is to set directions for work on Calyx in 2022. We've had a bunch of interest from the CIRCT community, along with the awesome work on the Calyx dialect lead by @cgyurgyik and @mortbopet. Moving forward, we'd like to get feedback from the community of potential Calyx users on what things are crucial in enabling adoption in the future and how can we best support them. To this end, we're collecting feedback from the community on Calyx-related work they'd like to see done–from specific engineering tasks to the bigger vision stuff. Being a small research team, we can't guarantee all of it will be done but we'd like to prioritize that affect the most users and be more community led.
To start us off, here are a few things that I think are important going forward:
State of Calyx in CIRCT: The Calyx CIRCT dialect has feature parity with respect to the native implementation. However, a majority of the compiler passes, including the core lowering passes, are implemented in the native compiler making it a hard dependency on folks using the Calyx-CIRCT flow. Going forward, I can think of a few ways to align the native and CIRCT efforts:
Well-defined Semantics: @EclecticGriffin's work on the Calyx Interactive Debugger (CIDR) uncovered several gaps in the semantics of Calyx, specifically with interfaces and control operators.
seq
operator which leads to incorrect optimizations. The key problem is that in order to retain the isolation properties of groups while relying on component-baseddone
signals, we have to know something about what part of group execution overlaps. Continued work on this aims to make the timing behavior more precise.Done
signals:done
signals correspond to ready signal in a traditional ready-valid interface and are used pervasively by Calyx components and primitives. However, unlike data signals,done
signals need to be manipulated very carefully since they signal passage of abstract time steps in the execution of the design. Careless use can result in unexpected behavior: #621, #788. Our work next year will focus on precisely defining the semantics ofdone
signals and describing how they can extended to pipelined designs.Parallel Execution: While technically a part of (2), the complexity of the
par
operator deserves its own thread (pun unintended). Calyx's existingpar
operator is very loosely specified: it guarantees that all children of apar
block execute once and scheduled in some order; there is no explicit guarantee that all children start executing at the same time even though the lowering passes currently follow this strategy. In the future, we'd like to move away from this form of unstructured parallelism which devolves into the same kind of pervasive parallelism in hardware designs and is not very amenable to automatic optimization and analysis. We've played around with a few different ideas for structured parallelism operators:par
as an optimization: The current semantics implemented by CIDR treatspar
blocks purely as an optimization ofseq
; it is always acceptable to replacepar
withseq
and assume the program remains functionally correct. The native compiler, on the other hand, treatspar
blocks in the same way as hardware parallelism: all assignments are active and input ports with multiple drivers result in a runtime error. In addition to this mismatch, this implementation ofpar
cannot express traditional producer-consumer examples.par
with explicit synchronization: This would amount to implementing a "fence" instruction in Calyx which tells the compiler where the synchronization points in the control program are. While this probably enables us to express the largest kinds of parallel patterns, the hardware cost of generating a "fence" is not obvious in the same way that the cost of other control operators is.There are a lot of other things to discuss here but I'm going to leave it to here. If you have thoughts on what could make Calyx more useful for you, no matter how specific, please share them with us!
Beta Was this translation helpful? Give feedback.
All reactions