-
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.
Adds compute follows data check to KernelDispatcher
- Added checks for compute follows data compliance to kernel compilation. - Removed support for __get_item__ in KernelDispatcher - Address review comments.
- Loading branch information
Showing
3 changed files
with
143 additions
and
43 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
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
90 changes: 90 additions & 0 deletions
90
numba_dpex/tests/experimental/test_exec_queue_inference.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,90 @@ | ||
# SPDX-FileCopyrightText: 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
import dpctl | ||
import dpnp | ||
import pytest | ||
|
||
import numba_dpex.experimental as exp_dpex | ||
from numba_dpex import Range | ||
from numba_dpex.core.exceptions import ExecutionQueueInferenceError | ||
|
||
|
||
@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_successful_execution_queue_inference(): | ||
""" | ||
Tests if KernelDispatcher successfully infers the execution queue for the | ||
kernel. | ||
""" | ||
|
||
q = dpctl.SyclQueue() | ||
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) | ||
|
||
# FIXME: This test fails unexpectedly if the NUMBA_CAPTURED_ERRORS is set | ||
# to "new_style" | ||
try: | ||
exp_dpex.call_kernel(add, r, a, b, c) | ||
except: | ||
pytest.fail("Unexpected error when calling kernel") | ||
|
||
assert c[0] == b[0] + a[0] | ||
|
||
|
||
def test_execution_queue_inference_error(): | ||
""" | ||
Tests if KernelDispatcher successfully raised ExecutionQueueInferenceError | ||
when dpnp.ndarray arguments do not share the same dpctl.SyclQueue | ||
instance. | ||
""" | ||
|
||
q1 = dpctl.SyclQueue() | ||
q2 = dpctl.SyclQueue() | ||
a = dpnp.ones(100, sycl_queue=q1) | ||
b = dpnp.ones_like(a, sycl_queue=q2) | ||
c = dpnp.zeros_like(a, sycl_queue=q1) | ||
r = Range(100) | ||
|
||
from numba.core import config | ||
|
||
current_captured_error_style = config.CAPTURED_ERRORS | ||
config.CAPTURED_ERRORS = "new_style" | ||
|
||
with pytest.raises(ExecutionQueueInferenceError): | ||
exp_dpex.call_kernel(add, r, a, b, c) | ||
|
||
config.CAPTURED_ERRORS = current_captured_error_style | ||
|
||
|
||
def test_error_when_no_array_args(): | ||
""" | ||
Tests if KernelDispatcher successfully raised ExecutionQueueInferenceError | ||
when no dpnp.ndarray arguments were passed to a kernel. | ||
""" | ||
a = 1 | ||
b = 2 | ||
c = 3 | ||
r = Range(100) | ||
|
||
from numba.core import config | ||
|
||
current_captured_error_style = config.CAPTURED_ERRORS | ||
config.CAPTURED_ERRORS = "new_style" | ||
|
||
with pytest.raises(ExecutionQueueInferenceError): | ||
exp_dpex.call_kernel(add, r, a, b, c) | ||
|
||
config.CAPTURED_ERRORS = current_captured_error_style |