Skip to content

Commit f758ae3

Browse files
committed
[oneDPL][ranges][merge][dpcpp] + out_of_bounds fix
1 parent 8ca24c2 commit f758ae3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,9 @@ struct __parallel_merge_submitter<_IdType, __internal::__optional_kernel_name<_N
200200
auto __id = __item_id.get_linear_id();
201201
const _IdType __i_elem = __id * __chunk;
202202

203-
const auto __start =
204-
__find_start_point(__rng1, _IdType{0}, __n1, __rng2, _IdType{0}, __n2, __i_elem, __comp);
205-
__serial_merge(__rng1, __rng2, __rng3, __start.first, __start.second, __i_elem, __chunk, __n1, __n2,
206-
__comp);
203+
const auto __n_merge = std::min<_IdType>(__chunk, __n - __i_elem);
204+
const auto __start = __find_start_point(__rng1, _IdType{0}, __n1, __rng2, _IdType{0}, __n2, __i_elem, __comp);
205+
__serial_merge(__rng1, __rng2, __rng3, __start.first, __start.second, __i_elem, __n_merge, __n1, __n2,
207206

208207
if(__id == __steps - 1) //the last WI does additional work
209208
{

0 commit comments

Comments
 (0)