-
Notifications
You must be signed in to change notification settings - Fork 79
New dependency finding #683
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
Conversation
- Changed function that generates access relations.
(`generate_access_relations()`)
- Changed function that generates dependency relations.
(`generate_dependency_relations()`)
- Added data classes that store information relevant to.
- (`RelationInfo`, `AccessRelation(RelationInfo)`,
`DependencyRelation(RelationInfo)`
inducer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! Looks great, just a few comments below.
loopy/kernel/__init__.py
Outdated
| size: isl.PwAff | ||
|
|
||
| @dataclass(frozen=True) | ||
| class RelationInfo: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstrings, specifying what variables are in the map, what the two ends of the map mean, what naming conventions are used.
loopy/kernel/__init__.py
Outdated
| size: isl.PwAff | ||
|
|
||
| @dataclass(frozen=True) | ||
| class RelationInfo: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add into documentation.
loopy/kernel/__init__.py
Outdated
| @dataclass(frozen=True) | ||
| class AccessRelation(RelationInfo): | ||
| access_type: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this want to be an enum?
loopy/kernel/__init__.py
Outdated
| relation: isl.Map | ||
|
|
||
| @dataclass(frozen=True) | ||
| class AccessRelation(RelationInfo): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should access relations be long-lived?
loopy/kernel/__init__.py
Outdated
| relation: isl.Map | ||
|
|
||
| @dataclass(frozen=True) | ||
| class AccessRelation(RelationInfo): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"has-a happier than is-a"
loopy/kernel/__init__.py
Outdated
|
|
||
| # {{{ dependency wrangling | ||
|
|
||
| def generate_access_relations(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def generate_access_relations(self): | |
| def generate_access_relations(self) -> ...: |
loopy/kernel/__init__.py
Outdated
| for insn in self.instructions: | ||
| for relation in write_read: | ||
| if relation.dependent_id == insn.id: | ||
| insn.update_depends_on(relation.insn_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| insn.update_depends_on(relation.insn_id) | |
| insn = insn.copy(depends_on=...) |
loopy/kernel/__init__.py
Outdated
| for read in read_maps | ||
| if write.var_name == read.var_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary quadratic complexity?
loopy/kernel/__init__.py
Outdated
| def dep_finder(self): | ||
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loopy/kernel/__init__.py
Outdated
| #self_dependency = x.relation.apply_range(x.relation.reverse()) | ||
|
|
||
| dependency_relation = x.relation.apply_range(y.relation.reverse()) | ||
| #dependency_relation -= self_dependency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subtract the diagonal instead:
…ion, and rewrote classes storing information for relations.
…ify_execution_order
…tation of the function
loopy/kernel/dependency.py
Outdated
| variable_name: str | ||
| relation: isl.Map | ||
| dependency_type: DependencyType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| variable_name: str | |
| relation: isl.Map | |
| dependency_type: DependencyType | |
| variable_name: Optional[str] | |
| relation: isl.Map | |
| dependency_type: Optional[DependencyType] |
(But probably better to make a data-mediated dependency a separate type, maybe a subclass.)
loopy/kernel/dependency.py
Outdated
| WRITE_READ = 0 | ||
| READ_WRITE = 1 | ||
| WRITE_WRITE = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| WRITE_READ = 0 | |
| READ_WRITE = 1 | |
| WRITE_WRITE = 2 | |
| WRITE_AFTER_READ = 0 | |
| READ_AFTER_WRITE = 1 | |
| WRITE_AFTER_WRITE = 2 |
loopy/kernel/dependency.py
Outdated
| from dataclasses import dataclass | ||
| from enum import Enum | ||
|
|
||
| class DependencyType(Enum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure whether we'll want this, or whether we'll want all those union'd together.
loopy/kernel/dependency.py
Outdated
| dependency_type: DependencyType | ||
|
|
||
| @dataclass(frozen=True) | ||
| class AccessRelation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| class AccessRelation: | |
| class _AccessRelation: |
loopy/kernel/dependency.py
Outdated
| union_of_dependencies = None | ||
| for rel in write_read: | ||
| if union_of_dependencies is None: | ||
| union_of_dependencies = rel.relation | ||
| else: | ||
| union_of_dependencies = union_of_dependencies | rel.relation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functools.reduce
loopy/kernel/dependency.py
Outdated
| domain: isl.BasicSet = knl.get_inames_domain(insn.within_inames) | ||
| insn_order: isl.Map = domain.lex_lt_set(domain) | ||
|
|
||
| # v FIXME: there must be a better way |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think about transitive dependencies.
loopy/kernel/dependency.py
Outdated
|
|
||
| for insn in knl.instructions: | ||
| domain: isl.BasicSet = knl.get_inames_domain(insn.within_inames) | ||
| insn_order: isl.Map = domain.lex_lt_set(domain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't start from lexicographic, but rather from an already-existing happens-before.
| :returns: True or false depending on whether the provided execution order | ||
| respects the dependencies in the loopy program. | ||
| """ | ||
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at James's prior work.
loopy/kernel/dependency.py
Outdated
| insn_order = insn_order & union_of_dependencies | ||
| execution_order = execution_order | frozenset({insn_order}) | ||
|
|
||
| return execution_order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this into the LoopKernel data structure.
…uced more? Yes (coming soon).
| given kernel transformation respects the data dependencies in a given | ||
| program. | ||
| .. attribute:: happens_before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .. attribute:: happens_before | |
| .. attribute:: after_id |
| from dataclasses import dataclass | ||
|
|
||
| @dataclass(frozen=True) | ||
| class HappensBefore: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| class HappensBefore: | |
| class HappensAfter: |
|
Does #704 supersede this? |
No description provided.