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

Add usm_ndarray creation c-api #1050

Merged
merged 7 commits into from
Feb 3, 2023

Conversation

oleksandr-pavlyk
Copy link
Collaborator

@oleksandr-pavlyk oleksandr-pavlyk commented Jan 30, 2023

Closes #1049

This PR adds 3 new C-API for usm_ndarray:

  • void UsmNDArray_SetWritableFlag(usm_array arr, int flag) : Set WRITABLE flag of arr if bool(flag) is True, and clears it otherwise
  • object UsmNDArray_MakeFromMemory(int nd, const Py_ssize_t *shape, int typenum, c_dpmem._Memory memobj, Py_ssize_t offset): create usm_ndarray of given shape and data-type from USM-memory object and offset
  • object UsmNDArray_MakeFromPtr(size_t nelems, int typenum, DPCTLSyclUSMRef ptr, DPCTLSyclQueueRef QRef, object owner): create 1D usm_ndarray of requested data-type from pointer and queue reference; owner=None is interpreter as transfer of memory ownership, and memory will be deallocated once the usm_ndarray instance is deleted. If owner is not None, deleter of usm_ndarray instance will call the deleter of owner which is supposed to clean up the USM allocation. The owner object must thus capture the pointer and the queue reference, or the context to make the correct call to sycl::free.

ctypes-based tests are added to the test-suite.

New C-API functions are added to dpctl::detail::dpctl_capi singleton class, but are yet unused.

  • 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?

@samir-nasibli

@github-actions
Copy link

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_55 ran successfully.
Passed: 33
Failed: 801
Skipped: 280

@coveralls
Copy link
Collaborator

coveralls commented Jan 30, 2023

Coverage Status

Coverage: ?%. Remained the same when pulling 5145923 on add-usm-ndarray-creation-c-api into d144118 on master.

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_56 ran successfully.
Passed: 33
Failed: 801
Skipped: 280

@oleksandr-pavlyk
Copy link
Collaborator Author

Right now UsmNDArray_MakeFromMemory creates a C-contiguous array. Should the api allow for order keyword?

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the add-usm-ndarray-creation-c-api branch from e471c15 to f40d7e6 Compare February 1, 2023 19:42
@github-actions
Copy link

github-actions bot commented Feb 1, 2023

Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_59 ran successfully.
Passed: 33
Failed: 801
Skipped: 280

@github-actions
Copy link

github-actions bot commented Feb 1, 2023

Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_60 ran successfully.
Passed: 33
Failed: 801
Skipped: 280

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the add-usm-ndarray-creation-c-api branch from ea67d57 to 5145923 Compare February 1, 2023 21:24
@github-actions
Copy link

github-actions bot commented Feb 1, 2023

Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_64 ran successfully.
Passed: 33
Failed: 801
Skipped: 280

@oleksandr-pavlyk oleksandr-pavlyk merged commit 61430eb into master Feb 3, 2023
@oleksandr-pavlyk oleksandr-pavlyk deleted the add-usm-ndarray-creation-c-api branch February 3, 2023 00:34
@github-actions
Copy link

github-actions bot commented Feb 3, 2023

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

@github-actions
Copy link

github-actions bot commented Feb 3, 2023

Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_70 ran successfully.
Passed: 33
Failed: 801
Skipped: 280

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.

Add C-API function UsmNDArray_MakeFromMemory and UsmNDArray_SetWritableFlag
2 participants