Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 5 additions & 6 deletions src/numba/openmp/analysis.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from numba.core import ir, types, typing
from numba.core.analysis import _fix_loop_exit, compute_cfg_from_blocks
from numba.core.ir_utils import visit_vars
from numba.extending import overload, intrinsic
from numba.extending import intrinsic


def remove_ssa(var_name, scope, loc):
Expand Down Expand Up @@ -115,11 +115,10 @@ def get_var_from_enclosing(enclosing_regions, var):


def remove_indirections(clause):
try:
while len(clause) == 1 and isinstance(clause[0], list):
clause = clause[0]
except:
pass
if not isinstance(clause, list):
return clause
while len(clause) == 1 and isinstance(clause[0], list):
clause = clause[0]
return clause


Expand Down
11 changes: 3 additions & 8 deletions src/numba/openmp/omp_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,12 @@ def extract_args_from_openmp(func_ir):
try:
visit_res = visitor.transform(parse_res)
inst.value.args.extend([var_table[x] for x in visit_res])
except Exception as f:
print("generic transform exception")
except Exception as e:
print(f"generic transform exception: {e}")
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print(exc_type, fname, exc_tb.tb_lineno)
# print("Internal error for OpenMp pragma '{}'".format(arg.value))
sys.exit(-2)
except BaseException as e:
print("fallthrough exception")
# print("Internal error for OpenMp pragma '{}'".format(arg.value))
sys.exit(-3)


def remove_empty_blocks(blocks):
Expand Down Expand Up @@ -188,7 +183,7 @@ def mutate_with_body(
dispatcher_factory,
extra,
):
if _OpenmpContextType.first_time == True:
if _OpenmpContextType.first_time:
_OpenmpContextType.first_time = False
self.do_numba_fixups()

Expand Down
24 changes: 6 additions & 18 deletions src/numba/openmp/omp_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def update_context(self, context, builder):

if (
not hasattr(cctyp, "pyomp_patch_installed")
or cctyp.pyomp_patch_installed == False
or not cctyp.pyomp_patch_installed
):
cctyp.pyomp_patch_installed = True
# print("update_context", "id(cctyp.return_user_exec)", id(cctyp.return_user_exc), "id(context)", id(context))
Expand Down Expand Up @@ -779,7 +779,7 @@ def pyomp_return_status_propagate(self, builder, *args, **kwargs):

if (
not hasattr(cemtyp, "pyomp_patch_installed")
or cemtyp.pyomp_patch_installed == False
or not cemtyp.pyomp_patch_installed
):
cemtyp.pyomp_patch_installed = True
# print("update_context", "id(cemtyp.return_user_exec)", id(cemtyp.fp_zero_division), "id(context)", id(context))
Expand All @@ -799,7 +799,7 @@ def pyomp_fp_zero_division(self, builder, *args, **kwargs):

if (
not hasattr(ptyp, "pyomp_patch_installed")
or ptyp.pyomp_patch_installed == False
or not ptyp.pyomp_patch_installed
):
ptyp.pyomp_patch_installed = True
# print("update_context", "id(ptyp.emit_environment_sentry)", id(ptyp.emit_environment_sentry), "id(context)", id(context))
Expand Down Expand Up @@ -838,7 +838,6 @@ def fix_dispatchers(self, typemap, typingctx, cuda_target):
typemap[k] = v

def lower(self, lowerer):
typingctx = lowerer.context.typing_context
targetctx = lowerer.context
typemap = lowerer.fndesc.typemap
calltypes = lowerer.fndesc.calltypes
Expand Down Expand Up @@ -920,7 +919,6 @@ def add_struct_tags(self, var_table):
assert isinstance(cur_tag_var, str)
cur_tag_typ = typemap_lookup(typemap, cur_tag_var)
if isinstance(cur_tag_typ, types.npytypes.Array):
cur_tag_ndim = cur_tag_typ.ndim
stride_typ = lowerer.context.get_value_type(
types.intp
) # lir.Type.int(64)
Expand Down Expand Up @@ -1082,7 +1080,7 @@ def add_struct_tags(self, var_table):
for extra in extras_before:
lowerer.lower_inst(extra)

elif target_num is not None and self.target_copy != True:
elif target_num is not None and not self.target_copy:
var_table = get_name_var_table(lowerer.func_ir.blocks)

ompx_attrs = list(
Expand All @@ -1108,7 +1106,7 @@ def add_struct_tags(self, var_table):
for otag in self.tags:
print("tag in target:", otag, type(otag.arg))

from numba.core.compiler import Compiler, Flags
from numba.core.compiler import Flags

if DEBUG_OPENMP >= 1:
print("openmp start region lower has target", type(lowerer.func_ir))
Expand Down Expand Up @@ -1220,7 +1218,6 @@ def fixup_openmp_pairs(blocks):
print("fndesc:", fndesc, type(fndesc))
print("func_ir type:", type(func_ir))
dprint_func_ir(func_ir, "target func_ir")
internal_codegen = targetctx._internal_codegen

# Find the start and end IR blocks for this offloaded region.
start_block, end_block = find_target_start_end(func_ir, target_num)
Expand Down Expand Up @@ -1585,10 +1582,6 @@ def prepend_device_to_func_name(outlined_ir):
id(func_ir.blocks[k].body),
)

shared_ext = ".so"
if sys.platform.startswith("win"):
shared_ext = ".dll"

# TODO: move device pipelines in numba proper.
if selected_device == 1:
if DEBUG_OPENMP >= 1:
Expand Down Expand Up @@ -1911,12 +1904,7 @@ def list_vars(self):
return list_vars_from_tags(self.tags)

def lower(self, lowerer):
typingctx = lowerer.context.typing_context
targetctx = lowerer.context
typemap = lowerer.fndesc.typemap
context = lowerer.context
builder = lowerer.builder
library = lowerer.library

if DEBUG_OPENMP >= 2:
print("openmp_region_end::lower", id(self), id(self.start_region))
Expand All @@ -1941,7 +1929,7 @@ def lower(self, lowerer):
# Process the accumulated allocas in the start region.
self.start_region.process_alloca_queue()

assert self.start_region.omp_region_var != None
assert self.start_region.omp_region_var is not None
if DEBUG_OPENMP >= 2:
print(
"before adding exit", self.start_region.omp_region_var._get_name()
Expand Down
Loading
Loading