FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-115457: Support splitting and replication of micro ops. by markshannon · Pull Request #115558 · python/cpython · GitHub

/ cpython Public

GH-115457: Support splitting and replication of micro ops. - #115558

Merged
markshannon merged 6 commits into
python:mainfrom
faster-cpython:split-on-oparg-1
Feb 20, 2024
Merged

GH-115457: Support splitting and replication of micro ops. #115558
markshannon merged 6 commits into
python:mainfrom
faster-cpython:split-on-oparg-1

Conversation

markshannon commented Feb 16, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Adds the split and replicate(N) annotations

split splits uops into two depending on the low bit of the oparg. This removes a few jumps from uops like _LOAD_ATTR_INSTANCE_VALUE.

replicate(N) replicates the original uop for each oparg in range(N). This is particularly valuable for uops that loop over oparg, but it is also useful to inline the oparg at build time rather than when patching.

Copy link
Copy Markdown
Member

Also, I like how clean this is in the DSL!

Copy link
Copy Markdown
Member Author

about 1% faster

Comment thread Python/optimizer.c
else if (oparg < _PyUop_Replication[opcode]) {
buffer[pc].opcode = opcode + oparg + 1;
}
else if (opcode == _JUMP_TO_TOP || opcode == _EXIT_TRACE) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Maybe use op_is_end here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It's a static function in another file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We'll leave it up to Ken Jin to turn it into a macro or static inline in a header. (Because he's adding another opcode that could end the list of opcodes, a new JUMP variant.)

Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good in general, just one minor comment.

properties=compute_properties(op),
)
if effect_depends_on_oparg_1(op) and "split" in op.annotations:
result.properties.oparg_and_1 = True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

For code consistency, shouldn't this be compute_properties?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Shouldn't what be compute_properties?

Fidget-Spinner Feb 19, 2024
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Woops I meant shouldn't this be computed in compute_properties ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The oparg_and_1 property only applies to the base uop, not the replicas as their behavior does not depend on oparg & 1. compute_properties computes the properties from the definition only, so we would need to modify oparg_and_1 anyway.

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Cool!

Comment thread Python/optimizer.c
else if (oparg < _PyUop_Replication[opcode]) {
buffer[pc].opcode = opcode + oparg + 1;
}
else if (opcode == _JUMP_TO_TOP || opcode == _EXIT_TRACE) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We'll leave it up to Ken Jin to turn it into a macro or static inline in a header. (Because he's adding another opcode that could end the list of opcodes, a new JUMP variant.)

Comment thread Python/executor_cases.c.h

encukou commented Feb 20, 2024
edited
Loading

Copy link
Copy Markdown
Member

The refleaks buildbot failed on test.test_capi.test_opt.TestUops.test_confidence_score. Likely causes: GH-114142, GH-115558, or GH-115688
I'll investigate later if it's not fixed; you probably have more context.

Edit: it's likely to be fixed in #115728

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL