From d5f16803ea45ac15938369bc8a64105bc997f3bb Mon Sep 17 00:00:00 2001 From: Yevhenii Havrylko Date: Thu, 2 May 2024 13:13:56 -0400 Subject: [PATCH] Clean up unused code in parfors --- numba_dpex/core/parfors/compiler.py | 88 --------------------- numba_dpex/core/parfors/kernel_builder.py | 11 --- numba_dpex/core/parfors/parfor_lowerer.py | 1 - numba_dpex/core/parfors/reduction_helper.py | 4 - 4 files changed, 104 deletions(-) delete mode 100644 numba_dpex/core/parfors/compiler.py diff --git a/numba_dpex/core/parfors/compiler.py b/numba_dpex/core/parfors/compiler.py deleted file mode 100644 index 8864cc637c..0000000000 --- a/numba_dpex/core/parfors/compiler.py +++ /dev/null @@ -1,88 +0,0 @@ -# SPDX-FileCopyrightText: 2022 - 2024 Intel Corporation -# -# SPDX-License-Identifier: Apache-2.0 - -from numba.core import compiler, ir -from numba.core import types as numba_types -from numba.core.compiler_lock import global_compiler_lock - -from numba_dpex.core import config -from numba_dpex.core.exceptions import ( - KernelHasReturnValueError, - UnreachableError, -) -from numba_dpex.core.pipelines.kernel_compiler import KernelCompiler - - -@global_compiler_lock -def compile_numba_ir_with_dpex( - pyfunc, - pyfunc_name, - args, - return_type, - target_context, - typing_context, - debug=False, - is_kernel=True, - extra_compile_flags=None, -): - """ - Compiles a function using class:`numba_dpex.core.pipelines.KernelCompiler` - and returns the compiled result. - - Args: - args: The list of arguments passed to the kernel. - debug (bool): Optional flag to turn on debug mode compilation. - extra_compile_flags: Extra flags passed to the compiler. - - Returns: - cres: Compiled result. - - Raises: - KernelHasReturnValueError: If the compiled function returns a - non-void value. - """ - # First compilation will trigger the initialization of the backend. - typingctx = typing_context - targetctx = target_context - - flags = compiler.Flags() - # Do not compile the function to a binary, just lower to LLVM - flags.debuginfo = config.DEBUGINFO_DEFAULT - flags.no_compile = True - flags.no_cpython_wrapper = True - flags.no_cfunc_wrapper = True - flags.nrt = False - - if debug: - flags.debuginfo = debug - - # Run compilation pipeline - if isinstance(pyfunc, ir.FunctionIR): - cres = compiler.compile_ir( - typingctx=typingctx, - targetctx=targetctx, - func_ir=pyfunc, - args=args, - return_type=return_type, - flags=flags, - locals={}, - pipeline_class=KernelCompiler, - ) - else: - raise UnreachableError() - - if ( - is_kernel - and cres.signature.return_type is not None - and cres.signature.return_type != numba_types.void - ): - raise KernelHasReturnValueError( - kernel_name=pyfunc_name, - return_type=cres.signature.return_type, - ) - # Linking depending libraries - library = cres.library - library.finalize() - - return cres diff --git a/numba_dpex/core/parfors/kernel_builder.py b/numba_dpex/core/parfors/kernel_builder.py index 6f059c8452..23aa46c7f9 100644 --- a/numba_dpex/core/parfors/kernel_builder.py +++ b/numba_dpex/core/parfors/kernel_builder.py @@ -3,25 +3,18 @@ # SPDX-License-Identifier: Apache-2.0 import copy -import sys import warnings -import dpctl -import dpctl.program as dpctl_prog from numba.core import ir, types from numba.core.errors import NumbaParallelSafetyWarning from numba.core.ir_utils import ( - add_offset_to_labels, get_name_var_table, get_unused_var_name, legalize_names, mk_unique_var, - remove_dead, remove_dels, - rename_labels, replace_var_names, ) -from numba.core.target_extension import target_override from numba.core.typing import signature from numba.parfors import parfor @@ -32,15 +25,11 @@ ) from numba_dpex.core.types.kernel_api.index_space_ids import ItemType from numba_dpex.core.utils.call_kernel_builder import SPIRVKernelModule -from numba_dpex.kernel_api_impl.spirv import spirv_generator from numba_dpex.kernel_api_impl.spirv.dispatcher import ( SPIRVKernelDispatcher, _SPIRVKernelCompileResult, ) -from ..descriptor import dpex_kernel_target -from ..types import DpnpNdArray -from .compiler import compile_numba_ir_with_dpex from .kernel_templates.range_kernel_template import RangeKernelTemplate diff --git a/numba_dpex/core/parfors/parfor_lowerer.py b/numba_dpex/core/parfors/parfor_lowerer.py index 3eb39b2cf5..4610cf9ef4 100644 --- a/numba_dpex/core/parfors/parfor_lowerer.py +++ b/numba_dpex/core/parfors/parfor_lowerer.py @@ -3,7 +3,6 @@ # SPDX-License-Identifier: Apache-2.0 import copy -from collections import namedtuple from llvmlite import ir as llvmir from numba.core import cgutils, ir, types diff --git a/numba_dpex/core/parfors/reduction_helper.py b/numba_dpex/core/parfors/reduction_helper.py index cb9e189977..eeeff3e486 100644 --- a/numba_dpex/core/parfors/reduction_helper.py +++ b/numba_dpex/core/parfors/reduction_helper.py @@ -17,10 +17,6 @@ from numba.parfors import parfor from numba.parfors.parfor_lowering_utils import ParforLoweringBuilder -from numba_dpex.core.datamodel.models import ( - dpex_data_model_manager as kernel_dmm, -) -from numba_dpex.core.utils.call_kernel_builder import KernelLaunchIRBuilder from numba_dpex.core.utils.cgutils_extra import get_llvm_type from numba_dpex.dpctl_iface import libsyclinterface_bindings as sycl