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

Use different data models for DpnpNdArray Type for kernel and dpjit targets #1118

Merged
merged 2 commits into from
Aug 20, 2023

Conversation

diptorupd
Copy link
Contributor

  • Have you provided a meaningful PR description?

Previously, a dpnp.ndarray argument passed to a kernel function was passed as an instance of numba_dpex.core.types.USMNdArray. The USMNdArray type uses the numba_dpex.core.datamodel.models.USMArrayModel data model where pointers have an explicit address space qualifier.

The PR now registers the dpnp.ndarray-specific DpnpNdArray types with a USMArrayModel for the DpexKernelTarget and with the numba.core.datamodel.models.ArrayModel for the CPUTarget. By doing so, we now correctly recognize a dpnp.ndarray passed to a kernel as such instead of a generic USMNdArray object. The change unblocks the creation of a Numba-specific CPython wrapper for kernel functions as we need to use the correct Numba type to properly unbox and box a dpnp.ndarray.

Additionally, fixes a bug in numba_dpex.dpnp_iface.arrayobj.getitem_arraynd_intp that was found during testing.

  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • If this PR is a work in progress, are you filing the PR as a draft?

Diptorup Deb added 2 commits August 20, 2023 00:25
    - Previously, a dpnp.ndarray argument passed to a kernel function was
      passed as an instance of numba_dpex.core.types.USMNdArray.
      The USMNdArray type uses the numba_dpex.core.datamodel.models.USMArrayModel
      data model where pointers have an explicit address space qualifier.

      The changed code now registers the dpnp.ndarray-specific DpnpNdArray type
      with a USMArrayModel for the DpexKernelTarget and with the
      numba.core.datamodel.models.ArrayModel for the CPUTarget. By doing so, we now
      correctly recognize a dpnp.ndarray passed to a kernel as such instead of a generic
      USMNdArray object. The change unblocks the creation of a Numba-specific CPython
      wrapper for kernel functions as we need to use the correct Numba type to
      properly unbox and box a dpnp.ndarray.
    - The dpnp.ndarray overload for getitem_arraynd_intp involves
      updating the sycl_queue object when __getitem__ returns a
      view. The existing implementation was trying to do so even
      when __getitem__ returns a scalar.

      Adds an extra check to avoid the problem.
@diptorupd diptorupd force-pushed the fix/dpnp_data_model branch from addf4dc to 12c5c23 Compare August 20, 2023 05:25
@diptorupd diptorupd merged commit 2f006b9 into main Aug 20, 2023
@diptorupd diptorupd deleted the fix/dpnp_data_model branch August 20, 2023 06:28
github-actions bot added a commit that referenced this pull request Aug 20, 2023
Use different data models for DpnpNdArray Type for kernel and dpjit targets 2f006b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant