Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/rvsdg_frontend' into mis…
Browse files Browse the repository at this point in the history
…c/merge_main_2

Reset unneeded changes to the buildscripts
These files are changed by apply git reset origin/main FILES
  • Loading branch information
sklam committed Aug 10, 2023
2 parents 4605995 + 54e3a6a commit 0fc40ca
Show file tree
Hide file tree
Showing 15 changed files with 2,850 additions and 10 deletions.
5 changes: 3 additions & 2 deletions buildscripts/azure/azure-linux-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ jobs:
- script: |
set -e
export PATH=$HOME/miniconda3/bin:$PATH
conda install -y mypy
mypy
# using conda-forge because main only have version < 1.0
conda create -n mypy311 -y -c conda-forge python=3.11 mypy
conda run -n mypy311 mypy
displayName: 'Mypy'
condition: eq(variables['RUN_MYPY'], 'yes')
Expand Down
8 changes: 8 additions & 0 deletions docs/source/reference/envvars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,14 @@ Compilation options

*Default value:* "all"

.. envvar:: NUMBA_USE_RVSDG_FRONTEND

Turns on the experimental RVSDG frontend. It depends on the ``numba-rvsdg``
package and only supports Python 3.11 partially.
This option will be removed when the RVSDG frontend fully replaces the
old frontend.

*Default value:* 0 (Off)

.. _numba-envvars-caching:

Expand Down
8 changes: 8 additions & 0 deletions docs/upcoming_changes/9012.new_feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

Added RVSDG-frontend
====================

This PR is a preliminary work on adding a RVSDG-frontend for processing
bytecode. RVSDG (Regionalized Value-State Dependence Graph) allows us to
have a dataflow-centric view instead of a traditional SSA-CFG view. This
allows us to simplify the compiler in the future.
8 changes: 7 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
warn_unused_configs = True
follow_imports = silent
show_error_context = True
files = **/numba/core/types/*.py, **/numba/core/datamodel/*.py, **/numba/core/rewrites/*.py, **/numba/core/unsafe/*.py
files = **/numba/core/types/*.py, **/numba/core/datamodel/*.py, **/numba/core/rewrites/*.py, **/numba/core/unsafe/*.py, **/numba/core/rvsdg_frontend/*.py, **/numba/core/rvsdg_frontend/rvsdg/*.py

# Per-module options:
# To classify a given module as Level 1, 2 or 3 it must be added both in files (variable above) and in the lists below.
Expand Down Expand Up @@ -50,3 +50,9 @@ ignore_missing_imports = True
[mypy-winreg.*]
# this can be removed after Mypy 0.78 is out with the latest typeshed
ignore_missing_imports = True

[mypy-numba_rvsdg.*]
ignore_missing_imports = True

[mypy-graphviz.*]
ignore_missing_imports = True
2 changes: 1 addition & 1 deletion numba/core/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def find_branches(func_ir):
if isinstance(branch_or_jump, ir.Branch):
branch = branch_or_jump
pred = guard(get_definition, func_ir, branch.cond.name)
if pred is not None and pred.op == "call":
if pred is not None and getattr(pred, "op", None) == "call":
function = guard(get_definition, func_ir, pred.func)
if (function is not None and
isinstance(function, ir.Global) and
Expand Down
16 changes: 12 additions & 4 deletions numba/core/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
CanonicalizeLoopEntry, LiteralUnroll,
ReconstructSSA, RewriteDynamicRaises,
LiteralPropagationSubPipelinePass,
RVSDGFrontend,
)

from numba.core.typed_passes import (NopythonTypeInference, AnnotateTypes,
Expand Down Expand Up @@ -661,10 +662,17 @@ def define_parfor_gufunc_pipeline(state, name="parfor_gufunc_typed"):
def define_untyped_pipeline(state, name='untyped'):
"""Returns an untyped part of the nopython pipeline"""
pm = PassManager(name)
if state.func_ir is None:
pm.add_pass(TranslateByteCode, "analyzing bytecode")
pm.add_pass(FixupArgs, "fix up args")
pm.add_pass(IRProcessing, "processing IR")
if config.USE_RVSDG_FRONTEND:
if state.func_ir is None:
pm.add_pass(RVSDGFrontend, "rvsdg frontend")
pm.add_pass(FixupArgs, "fix up args")
pm.add_pass(IRProcessing, "processing IR")
else:
if state.func_ir is None:
pm.add_pass(TranslateByteCode, "analyzing bytecode")
pm.add_pass(FixupArgs, "fix up args")
pm.add_pass(IRProcessing, "processing IR")

pm.add_pass(WithLifting, "Handle with contexts")

# inline closures early in case they are using nonlocal's
Expand Down
3 changes: 3 additions & 0 deletions numba/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ def _readenv(name, ctor, default):
def optional_str(x):
return str(x) if x is not None else None

# RVSDG frontend selection
USE_RVSDG_FRONTEND = _readenv("NUMBA_USE_RVSDG_FRONTEND", int, 0)

# developer mode produces full tracebacks, disables help instructions
DEVELOPER_MODE = _readenv("NUMBA_DEVELOPER_MODE", int, 0)

Expand Down
Empty file.

0 comments on commit 0fc40ca

Please sign in to comment.