Skip to content

Meta Kernel Generation#96

Merged
davschneller merged 16 commits intomasterfrom
davschneller/metagen
Feb 16, 2026
Merged

Meta Kernel Generation#96
davschneller merged 16 commits intomasterfrom
davschneller/metagen

Conversation

@davschneller
Copy link
Contributor

@davschneller davschneller commented Aug 27, 2025

Add a way to call Yateto multiple times in a row with different configurations and template the kernels and tensors by call.
Subroutine caching needs to be done externally still (cf. #80 ; can be done with the datastructures introduced there).

Can be e.g. used to disambiguate kernels by precision or even more (like, e.g. convergence order or material class).
Needed for SeisSol/SeisSol#1421 and maybe others to come.

@davschneller davschneller marked this pull request as ready for review October 16, 2025 16:05
@davschneller davschneller mentioned this pull request Nov 13, 2025
Copy link
Contributor

@vikaskurapati vikaskurapati left a comment

Choose a reason for hiding this comment

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

Mostly looks okay to me apart from some queries. Could you please address them?

outfiles = []
for gendata in self.generators:
outdirname = f'metagen_{gendata["name"]}'
outdir = os.path.join(outputDir, outdirname)
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is outputDir defined in this scope? If it is intended to be a global variable, can we please avoid that and pass it as a function argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops; missed that one. Made it a function arg.

args = gendata['args']
kwargs = gendata['kwargs']

fixArchitectureGlobal(generator._arch)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use a getter function from Generator class instead of accessing the so called private variable here? I know this won't break anything, but it may be a cleaner design.

Copy link
Contributor Author

@davschneller davschneller Feb 12, 2026

Choose a reason for hiding this comment

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

Yes, we can (I agree, it's better that way). Done in the upcoming commit.

splitname = prename.split('::')

def inner():
name = splitname[-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

How are we guaranteeing that splitname is never an empty list here? I see Line 122 has splitname = prename.split('::'). So we could either have a check that prename is always consistently formatted, or if splitname is never empty. You could choose which is a better check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That actually shouldn't happen; since even without a '::' we'll just get a list with a single element, it being the whole string.
Looking it up for certainty (cf. here https://docs.python.org/3.6/library/stdtypes.html#str.split ): since we use split( ) with an argument, it doesn't happen. But it could if we had split(). I can add a comment for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if prename is an empty string? Or is it someone we can guarantee would never happen with absolute certainty? I still think it is better to have such checks in the function, so it is self-contained. But if you think it is too redundant, I would yield here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you mean about the split, then: prename = '' => prename.split('::') == [''] .

(i.e. we just get one element which is the whole string)

(can probably be confirmed in any Python console around if needed)

def compile_list(self, outputDir=''):
outfiles = []
for gendata in self.generators:
outdirname = f'metagen_{gendata["name"]}'
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a review comment, but a general query: how do you choose which variable name to be camel case, and which variable to be normal like this? For example: outdirname is not camelcase, but the function argument outputDir is camelcase. Is it that all internal variables are not camel cases, and then class members, and function arguments are camel cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's say... It's a bit arbitrary. The outputDir being camel case is more a relic since all of Yateto uses that convention quite a bit; especially in the older commits it seems.
And so, outputDir is usually in camel case within Yateto for now.

Usually, per the official Python style guide, snake case is the "official" way to name things; though snake case can sometimes appear a bit hard to read IMO (it just gives you less to focus on—visually at least).

... that made me think; at some point we might wanna apply the whole usual swath of Python linters on Yateto. I've started setting up a pre-commit in #109.

@davschneller davschneller merged commit c09c9e7 into master Feb 16, 2026
6 checks passed
@davschneller davschneller deleted the davschneller/metagen branch February 16, 2026 10:39
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.

2 participants