Skip to content

Added support for stream other than None#906

Merged
oleksandr-pavlyk merged 2 commits intomasterfrom
dlpack-use-of-stream
Sep 13, 2022
Merged

Added support for stream other than None#906
oleksandr-pavlyk merged 2 commits intomasterfrom
dlpack-use-of-stream

Conversation

@oleksandr-pavlyk
Copy link
Copy Markdown
Contributor

If stream keyword argument has type dpctl.SyclQueue, then submit a barrier into self.sycl_queue, and than submit another barrier into stream with dependency on the event returned by submission of the barrier into self.sycl_queue:

   ev = self.sycl_queue.submit_barrier()
   stream.submit_barrier(dependent_events=[ev])

All other types of stream are ignored, in particular integer values of stream.

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

--

With this PR, MPI transfer of usm_ndarray allocated using level-zero backend becomes possible:

from mpi4py import MPI
import dpctl.tensor as dpt
import numpy as np

comm = MPI.COMM_WORLD
rank = comm.Get_rank()

# automatic MPI datatype discovery
if rank == 0:
    data = dpt.arange(100, dtype="float64")
    comm.Send(data, dest=1, tag=13)
elif rank == 1:
    data = dpt.empty(100, dtype="float64")
    comm.Recv(data, source=0, tag=13)
    X = dpt.asnumpy(data)
    print("From rank=1, received: ", X)

The example run using mpi4py built using Intel(R) MPI from oneAPI basekit:

$ I_MPI_OFFLOAD=2 mpirun -n 2 python mpi_exchange.py
From rank=1, received:  [ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9. 10. 11. 12. 13. 14. 15. 16. 17.
 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35.
 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53.
 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71.
 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89.
 90. 91. 92. 93. 94. 95. 96. 97. 98. 99.]

If `stream` keyword argument has type `dpctl.SyclQueue`, then submit
a barrier into `self.sycl_queue`, and than submit another barrier into
stream with dependency on the event returned by submission
of the barrier into `self.sycl_queue`:

```python
   ev = self.sycl_queue.submit_barrier()
   stream.submit_barrier(dependent_events=[ev])
```

All other types of stream are ignored, in particular integer
values of stream.
@github-actions
Copy link
Copy Markdown

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Sep 11, 2022

Coverage Status

Coverage increased (+0.02%) to 81.888% when pulling b79b4b1 on dlpack-use-of-stream into 3d79ef9 on master.

@github-actions
Copy link
Copy Markdown

Array API standard conformance tests failed to run for dpctl=0.14.0dev0=py310h8c27c75_80.

@github-actions
Copy link
Copy Markdown

Array API standard conformance tests failed to run for dpctl=0.14.0dev0=py310h8c27c75_81.

@oleksandr-pavlyk oleksandr-pavlyk merged commit 0b2180a into master Sep 13, 2022
@oleksandr-pavlyk oleksandr-pavlyk deleted the dlpack-use-of-stream branch September 13, 2022 13:54
@github-actions
Copy link
Copy Markdown

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

@github-actions
Copy link
Copy Markdown

Array API standard conformance tests failed to run for dpctl=0.14.0dev0=py310h8c27c75_81.

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