Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow importing numba-dpex even if no SYCL device is detected by dpctl #1272

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still have this? We need to completely nuke the old way of setting the kernel lauch parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. DEFAULT_LOCAL_SIZE is referenced in the vectorizers.py module. The vectorizers.py is badly broken and non functional at the moment that is why I did not remove the code from __init__.py. I am going to do that in a follow up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #1273 to keep track of the pending clean up.

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
Loading