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

Dialect Extensions #115

Closed
NeuralCoder3 opened this issue Oct 14, 2022 · 3 comments
Closed

Dialect Extensions #115

NeuralCoder3 opened this issue Oct 14, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@NeuralCoder3
Copy link
Collaborator

NeuralCoder3 commented Oct 14, 2022

Often, one wants to keep a dialect extensible such that other dialects can attach at a well-defined interface.
An example would be a backend dialect that allows for dialects to handle code emission of new axioms.

This would also augment the rule construct on the cpp site for extensions that go beyond rewrites.

In general, such extension points could take the form of a map/list of functions that the dialect invokes.
The main difficulty in this approach is that the map with its type signature as well as interfacing declarations
have to be visible from other dialects.

A first step towards inter-dialect extensions, visibility, and backend extensions is in
https://github.com/NeuralCoder3/thorin2/tree/dialect_backends

@NeuralCoder3 NeuralCoder3 added the enhancement New feature or request label Oct 14, 2022
@leissa
Copy link
Member

leissa commented Oct 14, 2022

I'd prefer a design where we put as much stuff as possible within Thorin itself. For example, we should simply expose all different passes/phases as Thorin meta programs. This way the user can simply define their own compilation pipeline or maybe invoke very specific transformations at specific parts in the program. This fixes the pragma problem approaches like OpenMP have and extends the vectorize/parallel etc idiom that we did on master.
Check out this inspiring paper @michel-steuwer pointed me at:
https://homepages.inf.ed.ac.uk/gdp/publications/compiler-forest.pdf

E.g. we could so sth like this and let the user explicitly decide where to fire the expensive exponential optimizer:

for i in expensive_optimizations(loop) {
    // ...
}

Another useful thing is "failing is an option". With Thorin we have a super powerful language. But realistically we won't be able to compile each and every edge case that you can build with such language. Now, if you expose the compilation itself as a function the programmer has to invoke, the function may return Failure with an error message. E.g., if you want to vectorize code that contains higher-order functions, exceptions and what not, it is probably best for everyone involved, to simply report to the user back

sorry, I cannot vectorize this functions because you are using exceptions.

Another example would be the LLVM backend failing (see #108 and #9) with sth like

cannot compile this functions as it makes use of other nested functions; consider running clos_conv first

But I think we should take this discussion to a virtual meeting before we rush anything here.

@leissa
Copy link
Member

leissa commented Oct 14, 2022

Just tagging @michel-steuwer

@leissa
Copy link
Member

leissa commented Mar 20, 2024

I think we can close this due to the %compile and %opt plugins.

@leissa leissa closed this as completed Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants