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

Remove unused global data descriptor shapes from arguments #1338

Merged
merged 12 commits into from Aug 3, 2023

Conversation

tbennun
Copy link
Collaborator

@tbennun tbennun commented Jul 30, 2023

This PR allows symbols that exist only in non-transient arrays to generate code successfully. This avoids the case of unused program arguments and enables compilation of more programs, while retaining symbolic analysis.

@tbennun tbennun requested review from alexnick83 and removed request for alexnick83 July 30, 2023 18:38
@tbennun tbennun marked this pull request as draft July 30, 2023 18:56
@tbennun tbennun marked this pull request as ready for review July 30, 2023 22:05
Copy link
Contributor

@alexnick83 alexnick83 left a comment

Choose a reason for hiding this comment

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

Some questions on the selected implementation.

for o in self.offset:
if isinstance(o, sp.Expr):
result |= set(o.free_symbols)

if self.transient or all_symbols:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the transient check only here? What about strides and offset just above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Strides and offset are always necessary if you have any memlet (a[i*stride] will be generated in the code).

for name, desc in self.arrays.items():
defined_syms.add(name)
if not desc.transient:
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe I understand the algorithm now. What I don't like is that it spills the need to specialize for Data subclasses to SDFG/SDFGState.free_symbols. Wouldn't it be cleaner not to have the transient check in Data.free_symbols and instead have it only here, without needing to specialize for strides/totalsize/etc.?

Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify, I would do:

for name, desc in self.arrays.items():
    if not desc.transient:
        not_strictly_necessary_global_symbols |= set(map(str, desc.free_symbols))

where free_symbols is the current definition. Alternatively, if the new definitions of free/used symbols are necessary, it could be desc.used_symbols(all_symbols=True).

Is the solution chosen an optimization, e.g., we can safely rule out that we don't need to check the strides or something like that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You’re right and I started to rewrite it as such.

@tbennun tbennun enabled auto-merge (squash) August 2, 2023 21:41
@tbennun tbennun requested a review from alexnick83 August 2, 2023 21:42
Copy link
Contributor

@alexnick83 alexnick83 left a comment

Choose a reason for hiding this comment

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

It appears the ssa-symbol tests didn't need to be amended after all. This makes more sense since this PR should not change the result of free_symbols.

context=context,
ignore_properties={'src_subset', 'dst_subset', 'num_accesses', 'is_data_src'})

dace.serialize.set_properties_from_json(
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to the PR, but why is YAPF constantly switching the formatting of such lines?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it depends on the version of yapf being used

@tbennun tbennun merged commit 350cff4 into master Aug 3, 2023
9 checks passed
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.

None yet

2 participants