Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dialect overview diagram #2072

Merged
merged 12 commits into from
Dec 10, 2021
Merged

Update dialect overview diagram #2072

merged 12 commits into from
Dec 10, 2021

Conversation

mortbopet
Copy link
Contributor

@mortbopet mortbopet commented Nov 2, 2021

Seeing as quite a few new dialects and conversions have entered CIRCT since this diagram was made, I think it's due for an update! Let me know what you think, and if you have anything you'd like to have added/removed.

note: I'll keep the below preview updated wrt. feedback in the comments.

Seeing as quite a few new dialects and conversions have entered CIRCT since this diagram was made, I think it's due for an update! Let me know what you think, and if you have anything you'd like to have added/removed.
@lattner
Copy link
Collaborator

lattner commented Nov 2, 2021

This is extremely timely. I'm going to suck this into the CIRCT keynote at the devmtg in two weeks :-)

@lattner
Copy link
Collaborator

lattner commented Nov 2, 2021

One node that could be added is "CHIRRTL" which is the predecessor the High FIRRTL. The FIR Parser can produce all of CHIRRTL, High, Mid, and Low FIRRTL.

@youngar
Copy link
Member

youngar commented Nov 2, 2021

From a FIRRTL perspective:

  1. There is only one FIRRTL dialect, so it probably makes sense to squash High+Med+Low into one box which would make the diagram a lot simpler
  2. We don't handle FIRRTL in EmitVerilog, so the line from Lower FIRRTL -> EmitVerilog can be removed

updated: We are missing a some dialects: seq, comb, esi, msft Not sure how they fit in the diagram though. It might make some sense to document the python CDE.

Fabian has some notes about some changes to LLHD.

@mortbopet
Copy link
Contributor Author

How about basing this on a .dot file? We might loose a bit on how nice the graph looks, but i think it could remove a bit of friction for making people update the graph on a regular basis.

image

From something like the following:

Digraph G {
  // MLIR dialects
  subgraph cluster_mlir {
    label = "Upstream MLIR";
    SCF [fillcolor="lightblue"]
    Standard [fillcolor="lightblue"]
    Arith [fillcolor="lightblue"]
  }

  // ===== Nodes =====

  subgraph cluster_circt {
    label = "CIRCT"
    // CIRCT dialects
    Calyx
    Handshake
    FIRRTL
    BLLHD [label="Behavioral LLHD"]
   ...

    // Internal tools
    EmitVerilog [fillcolor="darksalmon"]
    FIRRTLParser [label="FIRRTL Parser" fillcolor="darksalmon"]
    Scheduling [fillcolor="darksalmon"]
  }

  // External tools
  Moore [shape=octagon fillcolor="gold"]
  ...  
  // File formats
  FIRFile [label="FIR file" fillcolor="yellowgreen" shape=note]
  ...

  // ===== Connections =====
  // Dialect conversions
  SCF -> Calyx
  SCF -> StaticLogic [style=dashed]
  Handshake -> FIRRTL
  BLLHD -> SLLHD
  ...


  // Tool flows
  Scheduling -> StaticLogic [dir=both]
  FIRFile -> FIRRTLParser
  FIRRTLParser -> FIRRTL
  FIRRTL -> EmitVerilog
 ...
}
```

@teqdruid
Copy link
Contributor

teqdruid commented Nov 2, 2021

I don't mind the graphviz output, though it is messier. Manually placing some of the nodes could make it clearer (IIRC graphviz supports X/Y coordinates). I don't much care if we move to graphviz. Is it possible to add a legend to the graphviz diagram? That's important.

Notes:

  • MSFT has an ExportTcl exporter.
  • ESI can produce Cap'nProto for cosim communication.
  • EmitVerilog has been renamed to ExportVerilog

@teqdruid
Copy link
Contributor

teqdruid commented Nov 2, 2021

Also, using 'ortho splines' mode would better match the previous image: https://graphviz.org/docs/attrs/splines/

@maerhart
Copy link
Member

maerhart commented Nov 2, 2021

Quick comment:

  1. There should also be an arrow from Comb to LLHD Sim
  2. LLHD Sim is actually part of CIRCT (both LLHDToLLVM and Engine) so it might make sense to put it inside the box

@mikeurbach
Copy link
Contributor

I think a refresh is great in general, and I support checking in a .dot file as well as the rendered diagram.

One quick note on the Scheduling + StaticLogic side: we are moving towards doing the scheduling based on Affine dialect rather than SCF, since upstream tools provide the level of detail scheduling needs only for Affine out of the box. So that would be a dotted line from Affine to StaticLogic. We may do progressive lowering through SCF internally, or we may just created the pipeline directly from Affine.

I'll leave it to @maerhart and @fabianschuiki to drill into the LLHD parts, but my impression is that work is moving away from converting to the LLHD dialect, and instead supporting the core dialects in the simulator directly.

@mortbopet
Copy link
Contributor Author

Thank you for the inputs, I've tried to update the diagram accordingly. @teqdruid I'll try to work in a legend; it's quite tricky to do directly in GraphViz without messing up the layout... but I'm thinking that we can just embed an image of the legend inside a node somewhere. Regarding using ortho lines, I'd say it yields worse results that the other possible spline types:
image

Another interesting possibility with this diagram is to embed links on both nodes (link to Dialect docs) and edges (link to conversion pass), providing a visual way of navigating the proejct.

@teqdruid
Copy link
Contributor

teqdruid commented Nov 2, 2021

Yep -- ortho is ugly.

Can you push your dot file? I'd like to use a modified version in some slides I'm prepping now.

@teqdruid
Copy link
Contributor

teqdruid commented Nov 3, 2021

Thanks for the dot!

I also think that PyCDE deserves a mention as a frontend which is in active development and about to be in use. It can theoretically produce any dialect but HW, Comb, Seq, MSFT are the ones it currently targets with ESI planned.

@fabianschuiki
Copy link
Contributor

Thanks for updating this @mortbopet! And @mikeurbach is right: @maerhart has been removing a lot of ops from LLHD in favor of the core dialects. "Structural LLHD" and "Behavioural LLHD" are now basically just "LLHD", and the simulator takes in a mixture of HW/Comb/Seq and LLHD.

PyCDE -> HW
PyCDE -> Comb
PyCDE -> Seq
PyCDE -> LLHD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyCDE doesn't directly produce LLHD... though it'd be interesting to expose some of LLHD's timing constructs through PyCDE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer a dotted edge between PyCDE and LLHD, or no edge? I guess there's also a danger in adding hypothetical edges all over, cluttering up the graph 🤔.

@mortbopet mortbopet marked this pull request as ready for review November 3, 2021 20:11
@mortbopet mortbopet changed the title [Draft] Update dialect overview diagram Update dialect overview diagram Nov 3, 2021
@mortbopet
Copy link
Contributor Author

Regarding the legend, i think the best looking choice will be to just have it as a separate image above the generated image. Trying to embed it into the dot file seems to be messing too much with the layout engine.

@seldridge
Copy link
Member

Color nit: I would like to use "better" colors for this. In the past, I've used Colorbrewer as I didn't trust myself to pick good colors.

For four colors that are print friendly and colorblind safe, we could use:

  • #a6cee3 #a6cee3
  • #1f78b4 #1f78b4
  • #b2df8a #b2df8a
  • #33a02c #33a02c

There are more options if we don't need to be colorblind safe, e.g.:

  • #7fc97f #7fc97f
  • #beaed4 #beaed4
  • #fdc086 #fdc086
  • #ffff99 #ffff99

Or:

  • #8dd3c7 #8dd3c7
  • #ffffb3 #ffffb3
  • #bebada #bebada
  • #fb8072 #fb8072

@seldridge
Copy link
Member

  1. Would you be able to add Chisel as an external tool? It would be sufficient to just have it as a tool with no inputs.
  2. For accuracy, FIRRTL Dialect also lowers to SV. This will make the diagram even more cluttered. 😬

Purely for reference, below is the graphviz I've used for this previously. This is a cartoon compared to what you're showing here, however! This is also a very Chisel-centric view.

One approach that may compact things further is to use sub-clusterings and have arrows start/stop at the cluster boundary. This may hurt accuracy, which I feel is important with this diagram, here as opposed to the cartoon I've used to explain the project. (You can see an example of this in the graphviz below.)

circt

graphviz source
digraph A {
  compound=true
  graph [ranksep=0.25 dpi=300 rankdir=TB]

  {
    node [shape=note]
    "Foo.scala"
    "Foo.fir" "Foo.anno.json"
    "Foo.v"
  }

  {
    node [style=filled shape=box width=1]
    Chisel [label="Chisel\nFront End" fillcolor="#fff5eb"]
    FIRRTL [label="FIRRTL\nDialect" fillcolor="#e5f5e0"]
    HW [label="HW" fillcolor="#fcbba1"]
    Seq [label="Seq" fillcolor="#fcbba1"]
    Comb [label="Comb" fillcolor="#fcbba1"]
    SV [label="SV" fillcolor="#fcbba1"]
    Handshake [label="Handshake"]
    ESI [label="ESI"]
    Tensorflow [label="Tensorflow"]
    Vector [label="Vector"]
    LLVM [label="LLVM"]
    Calyx [label="Calyx"]
    // LLHD [label="LLHD"]
  }

  subgraph cluster_circt {
    label="CIRCT"
    FIRRTL SV Calyx
    // LLHD

    subgraph cluster_rtl_dialects {
      label= "RTL Dialects"
      HW Seq Comb
    }

    subgraph cluster_timing_insensitive_dialects {
      label= "Timing Insensitive Dialects"
      Handshake ESI
    }
  }

  subgraph cluster_mlir {
    label="MLIR Dialects"
    Tensorflow Vector LLVM
  }

  Vector -> Handshake [lhead=cluster_circt ltail=cluster_mlir style=dashed minlen=2]

  "Foo.scala" -> Chisel -> {"Foo.fir" "Foo.anno.json"}

  {"Foo.fir" "Foo.anno.json"} -> FIRRTL
  "Foo.fir" -> {Handshake ESI} [style=invis]
  {FIRRTL Handshake ESI Calyx} -> Seq [lhead=cluster_rtl_dialects minlen=2]
  FIRRTL -> SV
  // Seq -> LLHD [ltail=cluster_rtl_dialects minlen=2]
  Seq -> "Foo.v" [ltail=cluster_rtl_dialects minline=2]
  SV -> "Foo.v"
}

Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome.

Some nits about how to DRY out the graphviz. 😄

docs/dialects.dot Outdated Show resolved Hide resolved
docs/dialects.dot Outdated Show resolved Hide resolved
docs/dialects.dot Outdated Show resolved Hide resolved
docs/dialects.dot Outdated Show resolved Hide resolved
@mortbopet
Copy link
Contributor Author

@seldridge thank you for the tips! I've incorporated it into the preview at the top 👍 .

@lattner
Copy link
Collaborator

lattner commented Nov 5, 2021

This is looking really great to me

}

subgraph cluster_circt {
label = "CIRCT"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A labeljust="r" would get this out of the way of the SCF/Arith arrows.

@teqdruid
Copy link
Contributor

teqdruid commented Nov 5, 2021 via email

@mortbopet
Copy link
Contributor Author

mortbopet commented Nov 8, 2021

@teqdruid I agree that the CIRCT box might not be necessary and constrains the layout too much... but i do think we loose a bit on distinguishing what is part of CIRCT and what is not.

dialects

What did you put in those non-circt boxes? A well defined box could be fir/chisel/py/.sv.vhd/moore but other than that, boxes seem to constrain the layout too heavily.

@mikeurbach
Copy link
Contributor

@mortbopet the diagram @teqdruid is referring to is much more abstract than what you are working on here. See below for what we included in the talk.

Screenshot from 2021-11-08 12-22-43

I do agree that removing the CIRCT box could help with layout. For the diagram we are discussing here, what if we removed the CIRCT box, and added some invisible edges to try to help line up the layout? That's what I did for the below diagram from the same talk. There are invisible edges from both Standard and SCF to Scheduling. It's still more abstract than what you are doing here, but I think the same idea holds.

Screenshot from 2021-11-08 12-26-07

@teqdruid
Copy link
Contributor

teqdruid commented Nov 8, 2021 via email

@mikeurbach
Copy link
Contributor

Since several of us are now using this dot based diagram in talks, can we merge this PR? I think it is already a great starting point.

@mortbopet
Copy link
Contributor Author

Since several of us are now using this dot based diagram in talks, can we merge this PR?

Fine by me; i think the current version is fine as well - if someone wants to spend some time on manually layout'ing it by adding coordinates, i am not opposed to that either (that will -most likely- not be me, though 😉).

@lattner
Copy link
Collaborator

lattner commented Dec 10, 2021

@mortbopet do you have commit access or need help landing this?

@mortbopet mortbopet merged commit 56bc7b5 into main Dec 10, 2021
@mortbopet
Copy link
Contributor Author

@lattner i do; merged it for now and then we'll take it from there.

@mortbopet mortbopet deleted the update_dialectsimg branch May 17, 2022 07:46
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.

8 participants