Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Diptorup Deb committed Oct 24, 2023
1 parent 981ec0a commit 81f631a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions numba_dpex/tests/experimental/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
40 changes: 40 additions & 0 deletions numba_dpex/tests/experimental/test_kernel_dispatcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# SPDX-FileCopyrightText: 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

import dpctl
import dpnp

import numba_dpex.experimental as exp_dpex
from numba_dpex import NdRange, Range, config, dpjit


@exp_dpex.kernel(
release_gil=False,
no_compile=True,
no_cpython_wrapper=True,
no_cfunc_wrapper=True,
)
def add(a, b, c):
c[0] = b[0] + a[0]


def test_call_kernel_from_cpython():
"""
Negative test to verify that NumPy arrays cannot be passed to a kernel.
"""

q = dpctl.SyclQueue("gpu")
a = dpnp.ones(100, sycl_queue=q)
b = dpnp.ones_like(a, sycl_queue=q)
c = dpnp.zeros_like(a, sycl_queue=q)
r = Range(100)
ndr = NdRange(global_size=(100,), local_size=(1,))

exp_dpex.call_kernel(add, r, a, b, c)

assert c[0] == b[0] + a[0]

exp_dpex.call_kernel(add, ndr, a, b, c)

assert c[0] == b[0] + a[0]

0 comments on commit 81f631a

Please sign in to comment.