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

feat[venom]: new DFTPass algorithm #4255

Draft
wants to merge 97 commits into
base: master
Choose a base branch
from

Conversation

harkal
Copy link
Collaborator

@harkal harkal commented Sep 24, 2024

What I did

I upgraded the DFT algorithm to allow for more instruction movement. It also removes the use of order ids and sorting. It results generally smaller code, and opens up the road for multi-dimensional fencing.

How I did it

How to verify it

Commit message

This commit implements a new `DFTPass` to handle instruction grouping and 
ordering based on dependencies. This new algorithm ensures that instructions 
are processed in a dependency-first traversal manner as groups but also
individually, with special handling for volatile instructions and inter-group 
dependencies.

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

vyper/venom/passes/dft.py Fixed Show fixed Hide fixed
vyper/venom/passes/dft.py Fixed Show fixed Hide fixed
vyper/venom/passes/dft.py Fixed Show fixed Hide fixed
vyper/venom/basicblock.py Fixed Show fixed Hide fixed
vyper/venom/basicblock.py Fixed Show fixed Hide fixed
Comment on lines +73 to +79
children = sorted(
self.ida[inst],
key=lambda x: (
-self.inst_offspring_count[x] + (x.opcode == "iszero") * 10,
inst.operands.index(x.output) if x.output in inst.operands else 0,
),
)
Copy link
Member

Choose a reason for hiding this comment

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

the following seems to do slightly better:

Suggested change
children = sorted(
self.ida[inst],
key=lambda x: (
-self.inst_offspring_count[x] + (x.opcode == "iszero") * 10,
inst.operands.index(x.output) if x.output in inst.operands else 0,
),
)
children = sorted(
self.ida[inst],
key=lambda x: (
inst.operands.index(x.output) if x.output in inst.operands else 0,
-self.inst_offspring_count[x],
),
)

i guess inst_offspring_count is too coarse for what we want. i think the weight should be more like, recursively computing inst.operands.index(x.output) if x.output in inst.operands else 0, through the whole subgraph.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe this file will be clearer if the operand dependencies and barriers are separated into two data structures

Copy link

codecov bot commented Oct 5, 2024

Codecov Report

Attention: Patch coverage is 21.71053% with 119 lines in your changes missing coverage. Please review.

Project coverage is 49.38%. Comparing base (c02d2d8) to head (ff9e43c).

Files with missing lines Patch % Lines
vyper/venom/passes/dft.py 14.73% 81 Missing ⚠️
vyper/venom/basicblock.py 40.47% 25 Missing ⚠️
vyper/venom/venom_to_assembly.py 0.00% 6 Missing ⚠️
vyper/ir/compile_ir.py 0.00% 2 Missing and 1 partial ⚠️
vyper/venom/analysis/analysis.py 0.00% 1 Missing ⚠️
vyper/venom/analysis/cfg.py 0.00% 1 Missing ⚠️
vyper/venom/analysis/dfg.py 66.66% 1 Missing ⚠️
vyper/venom/analysis/liveness.py 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (c02d2d8) and HEAD (ff9e43c). Click for more details.

HEAD has 132 uploads less than BASE
Flag BASE (c02d2d8) HEAD (ff9e43c)
137 5
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4255       +/-   ##
===========================================
- Coverage   91.30%   49.38%   -41.93%     
===========================================
  Files         110      110               
  Lines       15764    15864      +100     
  Branches     3461     3492       +31     
===========================================
- Hits        14393     7834     -6559     
- Misses        935     7406     +6471     
- Partials      436      624      +188     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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