This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add a document detailing the design of the SymbolTable.
ClosedPublic

Authored by rriddle on Jan 28 2020, 4:05 PM.

Details

Summary

This document provides insight on the rationale and the design of Symbols in MLIR, and why they are necessary.

Diff Detail

Event Timeline

rriddle created this revision.Jan 28 2020, 4:05 PM
rriddle updated this revision to Diff 241017.Jan 28 2020, 4:06 PM

Remove duplicate TOC

@mehdi_amini Coming back to this after a while, let me know if I'm missing anything or if there is something you want discussed.

Unit tests: pass. 62196 tests passed, 0 failed and 815 were skipped.

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

Unit tests: pass. 62196 tests passed, 0 failed and 815 were skipped.

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

Harbormaster completed remote builds in B45189: Diff 241017.
mehdi_amini added inline comments.Jan 29 2020, 10:07 PM
mlir/docs/SymbolsAndSymbolTables.md
7

nice does not seems "nice" here ;)

What about "One advantage of the MLIR design is that... "?

40

resides within a region that defines a SymbolTable isn't accurate I believe because of the transitivity aspect.

42
within the closest parent operation defining a `SymbolTable`
74

The part about "dialects may need to ensure that their operations support SymbolRefs and SSA values," isn't clear to me.

88

SymbolRefs instead of Symbols here (since this is about defining uses)

115

The transitively nested aspect is ignored here again.

146

I would add " but cannot be referenced externally: all the uses are in the parent regions"

mlir/docs/SymbolsAndSymbolTables.md
27

I am having a bit of trouble inferring whether this refers to thread-safe, or thread-safe but expensive locking or thread-safe with locking that is not expensive or something else.

51

s/An/A/

89

Unrelated question, would this (be a reasonable mechanism for | could be extended to support) aliasing for buffer-like semantics?

One of the difficulties when writing DRR for Linalg on tensors is that there are no use-def chains but instead aliasings coming from taking subviews and from a memref being an "input or an output operand" of a linalg op.

Some of the mechanisms you put in place here seem like they could apply and maybe make things significantly better re writing chains of read/write dependencies.
The semantics of linalg guarantee full buffer writes at that level of abstraction so it "behaves like SSA" (hand-wavy) from this point of view.

The big missing thing would be supporting control-flow but it's not like I'm doing anything with that anyway atm.
I also see there is a big difference between aliasing and "unique string names" but I can't shake the feeling this may also help more generally.

Do you see a connection between the 2 or am I imagining things and pattern-matching too much on "alternative to traditional SSA use-list"?

antiagainst added inline comments.Feb 5 2020, 7:59 AM
mlir/docs/SymbolsAndSymbolTables.md
28

Symbols or Symbol?

31

Isn't this too far down the page?

35

We can also refer to symbols defined below regions right? Would be nice to be clear here. :)

57

It seems we should move this point to its own part given this part is talking about "*must* adhere to".

75

Each has?

115

Nit: Symbols or Symbols? I think typically we use the latter to mean plural form of some code.

rriddle updated this revision to Diff 242784.Feb 5 2020, 4:34 PM
rriddle marked 20 inline comments as done.

Add examples, reword a few sections, resolve comments.

mlir/docs/SymbolsAndSymbolTables.md
42

Used "immediately within" instead, as "closest parent operation" implies that a symbol can be outside of the immediate region of a symbol table, i.e. at depth>1

74

Reworded a bit. It is essentially bringing note to the different trade-offs now that there are two different ways to refer to operations.

89

Currently no. The current infrastructure is mainly focused on efficiently/properly supporting global value style references. For example, there is no way to refer to a symbol defined above the current symbol table. That means that mid-function symbol tables would lose the ability to reference other functions. This is an interesting use case, but I'm hesitant to try and generalize when we haven't fully served the existing needs.

115

A symbol is not transitive, a symbol reference is.

Unit tests: unknown.

clang-tidy: pass.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

Anything else here? @mehdi_amini

mehdi_amini accepted this revision.Feb 7 2020, 9:14 PM
This revision is now accepted and ready to land.Feb 7 2020, 9:14 PM
This revision was automatically updated to reflect the committed changes.
bondhugula added inline comments.
mlir/docs/SymbolsAndSymbolTables.md
5

This opening sentence is broken grammatically.

96

-> "closest parent op that has a symbol table".

Otherwise, it's not clear here whether this means "closest parent op that has a symbol table" or "closest parent op that defines the symbol if any". Unless I missed it, the resolution part isn't documented above.