Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign numba-dpex test suite #1018

Merged
merged 21 commits into from
Apr 28, 2023
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
38 changes: 32 additions & 6 deletions numba_dpex/tests/core/runtime/test_llvm_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@


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

"""Checks if the functions in the _dpexrt_python module are accessible
using llvmlite.
"""
assert (
llb.address_of_symbol("DPEXRT_sycl_usm_ndarray_from_python")
Expand All @@ -29,3 +25,33 @@ def test_llvm_symbol_registered():
llb.address_of_symbol("NRT_ExternalAllocator_new_for_usm")
== runtime._dpexrt_python.NRT_ExternalAllocator_new_for_usm
)

assert (
llb.address_of_symbol("DPEXRT_sycl_queue_from_python")
== runtime._dpexrt_python.DPEXRT_sycl_queue_from_python
)

assert (
llb.address_of_symbol("DPEXRT_sycl_queue_to_python")
== runtime._dpexrt_python.DPEXRT_sycl_queue_to_python
)

assert (
llb.address_of_symbol("DPEXRTQueue_CreateFromFilterString")
== runtime._dpexrt_python.DPEXRTQueue_CreateFromFilterString
)

assert (
llb.address_of_symbol("DpexrtQueue_SubmitRange")
== runtime._dpexrt_python.DpexrtQueue_SubmitRange
)

assert (
llb.address_of_symbol("DPEXRT_MemInfo_alloc")
== runtime._dpexrt_python.DPEXRT_MemInfo_alloc
)

assert (
llb.address_of_symbol("DPEXRT_MemInfo_fill")
== runtime._dpexrt_python.DPEXRT_MemInfo_fill
)
17 changes: 0 additions & 17 deletions numba_dpex/tests/core/runtime/test_nrt_python.py

This file was deleted.

18 changes: 0 additions & 18 deletions numba_dpex/tests/core/runtime/test_runtime.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import dpctl
import pytest

from numba_dpex.core.types import USMNdArray

"""Negative tests for expected exceptions raised during USMNdArray creation.

"""


def test_default_type_construction():
"""Tests call USMNdArray constructor with no device or queue args."""
usma = USMNdArray(1, queue=None)

assert usma.ndim == 1
assert usma.layout == "C"
assert usma.addrspace == 1
assert usma.usm_type == "device"

default_device = dpctl.SyclDevice()
cached_queue = dpctl.get_device_cached_queue(default_device)

assert usma.device == default_device.filter_string
assert usma.queue == cached_queue


def test_type_creation_with_device():
"""Tests creating a USMNdArray with a device arg and no queue"""

default_device_str = dpctl.SyclDevice().filter_string

usma = USMNdArray(1, device=default_device_str, queue=None)

assert usma.ndim == 1
assert usma.layout == "C"
assert usma.addrspace == 1
assert usma.usm_type == "device"

assert usma.device == default_device_str

cached_queue = dpctl.get_device_cached_queue(default_device_str)

assert usma.queue == cached_queue


def test_type_creation_with_queue():
"""Tests creating a USMNdArray with a queue arg and no device"""
queue = dpctl.SyclQueue()
usma = USMNdArray(1, queue=queue)

assert usma.ndim == 1
assert usma.layout == "C"
assert usma.addrspace == 1
assert usma.usm_type == "device"

assert usma.device == queue.sycl_device.filter_string
assert usma.queue == queue


def test_exception_when_both_device_and_queue_arg_specified():
"""Tests if TypeError is raised when both queue and device specified"""

queue = dpctl.SyclQueue()
with pytest.raises(TypeError):
USMNdArray(1, device="cpu", queue=queue)


def test_improper_queue_type():
"""Tests if TypeError is raised if queue argument is of invalid type"""

with pytest.raises(TypeError):
USMNdArray(1, queue="cpu")


def test_improper_device_type():
"""Tests if TypeError is raised if device argument is of invalid type"""

with pytest.raises(TypeError):
USMNdArray(1, device=0)
49 changes: 0 additions & 49 deletions numba_dpex/tests/integration/DuckUSMArray.py

This file was deleted.

41 changes: 0 additions & 41 deletions numba_dpex/tests/integration/test_dpnp_interop.py

This file was deleted.

80 changes: 0 additions & 80 deletions numba_dpex/tests/integration/test_sycl_usm_array_iface_interop.py

This file was deleted.

Loading