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
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include MANIFEST.in
include README.md setup.py LICENSE

recursive-include numba_dppy *.cl

16 changes: 16 additions & 0 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%PYTHON% setup.py install --single-version-externally-managed --record=record.txt
if errorlevel 1 exit 1

echo "Activating oneAPI compiler environment..."
call "%ONEAPI_ROOT%\compiler\latest\env\vars.bat"
if errorlevel 1 exit 1
REM conda uses %ERRORLEVEL% but FPGA scripts can set it. So it should be reseted.
set ERRORLEVEL=

echo on

set "CC=clang.exe"

%CC% -flto -target spir64-unknown-unknown -c -x cl -emit-llvm -cl-std=CL2.0 -Xclang -finclude-default-header numba_dppy/ocl/atomics/atomic_ops.cl -o numba_dppy/ocl/atomics/atomic_ops.bc
llvm-spirv -o numba_dppy/ocl/atomics/atomic_ops.spir numba_dppy/ocl/atomics/atomic_ops.bc
xcopy numba_dppy\ocl\atomics\atomic_ops.spir %SP_DIR%\numba_dppy\ocl\atomics /E /Y
Comment on lines +14 to +16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move SPIRV compilation to setup.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 changes: 15 additions & 0 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

${PYTHON} setup.py install --single-version-externally-managed --record=record.txt


if [ ! -z "${ONEAPI_ROOT}" ]; then
source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh
export CC=clang
else
echo "DPCPP is needed to build OpenCL kernel. Abort!"
fi

${CC} -flto -target spir64-unknown-unknown -c -x cl -emit-llvm -cl-std=CL2.0 -Xclang -finclude-default-header numba_dppy/ocl/atomics/atomic_ops.cl -o numba_dppy/ocl/atomics/atomic_ops.bc
llvm-spirv -o numba_dppy/ocl/atomics/atomic_ops.spir numba_dppy/ocl/atomics/atomic_ops.bc
cp numba_dppy/ocl/atomics/atomic_ops.spir ${SP_DIR}/numba_dppy/ocl/atomics/
48 changes: 48 additions & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package:
name: numba-dppy
version: {{ GIT_DESCRIBE_TAG }}

source:
path: ..

build:
number: {{ GIT_DESCRIBE_NUMBER }}
script_env:
- ONEAPI_ROOT

requirements:
build:
- {{ compiler('cxx') }}
host:
- python
- setuptools
- cython
- llvm-spirv
- numba
- dpctl
run:
- python
- numba >=0.51
- dpctl
- spirv-tools
- llvm-spirv
- dpnp
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dpNP is optional dependency


about:
home: https://github.com/IntelPython/numba-dppy
license: BSD-2-Clause
license_file: LICENSE
summary: "Numba extension for Intel CPU and GPU backend"
description: |
<strong>LEGAL NOTICE: Use of this software package is subject to the
software license agreement (as set forth above, in the license section of
the installed Conda package and/or the README file) and all notices,
disclaimers or license terms for third party or open source software
included in or with the software.</strong>
<br/><br/>
EULA: <a href="https://opensource.org/licenses/BSD-2-Clause" target="_blank">BSD-2-Clause</a>
<br/><br/>
extra:
recipe-maintainers:
- PokhodenkoSA
4 changes: 4 additions & 0 deletions conda-recipe/run_test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
python -m numba.runtests -b -v -m -- numba_dppy.tests
IF %ERRORLEVEL% NEQ 0 exit /B 1

exit /B 0
7 changes: 7 additions & 0 deletions conda-recipe/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -ex

python -m numba.runtests -b -v -m -- numba_dppy.tests

exit 0
4 changes: 2 additions & 2 deletions numba_dppy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def foo(in, out):

---------------------------------------------------------------------------
import numpy as np
from numba import dppl
import numba_dppy, numba_dppy as dppl
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename dppl to dppy.

import dpctl

@dppl.kernel
Expand Down Expand Up @@ -516,4 +516,4 @@ def test(*args, **kwargs):
if not dppl_present and not is_available():
dppl_error()

return numba.testing.test("numba.dppl.tests", *args, **kwargs)
return numba.testing.test("numba_dppy.tests", *args, **kwargs)
2 changes: 1 addition & 1 deletion numba_dppy/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _finalize_specific(self):

def get_asm_str(self):
# Return nothing: we can only dump assembler code when it is later
# generated (in numba.dppl.compiler).
# generated (in numba_dppy.compiler).
return None


Expand Down
4 changes: 2 additions & 2 deletions numba_dppy/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#from numba.targets.descriptors import TargetDescriptor
#from numba.targets.options import TargetOptions
#from numba import dppl
from numba.dppl import kernel, autojit
#import numba_dppy, numba_dppy as dppl
from numba_dppy import kernel, autojit
from .descriptor import dppl_target
#from numba.npyufunc.deviceufunc import (UFuncMechanism, GenerializedUFunc,
# GUFuncCallSteps)
Expand Down
14 changes: 7 additions & 7 deletions numba_dppy/dppl_lowerer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from numba.core import (compiler, ir, types, sigutils, lowering,
funcdesc, config)
from numba.parfors import parfor
from numba import dppl
import numba_dppy, numba_dppy as dppl
from numba.core.ir_utils import (add_offset_to_labels,
replace_var_names,
remove_dels,
Expand Down Expand Up @@ -40,7 +40,7 @@
from .dufunc_inliner import dufunc_inliner
from . import dppl_host_fn_call_gen as dppl_call_gen
import dpctl
from numba.dppl.target import DPPLTargetContext
from numba_dppy.target import DPPLTargetContext


def _print_block(block):
Expand Down Expand Up @@ -329,7 +329,7 @@ def addrspace_from(params, def_addr):
return addrspaces

addrspaces = addrspace_from(parfor_params,
numba.dppl.target.SPIR_GLOBAL_ADDRSPACE)
numba_dppy.target.SPIR_GLOBAL_ADDRSPACE)

if config.DEBUG_ARRAY_OPT >= 1:
print("parfor_params = ", parfor_params, type(parfor_params))
Expand Down Expand Up @@ -607,7 +607,7 @@ def print_arg_with_addrspaces(args):
print('after DUFunc inline'.center(80, '-'))
gufunc_ir.dump()

kernel_func = numba.dppl.compiler.compile_kernel_parfor(
kernel_func = numba_dppy.compiler.compile_kernel_parfor(
dpctl.get_current_queue(),
gufunc_ir,
gufunc_param_types,
Expand Down Expand Up @@ -975,7 +975,7 @@ def relatively_deep_copy(obj, memo):
from numba.core.types.functions import Function, Dispatcher
from numba.core.bytecode import FunctionIdentity
from numba.core.typing.templates import Signature
from numba.dppl.compiler import DPPLFunctionTemplate
from numba_dppy.compiler import DPPLFunctionTemplate
from numba.core.compiler import CompileResult
from numba.np.ufunc.dufunc import DUFunc
from ctypes import _CFuncPtr
Expand Down Expand Up @@ -1169,7 +1169,7 @@ def lower(self):
self.base_lower = self.gpu_lower
lowering.lower_extensions[parfor.Parfor].pop()
except Exception as e:
if numba.dppl.compiler.DEBUG:
if numba_dppy.compiler.DEBUG:
print("Failed to lower parfor on DPPL-device. Due to:\n", e)
lowering.lower_extensions[parfor.Parfor].pop()
if (lowering.lower_extensions[parfor.Parfor][-1] == numba.parfors.parfor_lowering._lower_parfor_parallel):
Expand All @@ -1195,7 +1195,7 @@ def copy_block(block):
def lower_parfor_rollback(lowerer, parfor):
try:
_lower_parfor_gufunc(lowerer, parfor)
if numba.dppl.compiler.DEBUG:
if numba_dppy.compiler.DEBUG:
msg = "Parfor lowered on DPPL-device"
print(msg, parfor.loc)
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/dppl_offload_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DpplOffloadDispatcher(dispatcher.Dispatcher):

def __init__(self, py_func, locals={}, targetoptions={}, impl_kind='direct', pipeline_class=compiler.Compiler):
if dppl_config.dppl_present:
from numba.dppl.compiler import DPPLCompiler
from numba_dppy.compiler import DPPLCompiler
targetoptions['parallel'] = True
dispatcher.Dispatcher.__init__(self, py_func, locals=locals,
targetoptions=targetoptions, impl_kind=impl_kind, pipeline_class=DPPLCompiler)
Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/dppl_passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
def dpnp_available():
try:
# import dpnp
from numba.dppl.dpnp_glue import dpnp_fptr_interface as dpnp_glue
from numba_dppy.dpnp_glue import dpnp_fptr_interface as dpnp_glue
return True
except:
return False
Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/examples/dppl_func.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import numpy as np
from numba import dppl
import numba_dppy, numba_dppy as dppl
import math

import dpctl
Expand Down
3 changes: 2 additions & 1 deletion numba_dppy/examples/dppl_with_context.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
from numba import dppl, njit, prange
from numba import njit, prange
import numba_dppy, numba_dppy as dppl
import dpctl

@njit
Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/examples/matmul.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import sys
import numpy as np
from numba import dppl
import numba_dppy, numba_dppy as dppl
import dpctl


Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/examples/pairwise_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import argparse
import timeit

from numba import dppl
import numba_dppy, numba_dppy as dppl
import dpctl
import dpctl._memory as dpctl_mem

Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/examples/sum-hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import sys
import numpy as np
from numba import dppl
import numba_dppy, numba_dppy as dppl
import dpctl


Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/examples/sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import sys
import numpy as np
from numba import dppl
import numba_dppy, numba_dppy as dppl
import dpctl


Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/examples/sum2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import sys
import numpy as np
from numba import dppl
import numba_dppy, numba_dppy as dppl
import dpctl


Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/examples/sum_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import sys
import numpy as np
from numba import dppl
import numba_dppy, numba_dppy as dppl
import dpctl


Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/examples/sum_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import math
import time

from numba import dppl
import numba_dppy, numba_dppy as dppl
import dpctl


Expand Down
3 changes: 2 additions & 1 deletion numba_dppy/examples/sum_reduction_ocl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import numpy as np
from numba import dppl, int32
from numba import int32
import numba_dppy, numba_dppy as dppl
import math

import dpctl
Expand Down
3 changes: 2 additions & 1 deletion numba_dppy/examples/sum_reduction_recursive_ocl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import numpy as np
from numba import dppl, int32
from numba import int32
import numba_dppy, numba_dppy as dppl
import math

import dpctl
Expand Down
4 changes: 2 additions & 2 deletions numba_dppy/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@


def init_jit():
from numba.dppl.dispatcher import DPPLDispatcher
from numba_dppy.dispatcher import DPPLDispatcher
return DPPLDispatcher

def initialize_all():
from numba.core.registry import dispatcher_registry
dispatcher_registry.ondemand['dppl'] = init_jit
dispatcher_registry.ondemand['dppy'] = init_jit

import dpctl
import glob
Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/ocl/ocldecl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from numba.core.typing.templates import (AttributeTemplate, ConcreteTemplate,
AbstractTemplate, MacroTemplate,
signature, Registry)
from numba import dppl
import numba_dppy, numba_dppy as dppl

registry = Registry()
intrinsic = registry.register
Expand Down
4 changes: 2 additions & 2 deletions numba_dppy/ocl/oclimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from numba.core.imputils import Registry
from numba.core import cgutils, types
from numba.core.itanium_mangler import mangle_c, mangle, mangle_type
from numba.dppl import target
from numba_dppy import target
from . import stubs
from numba.dppl.codegen import SPIR_DATA_LAYOUT
from numba_dppy.codegen import SPIR_DATA_LAYOUT


registry = Registry()
Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/ocl/stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from numba.core import types, ir, typing
from numba.core.rewrites.macros import Macro

from numba.dppl.target import SPIR_LOCAL_ADDRSPACE
from numba_dppy.target import SPIR_LOCAL_ADDRSPACE

_stub_error = NotImplementedError("This is a stub.")

Expand Down
2 changes: 1 addition & 1 deletion numba_dppy/spirv_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tempfile

from numba import config
from numba.dppl.target import LINK_ATOMIC
from numba_dppy.target import LINK_ATOMIC


def _raise_bad_env_path(msg, path, extra=None):
Expand Down
6 changes: 3 additions & 3 deletions numba_dppy/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _init_data_model_manager():

def _replace_numpy_ufunc_with_opencl_supported_functions():
from numba.np.ufunc_db import _ufunc_db as ufunc_db
from numba.dppl.ocl.mathimpl import lower_ocl_impl, sig_mapper
from numba_dppy.ocl.mathimpl import lower_ocl_impl, sig_mapper

ufuncs = [("fabs", np.fabs), ("exp", np.exp), ("log", np.log),
("log10", np.log10), ("expm1", np.expm1), ("log1p", np.log1p),
Expand All @@ -97,7 +97,7 @@ class DPPLTargetContext(BaseContext):
context_name = "dppl.jit"

def init(self):
self._internal_codegen = codegen.JITSPIRVCodegen("numba.dppl.jit")
self._internal_codegen = codegen.JITSPIRVCodegen("numba_dppy.jit")
self._target_data = (ll.create_target_data(codegen
.SPIR_DATA_LAYOUT[utils.MACHINE_BITS]))
# Override data model manager to SPIR model
Expand All @@ -118,7 +118,7 @@ def init(self):


def replace_numpy_ufunc_with_opencl_supported_functions(self):
from numba.dppl.ocl.mathimpl import lower_ocl_impl, sig_mapper
from numba_dppy.ocl.mathimpl import lower_ocl_impl, sig_mapper

ufuncs = [("fabs", np.fabs), ("exp", np.exp), ("log", np.log),
("log10", np.log10), ("expm1", np.expm1), ("log1p", np.log1p),
Expand Down
Loading