Skip to content

Commit

Permalink
Merge pull request #858 from IntelPython/fix/dpctl_compatibility
Browse files Browse the repository at this point in the history
Bump dpctl version requirement to 0.14 and fix issue caused by API change
  • Loading branch information
diptorupd authored Jan 7, 2023
2 parents 511a3c5 + 61c46f1 commit a541db5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 35 deletions.
4 changes: 2 additions & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ requirements:
- setuptools
- cython
- numba 0.56*
- dpctl >=0.13.0
- dpctl >=0.14*
- dpnp >=0.11*
- wheel
run:
- python
- numba >=0.56*
- dpctl >=0.13.0
- dpctl >=0.14*
- spirv-tools
- llvm-spirv 11.*
- dpnp >=0.11*
Expand Down
26 changes: 10 additions & 16 deletions numba_dpex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0

import imp
import logging
import os
import warnings

from numba.core import config

Expand All @@ -15,25 +14,23 @@ def _ensure_dpctl():
"""
from numba_dpex.dpctl_support import dpctl_version

if dpctl_version < (0, 8):
raise ImportError("numba_dpex needs dpctl 0.8 or greater")
if dpctl_version < (0, 14):
raise ImportError("numba_dpex needs dpctl 0.14 or greater")


def _dpctl_has_non_host_device():
"""
Make sure dpctl has non-host SYCL devices on the system.
Ensure dpctl can create a default sycl device
"""
import dpctl

# For the numba_dpex extension to work, we should have at least one
# non-host SYCL device installed.
# FIXME: In future, we should support just the host device.
if not dpctl.select_default_device().is_host:
try:
dpctl.select_default_device()
return True
else:
except Exception:
msg = "dpctl could not find any non-host SYCL device on the system. "
msg += "A non-host SYCL device is required to use numba_dpex."
warnings.warn(msg, UserWarning)
logging.exception(msg)
return False


Expand All @@ -57,11 +54,8 @@ def _readenv(): ...
try:
return ctor(value)
except Exception:
import warnings

warnings.warn(
"environ %s defined but failed to parse '%s'" % (name, value),
RuntimeWarning,
logging.exception(
"environ %s defined but failed to parse '%s'" % (name, value)
)
return default

Expand Down
17 changes: 0 additions & 17 deletions numba_dpex/device_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,4 @@
from .core import target
from .decorators import autojit, func, kernel


def is_available():
"""Returns a boolean indicating if dpctl could find a default device.
A ValueError is thrown by dpctl if no default device is found and it
implies that numba_dpex cannot create a SYCL queue to compile kernels.
Returns:
bool: True if a default SYCL device is found, otherwise False.
"""
try:
d = dpctl.select_default_device()
return not d.is_host
except ValueError:
return False


initialize.load_dpctl_sycl_interface()

0 comments on commit a541db5

Please sign in to comment.