Skip to content

Commit

Permalink
Merge pull request #1018 from IntelPython/redesign/test_suite
Browse files Browse the repository at this point in the history
Redesign numba-dpex test suite
  • Loading branch information
Diptorup Deb authored Apr 28, 2023
2 parents 000d5cd + 5655ab7 commit 094f852
Show file tree
Hide file tree
Showing 44 changed files with 572 additions and 1,348 deletions.
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)
File renamed without changes.
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

0 comments on commit 094f852

Please sign in to comment.