Skip to content

Commit b8999a4

Browse files
authored
Backprt gh-2333 (#2343)
This PR backports of #2333 from development branch to `maintenance/0.17.x`.
1 parent 9271917 commit b8999a4

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Furthermore, a number of issues relating to running on NVIDIA GPUs have been res
103103
* Resolved an issue with wrong result returned by `dpnp.tensordot` for integer data types [#2296](https://github.com/IntelPython/dpnp/pull/2296)
104104
* Resolved `ValueError` exception raised by `dpnp.linalg.qr` with non-contiguous input array [#2314](https://github.com/IntelPython/dpnp/pull/2314)
105105
* Resolved an issue with wrong result returned by `dpnp.fft.fftn` and `dpnp.fft.rfftn` when running on NVIDIA GPU [#2332](https://github.com/IntelPython/dpnp/pull/2332)
106+
* Added a workaround to prevent a memory corruption in `dpnp.correlate` [#2333](https://github.com/IntelPython/dpnp/pull/2333)
106107

107108

108109
## [0.16.1] - 12/06/2024

dpnp/backend/extensions/statistics/sliding_window1d.hpp

+29-7
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ class PaddedSpan : public Span<T, SizeT>
436436
using size_type = SizeT;
437437

438438
PaddedSpan(T *const data, const SizeT size, const SizeT pad)
439-
: Span<T>(data, size), pad_(pad)
439+
: Span<T, SizeT>(data, size), pad_(pad)
440440
{
441441
}
442442

@@ -574,9 +574,20 @@ void submit_sliding_window1d(const PaddedSpan<const T, SizeT> &a,
574574
}
575575

576576
auto *const out_ptr = out.begin();
577-
auto *const out_end = out.end();
578-
results.store(&out_ptr[glid],
579-
[out_end](auto &&ptr) { return ptr < out_end; });
577+
// auto *const out_end = out.end();
578+
579+
auto y_start = glid;
580+
auto y_stop =
581+
std::min(y_start + WorkPI * results.size_x(), out.size());
582+
uint32_t i = 0;
583+
for (uint32_t y = y_start; y < y_stop; y += results.size_x()) {
584+
out_ptr[y] = results[i++];
585+
}
586+
// while the code itself seems to be valid, inside correlate
587+
// kernel it results in memory corruption. Further investigation
588+
// is needed. SAT-7693
589+
// corruption results.store(&out_ptr[glid],
590+
// [out_end](auto &&ptr) { return ptr < out_end; });
580591
});
581592
}
582593

@@ -635,9 +646,20 @@ void submit_sliding_window1d_small_kernel(const PaddedSpan<const T, SizeT> &a,
635646
red);
636647

637648
auto *const out_ptr = out.begin();
638-
auto *const out_end = out.end();
639-
results.store(&out_ptr[glid],
640-
[out_end](auto &&ptr) { return ptr < out_end; });
649+
// auto *const out_end = out.end();
650+
651+
auto y_start = glid;
652+
auto y_stop =
653+
std::min(y_start + WorkPI * results.size_x(), out.size());
654+
uint32_t i = 0;
655+
for (uint32_t y = y_start; y < y_stop; y += results.size_x()) {
656+
out_ptr[y] = results[i++];
657+
}
658+
// while the code itself seems to be valid, inside correlate
659+
// kernel it results in memory corruption. Further investigation
660+
// is needed. SAT-7693
661+
// corruption results.store(&out_ptr[glid],
662+
// [out_end](auto &&ptr) { return ptr < out_end; });
641663
});
642664
}
643665

dpnp/tests/test_usm_type.py

-3
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,6 @@ def test_1in_1out(func, data, usm_type):
800800
@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
801801
@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
802802
def test_2in_1out(func, data1, data2, usm_type_x, usm_type_y):
803-
if func == "correlate" and is_win_platform():
804-
pytest.skip("due to SAT-7693")
805-
806803
x = dp.array(data1, usm_type=usm_type_x)
807804
y = dp.array(data2, usm_type=usm_type_y)
808805
z = getattr(dp, func)(x, y)

0 commit comments

Comments
 (0)