Skip to content

Commit a1e0027

Browse files
AlexanderKalistratovantonwolfy
authored andcommitted
Fixing memory corruption in correlate kernel (#2333)
- [x] Have you provided a meaningful PR description? - [x] Have you added a test, reproducer or referred to issue with a reproducer? - [x] Have you tested your changes locally for CPU and GPU devices? - [x] Have you made sure that new changes do not introduce compiler warnings? - [ ] Have you checked performance impact of proposed changes? - [x] If this PR is a work in progress, are you filing the PR as a draft? Temporary workaround for memory corruption inside correlate kernel. The root cause is still unknown, but the workaround seems to solve crashes
1 parent 90740ae commit a1e0027

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

dpnp/backend/extensions/statistics/sliding_window1d.hpp

Lines changed: 29 additions & 7 deletions
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

Lines changed: 0 additions & 3 deletions
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)