8000 GH-113464: Generate a more efficient JIT by brandtbucher · Pull Request #118512 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-113464: Generate a more efficient JIT #118512

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

Merged
merged 18 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move C initializer formation to StencilGroup
  • Loading branch information
brandtbucher committed May 1, 2024
commit 7aa12a2c3e3d3e11cad07f59cecb35b9e45e63c2
4 changes: 4 additions & 0 deletions Tools/jit/_stencils.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ def _emit_global_offset_table(self) -> None:
)
self.data.body.extend([0] * 8)

def as_c(self, opname: str) -> str:
"""Dump this hole as a StencilGroup initializer."""
return f"{{emit_{opname}, {len(self.code.body)}, {len(self.data.body)}}}"


def symbol_to_value(symbol: str) -> tuple[HoleValue, str | None]:
"""
Expand Down
7 changes: 2 additions & 5 deletions Tools/jit/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import _stencils

def _initialize_stencil_group(opname: str, group: _stencils.StencilGroup) -> str:
return f"{{emit_{opname}, {len(group.code.body)}, {len(group.data.body)}}}"

def _dump_footer(groups: dict[str, _stencils.StencilGroup]) -> typing.Iterator[str]:
yield "typedef struct {"
Expand All @@ -17,14 +15,13 @@ def _dump_footer(groups: dict[str, _stencils.StencilGroup]) -> typing.Iterator[s
yield " size_t data_size;"
yield "} StencilGroup;"
yield ""
initializer = _initialize_stencil_group('trampoline', groups['trampoline'])
yield f"static const StencilGroup trampoline = {initializer};"
yield f"static const StencilGroup trampoline = {groups['trampoline'].as_c('trampoline')};"
yield ""
yield "static const StencilGroup stencil_groups[MAX_UOP_ID + 1] = {"
for opname, group in sorted(groups.items()):
if opname == "trampoline":
continue
yield f" [{opname}] = {_initialize_stencil_group(opname, group)},"
yield f" [{opname}] = {group.as_c(opname)},"
yield "};"


Expand Down
0