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

Improve error reporting when searching for dpctl. #368

Merged
merged 3 commits into from
May 20, 2021

Conversation

diptorupd
Copy link
Contributor

@diptorupd diptorupd commented May 18, 2021

The PR improves the user warnings that are printed when a required version of dpctl is not found. There are three things that are checked for numba_dppy to set the dppy_found flag:

  1. import dpctl does not raise an error.
  2. The dpctl version is at least 0.7.0.
  3. The dpctl.select_default_device().is_host returns False, i.e., there is at least one non-host SYCL device.

Closes #219.

@diptorupd
Copy link
Contributor Author

diptorupd commented May 18, 2021

@PokhodenkoSA At least some of the UserWarning can be tested if we set these two environment variables: SYCL_DEVICE_FILTER=host and SYCL_ENABLE_HOST_DEVICE=1. Trying to import numba_dppy after setting these two environment variables will trigger the dpctl could not find any non-host SYCL device... warning. I can trigger it in normal Python. Do you know how to set environment variables in Pytest fixtures? I tried the following test case but that did not work:

import pytest
import os


def test_import_numba_dppy_with_only_host_device():
    with pytest.warns(
        UserWarning, match=r"dpctl could not find any non-host SYCL device"
    ):
        try:
            old_environ = dict(os.environ)
            os.environ["SYCL_DEVICE_FILTER"] = "host"
            os.environ["SYCL_ENABLE_HOST_DEVICE"] = "1"
            import numba_dppy
        except ImportError:
            pass
        finally:
            os.environ.clear()
            os.environ.update(old_environ)

numba_dppy/config.py Outdated Show resolved Hide resolved
@diptorupd diptorupd merged commit bb6268e into main May 20, 2021
@diptorupd diptorupd deleted the fix/improve_import_error_msg branch May 20, 2021 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dpctl Integration with dpctl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants