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.
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.
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: |
loopy/kernel/__init__.py
Outdated
| @dataclass(frozen=True) | ||
| class AccessRelation(RelationInfo): | ||
| access_type: str |
loopy/kernel/__init__.py
Outdated
| relation: isl.Map | ||
|
|
||
| @dataclass(frozen=True) | ||
| class AccessRelation(RelationInfo): |
There was a problem hiding this comment.
Should access relations be long-lived?
loopy/kernel/__init__.py
Outdated
| relation: isl.Map | ||
|
|
||
| @dataclass(frozen=True) | ||
| class AccessRelation(RelationInfo): |
loopy/kernel/__init__.py
Outdated
|
|
||
| # {{{ dependency wrangling | ||
|
|
||
| def generate_access_relations(self): |
There was a problem hiding this comment.
| 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.
| 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.
Unnecessary quadratic complexity?
loopy/kernel/__init__.py
Outdated
| def dep_finder(self): | ||
| pass |
There was a problem hiding this comment.
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.
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.
| 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.
| 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.
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.
| 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 |
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.
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.
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 |
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.
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.
| .. attribute:: happens_before | |
| .. attribute:: after_id |
| from dataclasses import dataclass | ||
|
|
||
| @dataclass(frozen=True) | ||
| class HappensBefore: |
There was a problem hiding this comment.
| class HappensBefore: | |
| class HappensAfter: |
|
Does #704 supersede this? |
No description provided.