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

Added submit_keep_args_alive #1395

Merged
merged 13 commits into from
Oct 24, 2023
Merged

Conversation

oleksandr-pavlyk
Copy link
Collaborator

@oleksandr-pavlyk oleksandr-pavlyk commented Sep 7, 2023

Added dpctl.SyclQueue._submit_keep_args_alive(args, events) that increments reference count of args object (typically a sequence of arguments an asynchronous task is operating on), ensuring that args object is not garbage collected until after events signal that tasks working on these objects complete their execution.

  • 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?
  • If this PR is a work in progress, are you opening the PR as a draft?

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch 2 times, most recently from 3a92246 to 19b628e Compare September 15, 2023 20:40
@github-actions
Copy link

@coveralls
Copy link
Collaborator

coveralls commented Sep 15, 2023

Coverage Status

coverage: 85.763% (+0.06%) from 85.701% when pulling 10722d4 on async-ref-count-increment into 1d57614 on master.

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev5=py310ha25a700_9 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev5=py310ha25a700_10 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev5=py310ha25a700_12 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev5=py310ha25a700_13 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev5=py310ha25a700_15 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev5=py310ha25a700_16 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch from 6daca36 to 1b393d4 Compare September 19, 2023 14:09
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.15.0rc1=py310ha25a700_14 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch 2 times, most recently from 4c8ae59 to bb473da Compare September 22, 2023 02:07
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.15.0rc1=py310ha25a700_30 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@oleksandr-pavlyk oleksandr-pavlyk marked this pull request as ready for review September 22, 2023 22:35
@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch from bb473da to 7c51f2f Compare September 23, 2023 21:54
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.15.0rc2=py310ha25a700_17 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch from 11b92bb to 7c51f2f Compare September 25, 2023 22:21
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.15.0rc2=py310ha25a700_24 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.15.0rc2=py310ha25a700_25 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch from 7c51f2f to 7f79887 Compare September 27, 2023 15:19
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.15.0rc3=py310ha25a700_13 ran successfully.
Passed: 916
Failed: 84
Skipped: 119

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch from 7f79887 to e303eaa Compare October 5, 2023 20:54
oleksandr-pavlyk added a commit to oleksandr-pavlyk/async-pipelining-example that referenced this pull request Oct 5, 2023
This is an adaptation of pipelining technique shared by @mbecker
in https://github.com/IntelPython/numbda_dpex/issues/147

This is built to work with async-ref-count-increment branch
IntelPython/dpctl#1395 which implements
asynchronous memcpy, asynchronous submit and asynchronous
keep_arg_alve task submission.
@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Array API standard conformance tests for dpctl=0.15.1dev0=py310ha25a700_16 ran successfully.
Passed: 935
Failed: 65
Skipped: 119

@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Array API standard conformance tests for dpctl=0.15.1dev0=py310ha25a700_17 ran successfully.
Passed: 935
Failed: 65
Skipped: 119

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch from f822827 to ed67ac8 Compare October 6, 2023 01:51
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Array API standard conformance tests for dpctl=0.15.1dev0=py310ha25a700_18 ran successfully.
Passed: 935
Failed: 65
Skipped: 119

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch from ed67ac8 to 802ead7 Compare October 6, 2023 16:22
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Array API standard conformance tests for dpctl=0.15.1dev0=py310ha25a700_19 ran successfully.
Passed: 935
Failed: 65
Skipped: 119

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.15.1dev0=py310ha25a700_44 ran successfully.
Passed: 935
Failed: 65
Skipped: 119

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch from 5b3643c to cebd7f9 Compare October 14, 2023 20:25
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.15.1dev0=py310ha25a700_53 ran successfully.
Passed: 935
Failed: 65
Skipped: 119

Usage:
   q = dpctl.SyclQueue()
   ...
   e = q.submit(krn, args, ranges)
   ht_e = q._submit_keep_args_alive(args, [e])
   ....
   ht_e.wait()
Instead delegated the task of Python object life-time management
to the user via use of _submit_keep_args_alive method
The SyclQueue.submit has become synchronosing, although
it still returns a SyclEvent (with exectuion_status always complete)
This is the copy operation where one can specify list of events the
copy operation requires before start of its execution.

DPCTLQueue_MemcpyWithEvents(
   __dpctl_keep DPCTLSyclQueueRef QRef,
   void *dst,
   const void *src,
   size_t nbytes,
   const DPCTLSyclEventRef *depEvents,
   size_t nDE
)

Uses this function in tests.
Also extends `dpctl.SyclQueue.memcpy` to allow arguments to be objects
that expose buffer protocol, allowing `dpctl.SyclQueue.memcpy` and
`dpctl.SyclQueue.memcpy_async` to be used to copy from/to USM-allocation
or host buffer.
```

In [9]: timer = dpctl.SyclTimer()

In [10]: with timer(q):
    ...:     y = dpt.linspace(1, 2, num=10**6, sycl_queue=q)
    ...:

In [11]: timer.dt
Out[11]: (0.0022024469999450957, 0.002116712)

In [12]: with timer(q):
    ...:     x = dpt.linspace(0, 1, num=10**6, sycl_queue=q)
    ...:

In [13]: timer.dt
Out[13]: (0.004531950999989931, 0.004239664000000001)
```
The object can unpack into a tuple, like before, but it prints
with annotation of what each number means, and provides names
getters.

  with timer(q):
      code

  dur = timer.dt
  print(dur)     # outputs (host_dt=..., device_dt=...)
  dur.host_dt    # get host-timer delta
  dur.device_dt  # get device-timer delta
  hdt, ddt = dur # unpack into a tuple
@oleksandr-pavlyk
Copy link
Collaborator Author

I tested numba_dpex test suite with dpctl from this PR, and all tests passed.

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the async-ref-count-increment branch from cebd7f9 to 10722d4 Compare October 17, 2023 20:57
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.15.1dev0=py310ha25a700_56 ran successfully.
Passed: 935
Failed: 65
Skipped: 119

@oleksandr-pavlyk oleksandr-pavlyk merged commit 26b9c92 into master Oct 24, 2023
26 checks passed
@oleksandr-pavlyk oleksandr-pavlyk deleted the async-ref-count-increment branch October 24, 2023 00:16
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.

2 participants