Skip to content
1 change: 1 addition & 0 deletions src/numba/openmp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ def _safe_readenv(name, ctor, default):
OPENMP_DISABLED = _safe_readenv("NUMBA_OPENMP_DISABLED", int, 0)
# Use toolchain for device code compilation by default to avoid issues with libomptarget compatibility checks.
OPENMP_DEVICE_TOOLCHAIN = _safe_readenv("NUMBA_OPENMP_DEVICE_TOOLCHAIN", int, 1)
SMART_PRIVATIZE = _safe_readenv("NUMBA_SMART_PRIVATIZE", int, 0)
15 changes: 9 additions & 6 deletions src/numba/openmp/omp_lower.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import sys
import os

from .config import DEBUG_OPENMP
from .config import DEBUG_OPENMP, SMART_PRIVATIZE
from .parser import openmp_parser
from .analysis import (
remove_ssa,
Expand Down Expand Up @@ -304,7 +304,10 @@ def should_be_firstprivate(var_name):

# All private variables (user-defined and compiler-generated)
for var_name in sorted(private_to_region):
add_clause(var_name, "QUAL.OMP.PRIVATE")
if SMART_PRIVATIZE or is_internal_var(ir.Var(scope, var_name, self.loc)):
add_clause(var_name, "QUAL.OMP.PRIVATE")
else:
add_clause(var_name, "QUAL.OMP.SHARED")

def make_implicit_explicit_target(
self,
Expand Down Expand Up @@ -649,7 +652,7 @@ def get_loops_in_region(all_loops):
)

deconstruct_indices = []
new_deconstruct_var = new_var_scope.redefine("deconstruct", self.loc)
new_deconstruct_var = new_var_scope.redefine("$deconstruct", self.loc)
deconstruct_indices.append(
ir.Assign(loop_bounds[-1][1], new_deconstruct_var, self.loc)
)
Expand All @@ -665,15 +668,15 @@ def get_loops_in_region(all_loops):
operator.floordiv, new_deconstruct_var, cur_iterspace_var, self.loc
)
new_deconstruct_var_loop = new_var_scope.redefine(
"deconstruct" + str(deconstruct_index), self.loc
"$deconstruct" + str(deconstruct_index), self.loc
)
deconstruct_indices.append(
ir.Assign(deconstruct_div, cur_loop_bound, self.loc)
)
# if DEBUG_OPENMP >= 1:
# deconstruct_indices.append(ir.Print([cur_loop_bound], None, self.loc))
new_deconstruct_var_mul = new_var_scope.redefine(
"deconstruct_mul" + str(deconstruct_index), self.loc
"$deconstruct_mul" + str(deconstruct_index), self.loc
)
deconstruct_indices.append(
ir.Assign(
Expand Down Expand Up @@ -935,7 +938,7 @@ def _get_loop_kind(func_var, call_table):
if latest_index.name not in vars_in_explicit_clauses:
new_index_clause = openmp_tag(
"QUAL.OMP.PRIVATE",
ir.Var(loop_index.scope, latest_index.name, inst.loc),
latest_index.name,
)
clauses.append(new_index_clause)
vars_in_explicit_clauses[latest_index.name] = new_index_clause
Expand Down
Loading
Loading