Skip to content

Commit e43b050

Browse files
vtavanaantonwolfy
andauthored
Resolve crash identified in backend implementation of dpnp.choose (#2063) (#2068)
* Add memory copy to device memory * Keep extra memcopy only for the result array * Add missing memory copy from host to device memory * Applied pre-commit formatting * Updated changelog * Add empty line in changelog * Correct the description of issue in changelog Co-authored-by: Anton <[email protected]>
1 parent 377179a commit e43b050

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ In addition, this release completes implementation of `dpnp.fft` module and adds
113113
* Resolved an issue with failing tests for `dpnp.append` when running on a device without fp64 support [#2034](https://github.com/IntelPython/dpnp/pull/2034)
114114
* Resolved an issue with input array of `usm_ndarray` passed into `dpnp.ix_` [#2047](https://github.com/IntelPython/dpnp/pull/2047)
115115
* Added a workaround to prevent crash in tests on Windows in internal CI/CD (when running on either Lunar Lake or Arrow Lake) [#2062](https://github.com/IntelPython/dpnp/pull/2062)
116+
* Fixed a crash in `dpnp.choose` caused by missing control of releasing temporary allocated device memory [#2063](https://github.com/IntelPython/dpnp/pull/2063)
116117

117118

118119
## [0.15.0] - 05/25/2024

dpnp/backend/kernels/dpnp_krnl_indexing.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ DPCTLSyclEventRef dpnp_choose_c(DPCTLSyclQueueRef q_ref,
6363
DPNPC_ptr_adapter<_DataType1> input1_ptr(q_ref, array1_in, size);
6464
_DataType1 *array_in = input1_ptr.get_ptr();
6565

66-
DPNPC_ptr_adapter<_DataType2 *> choices_ptr(q_ref, choices1, choices_size);
66+
// choices1 is a list of pointers to device memory,
67+
// which is allocating on the host, so memcpy to device memory is required
68+
DPNPC_ptr_adapter<_DataType2 *> choices_ptr(q_ref, choices1, choices_size,
69+
true);
6770
_DataType2 **choices = choices_ptr.get_ptr();
6871

6972
for (size_t i = 0; i < choices_size; ++i) {
@@ -88,6 +91,7 @@ DPCTLSyclEventRef dpnp_choose_c(DPCTLSyclQueueRef q_ref,
8891
};
8992

9093
sycl::event event = q.submit(kernel_func);
94+
choices_ptr.depends_on(event);
9195

9296
event_ref = reinterpret_cast<DPCTLSyclEventRef>(&event);
9397

0 commit comments

Comments
 (0)