Skip to content

Conversation

@a-alveyblanc
Copy link
Contributor

No description provided.

@a-alveyblanc a-alveyblanc changed the title Temp commit New dependency finding Sep 26, 2022
a-alveyblanc and others added 4 commits October 1, 2022 21:04
- 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)`
Copy link
Owner

@inducer inducer left a 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.

size: isl.PwAff

@dataclass(frozen=True)
class RelationInfo:
Copy link
Owner

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.

size: isl.PwAff

@dataclass(frozen=True)
class RelationInfo:
Copy link
Owner

Choose a reason for hiding this comment

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

Add into documentation.

Comment on lines 89 to 91
@dataclass(frozen=True)
class AccessRelation(RelationInfo):
access_type: str
Copy link
Owner

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?

relation: isl.Map

@dataclass(frozen=True)
class AccessRelation(RelationInfo):
Copy link
Owner

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?

relation: isl.Map

@dataclass(frozen=True)
class AccessRelation(RelationInfo):
Copy link
Owner

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"


# {{{ dependency wrangling

def generate_access_relations(self):
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
def generate_access_relations(self):
def generate_access_relations(self) -> ...:

for insn in self.instructions:
for relation in write_read:
if relation.dependent_id == insn.id:
insn.update_depends_on(relation.insn_id)
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
insn.update_depends_on(relation.insn_id)
insn = insn.copy(depends_on=...)

Comment on lines 698 to 699
for read in read_maps
if write.var_name == read.var_name]
Copy link
Owner

Choose a reason for hiding this comment

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

Unnecessary quadratic complexity?

Comment on lines 729 to 730
def dep_finder(self):
pass
Copy link
Owner

Choose a reason for hiding this comment

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

#self_dependency = x.relation.apply_range(x.relation.reverse())

dependency_relation = x.relation.apply_range(y.relation.reverse())
#dependency_relation -= self_dependency
Copy link
Owner

Choose a reason for hiding this comment

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

Subtract the diagonal instead: $\{[i,j] \to [i',j']: i=i' \land j=j'\}$

Comment on lines 48 to 50
variable_name: str
relation: isl.Map
dependency_type: DependencyType
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
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.)

Comment on lines 13 to 15
WRITE_READ = 0
READ_WRITE = 1
WRITE_WRITE = 2
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
WRITE_READ = 0
READ_WRITE = 1
WRITE_WRITE = 2
WRITE_AFTER_READ = 0
READ_AFTER_WRITE = 1
WRITE_AFTER_WRITE = 2

from dataclasses import dataclass
from enum import Enum

class DependencyType(Enum):
Copy link
Owner

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.

dependency_type: DependencyType

@dataclass(frozen=True)
class AccessRelation:
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
class AccessRelation:
class _AccessRelation:

Comment on lines 174 to 179
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
Copy link
Owner

Choose a reason for hiding this comment

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

functools.reduce

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
Copy link
Owner

Choose a reason for hiding this comment

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

Think about transitive dependencies.


for insn in knl.instructions:
domain: isl.BasicSet = knl.get_inames_domain(insn.within_inames)
insn_order: isl.Map = domain.lex_lt_set(domain)
Copy link
Owner

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
Copy link
Owner

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.

insn_order = insn_order & union_of_dependencies
execution_order = execution_order | frozenset({insn_order})

return execution_order
Copy link
Owner

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.

given kernel transformation respects the data dependencies in a given
program.
.. attribute:: happens_before
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
.. attribute:: happens_before
.. attribute:: after_id

from dataclasses import dataclass

@dataclass(frozen=True)
class HappensBefore:
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
class HappensBefore:
class HappensAfter:

@a-alveyblanc a-alveyblanc mentioned this pull request Nov 14, 2022
@inducer
Copy link
Owner

inducer commented Nov 14, 2022

Does #704 supersede this?

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