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

Expose LocalAccessor as kernel argument type #1991

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

oleksandr-pavlyk
Copy link
Collaborator

This PR adds _md_local_accessor Cython struct in _backend.pxd that ties to MDLocalAccessor struct defined in libsyclinterface, and which is to be used to indicate local_accessor kernel argument type (see test file in syclinterface library).

_sycl_queue.pyx then defines LocalAccessor type, constructible using LocalAccessor(ndim, typestr, dim0, dim1, dim2) constuctor. The ndim argument represents accessor dimensionality (only values 1, 2, or 3 are supported). The typestr can be "i1", "u1", "i2", "u2", "i4", "u4", "i8", "u8", "f4", or "f8"`.

  • Have you provided a meaningful PR description?
  • 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?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?
  • If this PR is a work in progress, are you opening the PR as a draft?

Copy link

Copy link

Array API standard conformance tests for dpctl=0.19.0dev0=py310h93fe807_518 ran successfully.
Passed: 894
Failed: 2
Skipped: 118

Copy link

Array API standard conformance tests for dpctl= ran successfully.
Passed: 894
Failed: 2
Skipped: 118

@coveralls
Copy link
Collaborator

coveralls commented Feb 17, 2025

Coverage Status

coverage: 88.067% (-0.2%) from 88.232%
when pulling f35e483 on add-md-local-accessor
into c6b00c7 on master.

Copy link

Array API standard conformance tests for dpctl=0.19.0dev0=py310h93fe807_540 ran successfully.
Passed: 894
Failed: 2
Skipped: 118

self.lacc.dpctl_type_id = _arg_data_type._UINT64_T
elif type == 'f4':
self.lacc.dpctl_type_id = _arg_data_type._FLOAT
elif type == 'f8':
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that the FP8 format is gaining traction and there is a micro-scaling FP4 format, I find the naming here confusing.
Why don't we follow the naming scheme of numpy for types?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Which naming scheme do you mean? NumPy does accept kind + size in bytes, unless you mean using f for float32 specifically and d for float64 specifically.

I think we would preferably support both, so it would be a good change to make it more flexible.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking about the name returned by dtype, like "float64" in this example here:

a = np.array([1, 2], dtype=float)
a.dtype == np.dtype(np.float64)
a.dtype == np.float64
a.dtype == float
a.dtype == "float64"
a.dtype == "d"

But you're right, the numpy scheme for specifying types matches what we have here, so we can just keep that.

It also aligns with what is used in other places in DPCTL, so makes sense to keep it consistent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I do think it's sensible to support addition dtype strings ("float32", "float64") and possibly NumPy's char names ("f", "d").

It may even be sensible to expose the dpctl dtype enumerators in the dpctl namespace as enums (not dtype objects like in tensor) and add them as possible arguments, but this may be better saved for a subsequent PR. Another thought being that this could be re-used for a typed work_group_memory overload

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, an enumeration for the possible dtypes would be useful, if we need it in multiple places, such as typed work_group_memory overload. But I agree, this can be done in a follow-up PR.

oleksandr-pavlyk and others added 5 commits February 27, 2025 00:31
…uments

LocalAccessor(ndim, elemental_type_str, dim0, dim1, dim2)

The elemental type can be one of the following:
 "i1", "u1", "i2", "u2", "i4", "u4", "i8", "u8", "f4", "f8"
Fixes conflict with built-in `type`
@ndgrigorian ndgrigorian force-pushed the add-md-local-accessor branch from ff43ac7 to e1e4b00 Compare February 27, 2025 08:38
Copy link

Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_11 ran successfully.
Passed: 894
Failed: 2
Skipped: 118

@ndgrigorian ndgrigorian force-pushed the add-md-local-accessor branch from e1e4b00 to 949571b Compare February 27, 2025 19:14
Copy link

Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_11 ran successfully.
Passed: 893
Failed: 3
Skipped: 118

@ndgrigorian ndgrigorian force-pushed the add-md-local-accessor branch from 949571b to f35e483 Compare February 27, 2025 22:22
Copy link

Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_11 ran successfully.
Passed: 896
Failed: 1
Skipped: 125

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.

4 participants