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

CNE: Simple support for hls #479

Merged
merged 77 commits into from
Aug 12, 2024
Merged

CNE: Simple support for hls #479

merged 77 commits into from
Aug 12, 2024

Conversation

sjalander
Copy link
Collaborator

No description provided.

@sjalander sjalander requested a review from phate May 10, 2024 14:29
Copy link
Owner

@phate phate left a comment

Choose a reason for hiding this comment

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

The library dependencies are:

libutil <-- librvsdg <-- libllvm <-- libhls

By introducing something from hls to libllvm, you are creating a cyclic dependency as libllvm all in a sudden is also dependent on libhls. This is not the right way to go about this.

If you want some CNE support for HLS, then you have currently two possibilities:

  1. We factor out the mechanisms from CNE and abstract it away from the concrete operations such that it can also be used in HLS. This will require some thinking and work.
  2. You implement your own CNE in libhls. You already went the same route with DNE. This means we are duplicating even more code though.

As it is, this is not going to be merged.

@sjalander
Copy link
Collaborator Author

I guess the ideal would be to go with option 1 and also do the same for DNE.

@phate
Copy link
Owner

phate commented May 12, 2024

@sjalander Yes, the best would be to go for option 1, but that would require some thinking and engineering time.

sjalander and others added 25 commits August 11, 2024 10:37
The diff should be self-explanatory :)
…phate#481)

While debugging other things, I caved and put together a little web-app
to render the Graphviz output, where I can click the nodes, ports and
edges to look at their attributes, and highlight related elements. It is
lacking features, and doesn't look good (highlight colors are extremely
arbitrary), but it did help me debug :)

Note that the webapp should be able to render any Graphviz, not just
output from the `GraphWriter`. The utility of the tool is of course
greater when nodes and edges have non-standard attributes.

This PR gives nodes a white fill instead of being transparent, making
them easier to click (can click anywhere instead of on text or border).
The rest of the PR is just cleanup of the code used to dump the
PointerObjectSet subset graph.

If you want to try the webapp, it's hosted at
https://dot-tree-viz.vercel.app/.

The code I wrote to dump RVSDG using the GraphWriter is not included, as
it was very ad hoc (see e.g. the type graph that does no
de-duplication).

<details><summary>Here is some example GraphViz</summary>

```
digraph graph0 {
  node[shape=box style=filled fillcolor=white];
  penwidth=6;
  label="Type graph"
  
  node0 [label=ptr tooltip="555d654afb10" ];
  node1 [label=ptr tooltip="555d6547ca90" ];
  node2 [label=iostate tooltip="555d65484230" ];
  node3 [label=mem tooltip="555d65484290" ];
  node4 [label=ptr tooltip="555d6549b3a0" ];
  node5 [label=bit32 tooltip="555d6547ead0" ];
  node6 [label=bit32 tooltip="555d65476b40" ];
  node7 [label=bit32 tooltip="555d65499260" ];
  node8 [label=bit32 tooltip="555d65499040" ];
  node9 [label=vararg tooltip="555d6547cc20" ];
  node10 [label=bit32 tooltip="555d65474c20" ];
  node11 [label=ptr tooltip="555d6546f9b0" ];
  node12 [label=mem tooltip="555d6546fa80" ];
  node13 [label=mem tooltip="555d6547ca30" ];
  node14 [label=ptr tooltip="555d65487a80" ];
  node15 [label=ptr tooltip="555d6548f240" ];
  node16 [label=struct tooltip="555d65471670" ];
  node17 [label=bit32 tooltip="555d654afaa0" ];
  node18 [label=ptr tooltip="555d65483c50" ];
  node19 [label=iostate tooltip="555d65471760" ];
  node20 [label=mem tooltip="555d65471810" ];
  node21 [label=bit32 tooltip="555d654ab7b0" ];
  node22 [label=ptr tooltip="555d65480ab0" ];
  node23 [label=mem tooltip="555d65476920" ];
  node24 [label=mem tooltip="555d654773f0" ];
  node17 -> node16[id=edge0 ];
  node18 -> node16[id=edge1 ];
}
digraph graph1 {
  node[shape=box style=filled fillcolor=white];
  penwidth=6;
  label="RVSDG root graph"
  tooltip="555d65497890" 
  {
    rank=source;
    a0 [label=a0 type=node0 tooltip="555d65488270" ];
  }
  node25 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i0" BGCOLOR="#FFFFFF" tooltip="555d6549b2d0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">LAMBDA[reorder_basic_blocks]</TD></TR>
                        <TR><TD>
                                <TABLE BORDER="0" CELLSPACING="4" CELLPADDING="2"><TR>
                                        <TD BORDER="1" STYLE="ROUNDED" WIDTH="40" BGCOLOR="white" SUBGRAPH="graph2">graph2</TD>
                                </TR></TABLE>
                        </TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o0" type="node1" BGCOLOR="#FFFFFF" tooltip="555d65477610"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d6549b420" ];
  {
    rank=sink;
    r2 [label=r2 tooltip="555d6547e270" ];
  }
  a0 -> node25:i0:n[id=edge25 ];
  node25:o0:s -> r2[id=edge26 ];
}
digraph graph2 {
  node[shape=box style=filled fillcolor=white];
  penwidth=6;
  tooltip="555d65493e20" 
  {
    rank=source;
    a1 [label=a1 type=node2 tooltip="555d65489b00" ];
    a2 [label=a2 type=node3 tooltip="555d65474340" ];
    a1 -> a2[style=invis];
    a3 [label=a3 type=node4 tooltip="555d65488150" ];
    a2 -> a3[style=invis];
  }
  node26 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">BITS32(1)</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o1" type="node5" BGCOLOR="#FFFFFF" tooltip="555d6547ea40"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d65476bc0" ];
  node27 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">BITS32(0)</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o2" type="node6" BGCOLOR="#FFFFFF" tooltip="555d65476ab0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d654769a0" ];
  node28 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">BITS32(0)</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o3" type="node7" BGCOLOR="#FFFFFF" tooltip="555d654991d0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d654990c0" ];
  node29 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">BITS32(0)</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o4" type="node8" BGCOLOR="#FFFFFF" tooltip="555d654719d0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d654718a0" ];
  node30 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">VALIST</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o5" type="node9" BGCOLOR="#FFFFFF" tooltip="555d6547cb90"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d654897a0" ];
  node31 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">BITS32(1)</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o6" type="node10" BGCOLOR="#FFFFFF" tooltip="555d65474b90"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d65476d90" ];
  node32 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i1" BGCOLOR="#FFFFFF" tooltip="555d6546f7f0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">ALLOCA[struct]</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o7" type="node11" BGCOLOR="#FFFFFF" tooltip="555d6546f920"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o8" type="node12" BGCOLOR="#FFFFFF" tooltip="555d6546f9f0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d65476e20" ];
  node33 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i2" BGCOLOR="#FFFFFF" tooltip="555d654ae3a0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i3" BGCOLOR="#FFFFFF" tooltip="555d6547c890"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">MemStateMerge</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o9" type="node13" BGCOLOR="#FFFFFF" tooltip="555d6547c9c0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d654ae220" ];
  node34 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i4" BGCOLOR="#FFFFFF" tooltip="555d65487690"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i5" BGCOLOR="#FFFFFF" tooltip="555d654877c0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i6" BGCOLOR="#FFFFFF" tooltip="555d654878f0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">GetElementPtr</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o10" type="node14" BGCOLOR="#FFFFFF" tooltip="555d65487a10"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d654993b0" ];
  node35 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i7" BGCOLOR="#FFFFFF" tooltip="555d6547ed10"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i8" BGCOLOR="#FFFFFF" tooltip="555d6547edd0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i9" BGCOLOR="#FFFFFF" tooltip="555d6548f090"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">GetElementPtr</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o11" type="node15" BGCOLOR="#FFFFFF" tooltip="555d6548f1b0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d6547eba0" ];
  node36 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i10" BGCOLOR="#FFFFFF" tooltip="555d6547dd80"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i11" BGCOLOR="#FFFFFF" tooltip="555d6547de70"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i12" BGCOLOR="#FFFFFF" tooltip="555d6547dfa0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i13" BGCOLOR="#FFFFFF" tooltip="555d6547e0c0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">CALL</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o12" type="node16" BGCOLOR="#FFFFFF" tooltip="555d654715e0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o13" type="node19" BGCOLOR="#FFFFFF" tooltip="555d654716d0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o14" type="node20" BGCOLOR="#FFFFFF" tooltip="555d654717a0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d65473470" ];
  node37 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i14" BGCOLOR="#FFFFFF" tooltip="555d6548dfa0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">ExtractValue</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o15" type="node21" BGCOLOR="#FFFFFF" tooltip="555d654ab720"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d6548ddf0" ];
  node38 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i15" BGCOLOR="#FFFFFF" tooltip="555d6548f470"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">ExtractValue</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o16" type="node22" BGCOLOR="#FFFFFF" tooltip="555d65480a20"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d6548f2c0" ];
  node39 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i16" BGCOLOR="#FFFFFF" tooltip="555d654ab920"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i17" BGCOLOR="#FFFFFF" tooltip="555d654aba50"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i18" BGCOLOR="#FFFFFF" tooltip="555d654abb80"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">Store</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o17" type="node23" BGCOLOR="#FFFFFF" tooltip="555d654768b0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d654ab830" ];
  node40 [shape=plain style=solid label=<
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i19" BGCOLOR="#FFFFFF" tooltip="555d65480c70"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i20" BGCOLOR="#FFFFFF" tooltip="555d65480da0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="10"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="i21" BGCOLOR="#FFFFFF" tooltip="555d65480ed0"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="1" STYLE="ROUNDED" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" >
                        <TR><TD CELLPADDING="1">Store</TD></TR>
                </TABLE>
        </TD></TR>
        <TR><TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>
                        <TD WIDTH="20"></TD>
                        <TD BORDER="1" CELLPADDING="1" PORT="o18" type="node24" BGCOLOR="#FFFFFF" tooltip="555d65477380"  WIDTH="8" HEIGHT="5" FIXEDSIZE="true"></TD>
                        <TD WIDTH="20"></TD>
                </TR></TABLE>
        </TD></TR>
</TABLE>
  > tooltip="555d65480b30" ];
  {
    rank=sink;
    r0 [label=r0 tooltip="555d65477490" ];
    r1 [label=r1 tooltip="555d65477550" ];
    r0 -> r1[style=invis];
  }
  node31:o6:s -> node32:i1:n[id=edge2 ];
  node32:o8:s -> node33:i2:n[id=edge3 color="#FF0000" ];
  a2 -> node33:i3:n[id=edge4 color="#FF0000" ];
  node32:o7:s -> node34:i4:n[id=edge5 ];
  node29:o4:s -> node34:i5:n[id=edge6 ];
  node28:o3:s -> node34:i6:n[id=edge7 ];
  node32:o7:s -> node35:i7:n[id=edge8 ];
  node27:o2:s -> node35:i8:n[id=edge9 ];
  node26:o1:s -> node35:i9:n[id=edge10 ];
  a3 -> node36:i10:n[id=edge11 ];
  node30:o5:s -> node36:i11:n[id=edge12 ];
  a1 -> node36:i12:n[id=edge13 color="#00FF00" ];
  node33:o9:s -> node36:i13:n[id=edge14 color="#FF0000" ];
  node36:o12:s -> node37:i14:n[id=edge15 ];
  node36:o12:s -> node38:i15:n[id=edge16 ];
  node34:o10:s -> node39:i16:n[id=edge17 ];
  node37:o15:s -> node39:i17:n[id=edge18 ];
  node36:o14:s -> node39:i18:n[id=edge19 color="#FF0000" ];
  node35:o11:s -> node40:i19:n[id=edge20 ];
  node38:o16:s -> node40:i20:n[id=edge21 ];
  node39:o17:s -> node40:i21:n[id=edge22 color="#FF0000" ];
  node36:o13:s -> r0[id=edge23 color="#00FF00" ];
  node40:o18:s -> r1[id=edge24 color="#FF0000" ];
}
```
</details>
…anSCC (phate#484)

This does not affect correctness, but should boost performance by
avoiding unnecessary visits of nodes that are already parts of finished
SCCs.

When implementing DFS using a stack, I had forgotten that the same node
can be added multiple times before it actually gets visited. In a graph
like
```
A -------> B
 \         ^
  --> C --/
```
Visiting node A will push B and C. Since we then visit C first, it will
also have to push B to process B before C can be popped. The edge `A->B`
should then be ignored when popping B the second time.
…e#487)

The three address code conversion for volatile loads and stores did not
create the correct LoadVolatileNode and StoreVolatileNode classes, but
simple_node classes.

This PR does the following:
1. Fix the three address code conversion for volatile loads
2. Fix the three address code conversion for volatile stores
3. Refactors the conversion to be better readable
4. Adds unit tests for the conversions
5. Adds support functions to easier test other conversions in the future
…sen] [SteensgaardAgnostic] (phate#486)

This PR does the following:
1. Adds support for volatile load, store, and memcpy nodes to memory
state encoder
2. Adds support for volatile load, store, and memcpy nodes to
Steensgaard alias analysis
3. Adds support for volatile load, store, and memcpy nodes to Andersen
alias analysis
4. Adds support for volatile load, store, and memcpy nodes to
region-aware memory node provider
5. Tighten the handling of simple nodes in the memory state encoder
…g worklist policy (phate#490)

This PR fixes a bug in the worklist solver where pointees could be added
to `GetPointsToSet(node)`, while the points-to set was being iterated
over.

Running the worklist is now divided into two functions, to convert
runtime configuration into compile-time configuration through
dispatching the corresponding templated version.

With this PR, the only configuration of the worklist solver is the
worklist policy.

The default configuration checks an environment variable to be
overridden. This is to make development easier, and not because I think
environment variables are a good configuration interface :)
As described in "The Ant and the Grasshopper" by Hardekopf and Lin
(2007).
This PR moves all operations that only work on memory states into the
same header and implementation file. This ensures that they are
logically grouped together instead of being split up over multiple
files.

The following operations are affected:
1. MemStateOperator, MemStateMergeOperator, MemStateSplitOperator: Moved
from operators.[hc]pp
2. Lambda[Entry/Exit]MemStateOperator and
Call[Entry/Exit]MemStateOperator: Moved from
alias-analysis/Operators.[hc]pp
Remove all code generation macros for instantiating bitstring operation
classes. Replace this with normal C++ template classes.
Adds Online Cycle Detection described by Pearce et al. "Online cycle
detection and difference propagation for pointer analysis" (2003).

OCD is enabled by default, but can be controlled by the config
environment variable. Template fun is used to dispatch the runtime
boolean into a compile time boolean, so there is no performance hit when
OCD is disabled.

Also contains a fix for a bug that could occur when the Escaped-flag
implies PointsToExternal in the unification root, without adding the
unification root to the worklist. I had handled this for
PointeesEscaping already, just forgot PointsToExternal.
The PR does the following:
1. Rename the operations to consistent names
2. Adds some documentation
3. Cleans up some minor code smells
This change introduces shared_ptr for types, uses them in most places
for storage, and starts putting in singleton objects for several
primitive
types.

The singletons use the "untracked feature" for std::shared_ptr -- the
"object used for lifetime tracking" can be separate from the "pointer
that the shared_ptr logically points to". It is possible to make the
former a "null" object in which case we actually have a non-reference
counted "shared" object that is supposed to have eternal lifetime.

This small trick allows to skip the cost of refcount inc/dec for these
eternal primitive objects. According to measurements, "create + destroy"
of e.g. bittype(32) is at ~6 CPU clock cycles (including function call
overhead), so this is already cheaper than before.
…ate#500)

Remove all code generation macros for instantiating bitstring comparison
operation classes. Replace this with normal C++ template classes.
Convert llvm type attribute, base types as well as the type conversion
routines to use shared_ptr<type>.
Instead of controlling which tracing format to be used at compile time
of jlm it is now given as a -D flag when compiling the generated file
with verilator.
Add overloaded constructors and/or creator functions that take
"shared_ptr<const type>" instead of "const type &" arguments (and hence
can take over reference from caller, instead of requiring a copy
operation).

In some cases, the "type copy" methods can be removed as they have no
callers anymore. For others, the superseded methods will be removed once
all callers are converted.

This sets the groundwork for gradually converting all call sites to use
shared type references.
This PR does the following:
1. Adds support for non-recursive direct calls to invariant value
redirection
2. Adds support for memory state operation nodes to invariant value
redirection
3. Adds helper methods to call node class to retrieve respective memory
state operation nodes
4. Adds helper methods to lambda node class to retrieve respective
memory state operation nodes
5. Some minor refactoring of the invariant value redirection tests

The above improvements handle the common cases. I marked the places in
the code where we can still do improvements with FIXMEs, but these
should not be very common and can be done another time.
Change the constructor of testnode to required shared_ptr<type> for
input and output parameters. This is a large and purely mechanical
change, but affects numerous files. This is the majority of node
conversions required.
This PR:

- converts constructors of rvsdg base nodes to only accept
shared_ptr<type> instead of "const type &"
- adds further overloads to various llvm IR ops to accept
shared_ptr<type> (for transition in addition to "const type&")
- removes the superseded "const type &" constructors from
expport/impport and clean up all ripple effects

With this PR, the conversion to changed API in unit tests is nearly
complete, so afterwards the "const type &"
API functions can be removed one-by-one.
Convert lambda, call nodes and others to use
"std::shared_ptr<FunctionType>" instead of "const FunctionType &" to
avoid copying instances.
Remove implicit conversion of "const type &" to port, and mark the
construction from "std::shared_ptr<type>" explicit. Remove
constructability through "const port&" from all node_input/node_output
(as well as structural input and all decendants). It still exists for
region args & results where it plays a role in carrying additional
information besides a type.

After this change, there is no type copying in and around graph nodes
anymore, although a few node factory functions need to be cleaned up
still.
phate#514)

We changed the make target for Andersen alias analysis with agnostic
encoding in this [PR](phate/jlm-eval-suite#31).
Fix the CI to reflect this change.
phate and others added 17 commits August 11, 2024 10:37
This PR does the following:
1. Introduces the GammaArgument class, which represents a region
argument in a gamma subregion.
2. Removes the is_gamma_argument() function.
This PR does the following:
1. Introduces the GammaResult class, which represents a region result in
a gamma subregion.
2. Removes the is_gamma_result() function.
This PR does the following:
1. Introduces the ThetaArgument class, which represents a region
argument in
a theta subregion.
2. Removes the is_gamma_argument() function.
This PR does the following:
1. Introduces the ThetaResult class, which represents a region result in
a theta subregion.
2. Removes the is_theta_result() function.
This PR does the following:
1. Removes `is_phi_output()` function
2. Removes `is_phi_cv()` function
3. Removes `is_phi_recvar_argument()` function
4. Removes `phi_result()` function
This PR does the following:
1. Rename TestRegion.cpp to RegionTests.cpp
2. Transform single unit test to individual unit tests
3. Split out the argument and result class tests into their own
respective files
4. Some minor clean-up of the individual unit tests

This PR cleans up the respective unit test files before handling issues
phate#556 and phate#555.

---------

Co-authored-by: Magnus Sjalander <[email protected]>
It turns out `for` loops in `/bin/sh` will ignore the exit codes of all
commands except the very last command they run. This allowed some
formatting errors to sneak into `master`.
This PR adds support for annotations to region trees. Here is an example
of how it will look like:

```
RootRegion
-STRUCTURAL_TEST_NODE
--Region[0]
--Region[1]
---STRUCTURAL_TEST_NODE
----Region[0]
----Region[1]
----Region[2] NumNodes:0 NumArguments:0
```

The plan is to use this for introducing a pass that enables the printing
of RVSDG properties for debugging as well as metric gathering for pass
evaluations.

---------

Co-authored-by: Magnus Sjalander <[email protected]>
I was having an issue where tests of the command parser would fail due
to some MLIR option, even when neither `--enable-mlir` nor
`--enable-hls` are passed to `configure.sh`. That is a separate issue
that should be fixed, but I thought it was about time I got MLIR and
CIRCT running on my own machine anyway.

These changes should make the build scripts work no matter where LLVM is
installed.

This is as a draft PR for now, to check that these changes do not break
CI.

PS: Some `.cpp` files used symbols imported from the standard library
indirectly, so I had to add some `#include <>` to make it work. I am on
arch (btw), but I am guessing these changes will become necessary on
Ubuntu eventually as well.
A test was failing when compiling without `--enable-mlir`, due to
`--output-format mlir` being unknown when `ENABLE_MLIR` is not defined.

This issue could have been fixed in a different location, such as not
defining the `Mlir` value in the `OutputFormat` enum at all, but that
would have created some additional situations where `#ifdef`s would have
to be added.

I think it is nice to use as few `#ifdef`s as possible, to avoid
situations like this where tests fail in specific `#ifdef`
configurations. I would not be opposed to including the `--output-format
mlir` option in all builds, but possibly making it invisible in the
help-text.
If `OutputFormat::Mlir` is selected without being enabled in the build,
it eventually triggers a `JLM_UNREACHABLE` that informs you that jlm has
been compiled without the MLIR dialect. I think this is much more
user-friendly than just denying that there ever was an output format
called `mlir`.
This change simplifies a helper function in
`TestJlcCommandLineParser.cpp` and `TestJlmOptCommandLineParser.cpp` by
using `c_str()`. It is safe to do this as the strings owning the
underlying data live longer than the vector of `const char *` (and the
strings are never modified).

To make this change legal, some `const` had to be added, but only in
places where no mutation is happening.

The `const char * const *` is necessary, as `char **` can not be cast to
`const char **`.
I had to google this to [understand
why](https://isocpp.org/wiki/faq/const-correctness#constptrptr-conversion).
@sjalander
Copy link
Collaborator Author

@phate
Went the easier route with duplicating code and created a HLS specific CNE optimization.

Copy link
Owner

@phate phate left a comment

Choose a reason for hiding this comment

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

Just asking to be sure: This PR does nothing else than cloning the CNE to the HLS namespace, right? You did not modify the CNE implementation in any?

Could you introduce a FIXME on the cne class that informs about it only being a copy from the LLVM cne (with explicit reference to the other implementation, please). If you made modifications, then please mention those as well. I will merge the PR with the FIXME.

I will also try to prioritize some engineering time in getting general support for common optimizations such that we can avoid the code duplication in the future.

@phate phate self-requested a review August 12, 2024 05:44
@sjalander
Copy link
Collaborator Author

sjalander commented Aug 12, 2024

@phate

No, it also has these changes applied to it 2bbab4a

I added a short note about this.

@sjalander sjalander enabled auto-merge (squash) August 12, 2024 07:10
@sjalander sjalander merged commit e5e1259 into phate:master Aug 12, 2024
10 checks passed
@phate phate deleted the cne branch August 12, 2024 14:21
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.

None yet

5 participants