[Mlir-commits] [mlir] [mlir] Target Description and Cost Model in MLIR (PR #85141)

Mike Urbach llvmlistbot at llvm.org
Wed Mar 13 16:51:53 PDT 2024


https://github.com/mikeurbach commented:

I'll chime in out of the blue here because I spend a lot of time in my day job dealing with various forms of system and device descriptions (Devicetree, IP-XACT, etc.) . I won't weigh in on how this could ultimately fit into MLIR, just some thoughts in a vacuum from someone who is interested in this kind of stuff.

IMHO the trick here is picking a point in the general <-> specific spectrum and doing it well. This seems to take a stance middle-left of that spectrum where the DeviceDesc has a handful of required constructs (id, type, description), and a general set of key value pairs (property). It sort of reminds me of Devicetree.

I've seen and used setups similar to this, and it can work well, if you can do interesting things in general with the required constructs, and you have flexibility in the optional properties. You can layer more domain specific constructs on top, which take away optionality and "stringly" typed field, like the DefaultBaseDeviceDesc. But I think getting agreement on such definitions is challenging. Even for "CPU" there are wildly different architectures and microarchitectures. I think in this regard, the current proposal is tending a little towards the specific end of the spectrum, and I think there are challenges here to get a specific model everyone can agree on.

In the CIRCT project, we ended up going as far as we could towards the general side. We built an IR for representing a simple "object oriented" language with classes, fields, objects, and references, an "interpreter" to elaborate an object graph, and APIs to query an elaborated object graph. It is up to the frontend and backend tooling to provide APIs to end users which emit the correct IR, elaborate the object graph, and query the elaborated model. Some more info [here](https://circt.llvm.org/docs/Dialects/OM/RationaleOM/) and a quick talk [here](https://docs.google.com/document/d/1fOSRdyZR2w75D87yU2Ma9h2-_lEPL4NxvhJGJd-s5pk/edit#heading=h.x4daawz1b13s) if you're curious.

Separately from the above, some other random thoughts...

Have you thought about references between devices? E.g., a cache hierarchy where L1 has a reference to L2, etc.

Have you looked at MDL? https://discourse.llvm.org/t/rfc-landing-mdl-in-llvm-codegen/76507. As someone who is just curious about these things, I also vaguely follow that effort. It is clearly the product of a lot of thought and experience.

In general, thanks for pushing on this, I think it's a really interesting topic.

https://github.com/llvm/llvm-project/pull/85141


More information about the Mlir-commits mailing list