Skip to content

Commit

Permalink
Add DPEX_OPT config and do not use numba's OPT
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzEeKkAa committed Oct 5, 2023
1 parent 39b5a5c commit e112e88
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
8 changes: 8 additions & 0 deletions numba_dpex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,11 @@ def __getattr__(name):
# Flag to turn on the ConstantSizeStaticLocalMemoryPass in the kernel pipeline.
# The pass is turned off by default.
STATIC_LOCAL_MEM_PASS = _readenv("NUMBA_DPEX_STATIC_LOCAL_MEM_PASS", int, 0)

DPEX_OPT = _readenv("NUMBA_DPEX_OPT", int, 2)

if DPEX_OPT:
logging.warning(
"Setting NUMBA_DPEX_OPT greater than 2 known to cause issues related "
+ "to very aggressive optimizations that leads to broken code"
)
7 changes: 4 additions & 3 deletions numba_dpex/core/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ def _optimize_final_module(self):
# Run some lightweight optimization to simplify the module.
pmb = ll.PassManagerBuilder()

# Make optimization level depending on config.OPT variable
pmb.opt_level = config.OPT
# Make optimization level depending on config.DPEX_OPT variable
pmb.opt_level = config.DPEX_OPT

pmb.disable_unit_at_a_time = False
pmb.inlining_threshold = 2
# TODO: investigate why it causes issues
# pmb.inlining_threshold = 2
pmb.disable_unroll_loops = True
pmb.loop_vectorize = False
pmb.slp_vectorize = False
Expand Down
2 changes: 1 addition & 1 deletion numba_dpex/core/kernel_interface/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(
self._kernel_bundle_cache = NullCache()
self._cache_hits = 0

if debug_flags or config.OPT == 0:
if debug_flags or config.DPEX_OPT == 0:
# if debug is ON we need to pass additional
# flags to igc.
self._create_sycl_kernel_bundle_flags = ["-g", "-cl-opt-disable"]
Expand Down
2 changes: 1 addition & 1 deletion numba_dpex/core/parfors/kernel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _compile_kernel_parfor(
)

dpctl_create_program_from_spirv_flags = []
if debug or config.OPT == 0:
if debug or config.DPEX_OPT == 0:
# if debug is ON we need to pass additional flags to igc.
dpctl_create_program_from_spirv_flags = ["-g", "-cl-opt-disable"]

Expand Down

0 comments on commit e112e88

Please sign in to comment.