sampsyo / cs6120

advanced compilers
https://www.cs.cornell.edu/courses/cs6120/2023fa/
MIT License
739 stars 157 forks source link

Project Proposal: A (experimental) MLIR based dialect/compiler for hardware design #314

Closed yy665 closed 1 year ago

yy665 commented 2 years ago

Background MLIR is a modular, hybrid IR that is built based upon LLVM and could support a very diverse set of requirements, including dataflow graphs for Machine Learning, Polyhedral Optimizations, and hardware synthesis tools/HLS.

One of the super exciting tools that extends MLIR is called CIRCT. CIRCT is an innovative approach on hardware tooling that tries to apply LLVM methodology.

What will you do? This sounds like a big project with uncontainable scope. To actually make it happen with one manpower (myself) and one month, I am planning on just building a limited prototype that could describe a very basic data-path that could do some simple computation and memory operations. A more important target would be figuring out some major design choices for this compiler/dialect (to make this idea more concrete), including the set of hardware we’d like to support, abstractions for hardware module and transformation, guarantees/invariants we are offering, and extension points.

Unlike CIRCT which targets RTL level, I would like to aim for a higher abstraction to make the reasoning/transformation easier, but not at the HLS level to retain expressiveness.

How will you do it? I still need sometime to dig into MLIR and CIRCT to figure this out, but what I could tell at this point is that I definitely need to extend the MLIR to include some hardware primitives. I will also be likely to have BLUESPEC as my target language and write the codegen.

How will you empirically measure success? A “Hello World” hardware (in BLUESPEC) generated by the compiler that has the correct semantics.

A design document that has answered all major questions, with graphs to depict the structure/components of the language and the compiler. (To lay the ground for any future work)

Team members: For now just me.

sampsyo commented 2 years ago

Thanks for getting this started! I think you need to make this proposal a bit more concrete/specific before it's ready to go. I understand that you want to build some kind of hardware-generating dialect in MLIR, but I don't yet understand what that dialect will look like. Here are some important questions to answer (although I'm sure this isn't everything and you can come up with other questions to answer too):

Also, 6120 projects need to have a significant evaluation component. To make this a viable proposal, you will need a larger empirical evaluation than compiling "hello world." Can you make a plan that empirically measures the effectiveness of your new compiler using some kind of quantitative metric and some realistic use cases?

yy665 commented 2 years ago

Thanks for the feedback! I agree these are crucial questions and I am still looking into them. I need to do a bit more research before I could make the major design choices.

Regarding the evaluation component, I will make a follow-up post here once I have a realistic but non-trivial target.