Skip to content

Commit

Permalink
Merge pull request #1272 from IntelPython/fix/import-dpex-even-withou…
Browse files Browse the repository at this point in the history
…t-sycl-devices

Allow importing numba-dpex even if no SYCL device is detected by dpctl
  • Loading branch information
Diptorup Deb authored Jan 9, 2024
2 parents 8c3cbed + 0034819 commit d12331e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 38 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ jobs:
NUMBA_DPEX_USE_MLIR: ${{ matrix.use_mlir && '1' || '0' }}
run: python -c "import dpnp, dpctl, numba_dpex; dpctl.lsplatform()"

- name: Smoke test - test import with no default device
env:
ONEAPI_DEVICE_SELECTOR: unknown:unknown
run: python -c "import numba_dpex"

- name: Run tests
if: ${{!matrix.run_gdb}}
env:
Expand Down
51 changes: 24 additions & 27 deletions numba_dpex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def parse_sem_version(version_string: str) -> Tuple[int, int, int]:
numba_sem_version = parse_sem_version(numba_version)
if numba_sem_version < (0, 57, 0) or numba_sem_version >= (0, 59, 0):
logging.warning(
"numba_dpex needs at lease numba 0.57.0 but no more than 0.59.0, using "
"numba_dpex needs at least numba 0.57.0 but no more than 0.59.0, using "
f"numba={numba_version} may cause unexpected behavior"
)

Expand Down Expand Up @@ -111,33 +111,30 @@ def parse_sem_version(version_string: str) -> Tuple[int, int, int]:
from numba_dpex.dpctl_iface import _intrinsic # noqa E402
from numba_dpex.dpnp_iface import dpnpimpl # noqa E402

if config.HAS_NON_HOST_DEVICE:
# Re export
from .core.targets import dpjit_target, kernel_target
from .decorators import dpjit, func, kernel
from .ocl.stubs import (
GLOBAL_MEM_FENCE,
LOCAL_MEM_FENCE,
atomic,
barrier,
get_global_id,
get_global_size,
get_group_id,
get_local_id,
get_local_size,
get_num_groups,
get_work_dim,
local,
mem_fence,
private,
sub_group_barrier,
)
from .core.targets import dpjit_target, kernel_target # noqa E402
from .decorators import dpjit, func, kernel # noqa E402
from .ocl.stubs import ( # noqa E402
GLOBAL_MEM_FENCE,
LOCAL_MEM_FENCE,
atomic,
barrier,
get_global_id,
get_global_size,
get_group_id,
get_local_id,
get_local_size,
get_num_groups,
get_work_dim,
local,
mem_fence,
private,
sub_group_barrier,
)

DEFAULT_LOCAL_SIZE = []
load_dpctl_sycl_interface()
del load_dpctl_sycl_interface

DEFAULT_LOCAL_SIZE = []
load_dpctl_sycl_interface()
del load_dpctl_sycl_interface
else:
raise ImportError("No non-host SYCL device found to execute kernels.")

Vectorize.target_registry.ondemand["dpex"] = lambda: DpexVectorize

Expand Down
11 changes: 0 additions & 11 deletions numba_dpex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ def __getattr__(name):
return getattr(config, name)


# Ensure dpctl can create a default sycl device.
# Set this config flag based on if dpctl is found or not.
# The config flags is used elsewhere inside Numba.
try:
HAS_NON_HOST_DEVICE = dpctl.select_default_device()
except Exception:
logging.exception(
"dpctl could not find any non-host SYCL device on the system. "
+ "A non-host SYCL device is required to use numba_dpex."
)

# To save intermediate files generated by th compiler
SAVE_IR_FILES = _readenv("NUMBA_DPEX_SAVE_IR_FILES", int, 0)

Expand Down

0 comments on commit d12331e

Please sign in to comment.