Skip to content

Fixing memory corruption #2333

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

Merged
merged 5 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions dpnp/backend/extensions/statistics/sliding_window1d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class PaddedSpan : public Span<T, SizeT>
using size_type = SizeT;

PaddedSpan(T *const data, const SizeT size, const SizeT pad)
: Span<T>(data, size), pad_(pad)
: Span<T, SizeT>(data, size), pad_(pad)
{
}

Expand Down Expand Up @@ -574,9 +574,20 @@ void submit_sliding_window1d(const PaddedSpan<const T, SizeT> &a,
}

auto *const out_ptr = out.begin();
auto *const out_end = out.end();
results.store(&out_ptr[glid],
[out_end](auto &&ptr) { return ptr < out_end; });
// auto *const out_end = out.end();

auto y_start = glid;
auto y_stop =
std::min(y_start + WorkPI * results.size_x(), out.size());
uint32_t i = 0;
for (uint32_t y = y_start; y < y_stop; y += results.size_x()) {
out_ptr[y] = results[i++];
}
// while the code itself seems to be valid, inside correlate
// kernel it results in memory corruption. Further investigation
// is needed. SAT-7693
// corruption results.store(&out_ptr[glid],
// [out_end](auto &&ptr) { return ptr < out_end; });
});
}

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

auto *const out_ptr = out.begin();
auto *const out_end = out.end();
results.store(&out_ptr[glid],
[out_end](auto &&ptr) { return ptr < out_end; });
// auto *const out_end = out.end();

auto y_start = glid;
auto y_stop =
std::min(y_start + WorkPI * results.size_x(), out.size());
uint32_t i = 0;
for (uint32_t y = y_start; y < y_stop; y += results.size_x()) {
out_ptr[y] = results[i++];
}
// while the code itself seems to be valid, inside correlate
// kernel it results in memory corruption. Further investigation
// is needed. SAT-7693
// corruption results.store(&out_ptr[glid],
// [out_end](auto &&ptr) { return ptr < out_end; });
});
}

Expand Down
3 changes: 0 additions & 3 deletions dpnp/tests/test_usm_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,6 @@ def test_1in_1out(func, data, usm_type):
@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
def test_2in_1out(func, data1, data2, usm_type_x, usm_type_y):
if func == "correlate" and is_win_platform():
pytest.skip("due to SAT-7693")

x = dp.array(data1, usm_type=usm_type_x)
y = dp.array(data2, usm_type=usm_type_y)
z = getattr(dp, func)(x, y)
Expand Down
Loading