-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
162 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from .._helper import * | ||
from . import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
import llvmlite.binding as llb | ||
|
||
from numba_dpex.core import runtime | ||
|
||
|
||
def test_llvm_symbol_registered(): | ||
""" "Register the helper function in _dpexrt_python so that we can insert calls to them via llvmlite. | ||
1. DPEXRT_sycl_usm_ndarray_from_python | ||
2.DPEXRT_sycl_usm_ndarray_to_python_acqref | ||
""" | ||
assert ( | ||
llb.address_of_symbol("DPEXRT_sycl_usm_ndarray_from_python") | ||
== runtime._dpexrt_python.DPEXRT_sycl_usm_ndarray_from_python | ||
) | ||
|
||
assert ( | ||
llb.address_of_symbol("DPEXRT_sycl_usm_ndarray_to_python_acqref") | ||
== runtime._dpexrt_python.DPEXRT_sycl_usm_ndarray_to_python_acqref | ||
) | ||
|
||
assert ( | ||
llb.address_of_symbol("NRT_ExternalAllocator_new_for_usm") | ||
== runtime._dpexrt_python.NRT_ExternalAllocator_new_for_usm | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
from numba_dpex.core.runtime import _dpexrt_python | ||
|
||
|
||
def test_pointers_exposed(): | ||
"""This test is to check attributts in _dpexrt_python.""" | ||
|
||
def exposed(function_name): | ||
assert hasattr(_dpexrt_python, function_name) | ||
assert isinstance(getattr(_dpexrt_python, function_name), int) | ||
|
||
exposed("DPEXRT_sycl_usm_ndarray_from_python") | ||
exposed("DPEXRT_sycl_usm_ndarray_to_python_acqref") | ||
exposed("DPEXRT_MemInfo_alloc") | ||
exposed("NRT_ExternalAllocator_new_for_usm") |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2020 - 2022 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""Tests for class DpexTargetContext.""" | ||
|
||
|
||
import pytest | ||
from numba.core import typing | ||
from numba.core.codegen import JITCPUCodegen | ||
|
||
from numba_dpex.core.targets.dpjit_target import DpexTargetContext | ||
|
||
ctx = typing.Context() | ||
dpexctx = DpexTargetContext(ctx) | ||
|
||
|
||
def test_dpjit_target(): | ||
assert dpexctx.lower_extensions == {} | ||
assert dpexctx.is32bit is False | ||
assert dpexctx.dpexrt is not None | ||
assert ( | ||
isinstance(dpexctx._internal_codegen, type(JITCPUCodegen("numba.exec"))) | ||
== 1 | ||
) | ||
|
||
|
||
def test_dpjit_target_refresh(): | ||
try: | ||
dpexctx.refresh | ||
except KeyError: | ||
pytest.fail("Unexpected KeyError in dpjit_target.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from .._helper import * | ||
from . import * |
36 changes: 36 additions & 0 deletions
36
numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty_dpjit.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""Tests for dpnp ndarray constructors.""" | ||
|
||
import dpnp | ||
import pytest | ||
|
||
from numba_dpex import dpjit | ||
|
||
shapes = [10, (2, 5)] | ||
dtypes = [dpnp.int32, dpnp.int64, dpnp.float32, dpnp.float64] | ||
usm_types = ["device", "shared", "host"] | ||
devices = ["cpu", "unknown"] | ||
|
||
|
||
@pytest.mark.parametrize("shape", shapes) | ||
@pytest.mark.parametrize("dtype", dtypes) | ||
@pytest.mark.parametrize("usm_type", usm_types) | ||
@pytest.mark.parametrize("device", devices) | ||
def test_dpnp_empty(shape, dtype, usm_type, device): | ||
@dpjit | ||
def func(shape): | ||
dpnp.empty(shape=shape, dtype=dtype, usm_type=usm_type, device=device) | ||
|
||
@dpjit | ||
def func1(shape): | ||
c = dpnp.empty( | ||
shape=shape, dtype=dtype, usm_type=usm_type, device=device | ||
) | ||
return c | ||
|
||
func(shape) | ||
|
||
func1(shape) |
28 changes: 0 additions & 28 deletions
28
numba_dpex/tests/njit_tests/dpnp_ndarray/test_dpnp_empty.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""This is to test USMNdArray raising correct exceptions.""" | ||
|
||
import dpnp | ||
import pytest | ||
from numba import njit | ||
from numba.core.errors import TypingError | ||
|
||
from numba_dpex.dpctl_iface import get_current_queue | ||
|
||
arguments = [ | ||
("shape=10", 'device="cpu"', "queue=a.sycl_queue"), | ||
("shape=10", "device=10", "queue=a.sycl_queue"), | ||
("shape=10", 'device="cpu"', "queue=test"), | ||
("shape=10", 'device="dpu"'), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("argument", arguments) | ||
def test_usm_ndarray_type_exceptions(argument): | ||
a = dpnp.ndarray(10) | ||
|
||
@njit | ||
def func(a): | ||
dpnp.empty(argument) | ||
|
||
with pytest.raises(TypingError): | ||
func(a) |