-
Notifications
You must be signed in to change notification settings - Fork 31
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
Call For Requirements: MExpr Externals System #832
Comments
Here are some basic proposed requirements from my side to get started with. All necessary information for an external call should be given as input to the compiler at compile/evaluation timeA user should be able to declare an external function call in MExpr without having to rebuild the compiler or having to otherwise change a global configuration of the compiler. Some motivations for this:
Externals should be declared as expressions in the compiled source program itself (in the compiled MExpr AST). Certain platform specific aspects such as library linking paths may be more suited as compile-time flags or environment variables rather than as information in the program. Syntax of declared externals should not assume any specific backendAs a framework, Miking should be able to target multiple backends. One key idea that has been discussed is that MExpr should have a stable syntax. But at the same time MExpr should be able to add support for multiple backends as time progresses, hence the syntax of the declared externals should not rely on the targeted backend. |
Another requirement that I would like to add is that there should be a possibility to add some "default" fallback for defined externals. As an example, if I want to include BigInt functionality in a C target then I probably want to use the This also puts some restrictions on the external type here, since the representation of BigInt has to be chosen depending on the implementation used. Another motivating example is to provide efficient implementations for special operations. Suppose that we have an external type |
Another good thing about "default" implementations for externals is that they could act as semantic specifications that backends should conform to. That's a feature (semantic specifications for externals) that I think would be good to have in one form or another |
One use case I would like to highlight is where you need to reason about the external as just another function in your AST. In particular, when implementing AD or partial evaluation, you want to lift elementary functions to dual numbers (or similar), or statically evaluate the function. It is, of course, possible to match on identifiers, but that is a bit inconvenient compared to matching on |
Could you clarify what you mean about just another function in the AST? Do you mean as an intrinsic function, a lambda expression, or something else? |
Yes, I mean intrinsic function. |
An interesting aspect with this is how this may generalize externals for interpreted mode and boot. But should probably leave this kind of discussion for when we start with the design. |
One things that would be useful when working with external types would be to be able to allow external types to also contain other Miking types. As an example, suppose I want to define this external "multi-device" array type:
with the following underlying implementation in C int mda_make(struct mdaGeneric *mda, size_t elemsize, size_t n)
{
mda->n = n;
mda->elemsize = elemsize;
mda->data = mda_malloc(n * elemsize);
if (mda->data == NULL)
return -1
return 0;
} In this case, the MultideviceArray type somehow needs to have access to size properties of the contained type I'm thinking that these features would be more on the optional side. Such that types (internal and externals) doesn't have to support information if it doesn't make sense for that type. For example:
|
Following recent Miking meeting discussions about the new system for externals, we decided on opening this GitHub issue to allow for async and offline discussion about what we want for the new externals system.
The idea would be that we all contribute with requirements that we would like to start with. Then we sift through the list to get a better idea of what we want from MExpr's external system.
This issue only considers the MExpr aspect of the externals system. MLang and other high-level DSLs may be used for motivation, but the proposed design should be focused on MExpr only. To avoid further bikeshedding, the focus is on requirements of the new externals system rather than its syntax.
Each suggested requirement must include at least the following (not necessarily in bullet form):
Suggest one or more requirements as a response to this issue. I will then add a link to that requirement here in the list below. A response can contain multiple requirements, in which I will add multiple links to that same response (one link per requirement).
List of collected requirements:
The text was updated successfully, but these errors were encountered: