Skip to content
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

Fix performance issue in __serial_merge #2022

Merged
merged 20 commits into from
Jan 27, 2025

Conversation

SergeyKopienko
Copy link
Contributor

@SergeyKopienko SergeyKopienko commented Jan 27, 2025

This is the second attempt of #2013: the source compile error has been introduced in the PR #1970
Example of the source compile error: https://godbolt.org/z/x6z7GMv1W

In the PR #2013 I detected performance issue.

The goal of this PR - to use ternary operator when it's possible.

Checks on GodBold:

  1. https://godbolt.org/z/6zPcWEMsn - implementation with __assing_impl
  2. https://godbolt.org/z/fdsPdoPz3 - implementation without __assing_impl

Thanks to @MikeDvorskiy and @dmitriy-sobolev for their implementations of __can_use_ternary_op_v !

…fix __serial_merge implementation: using ternary operator / assign operator with SFINAE
…fix __serial_merge implementation: using ternary operator / assign operator with SFINAE
@SergeyKopienko SergeyKopienko marked this pull request as ready for review January 27, 2025 11:50
…fix __serial_merge implementation: using ternary operator / assign operator with SFINAE
…fix __serial_merge implementation: using ternary operator / assign operator with SFINAE
…optimize condition check sue it's always calculated from left to right
…rge.h - remove __assing_impl function"

 - reverted due compile errors in https://github.com/uxlfoundation/oneDPL/actions/runs/12988989427/job/36221124714?pr=2022
oneDPL\include\oneapi\dpl\pstl\hetero\dpcpp\parallel_backend_sycl_merge.h(175,58): error: SYCL kernel cannot call a variadic function
  175 |         if constexpr (__can_use_ternary_op<_Rng1, _Rng2>().value)
      |                                                          ^
oneDPL\include\oneapi\dpl\pstl\hetero\dpcpp\parallel_backend_sycl_merge.h(350,21): note: called by 'operator()'
  350 |                     __serial_merge(__rng1, __rng2, __rng3, __start.first, __start.second, __i_elem,
      |                     ^
include\sycl\handler.hpp(405,7): note: called by 'operator()'
  405 |       KernelFunc(item);
      |       ^
…remove __assing_impl function and fix compile error in __can_use_ternary_op call
SergeyKopienko and others added 2 commits January 27, 2025 16:07
…ge.h

Co-authored-by: Dan Hoeflinger <109972525+danhoeflinger@users.noreply.github.com>
danhoeflinger
danhoeflinger previously approved these changes Jan 27, 2025
Copy link
Contributor

@danhoeflinger danhoeflinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good, but should have a second set of eyes on it.

Also, we should confirm that the reported bug is still fixed, and the performance regression disappears for the normal case.

danhoeflinger
danhoeflinger previously approved these changes Jan 27, 2025
Copy link
Contributor

@danhoeflinger danhoeflinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, wait for green CI

danhoeflinger
danhoeflinger previously approved these changes Jan 27, 2025
Copy link
Contributor

@danhoeflinger danhoeflinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :) third time is a charm

Copy link
Contributor

@MikeDvorskiy MikeDvorskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable.
But before merging into the main I suggest being sure that CI and a case with tuple type issue (which was before) are passed.

@SergeyKopienko SergeyKopienko merged commit 2a3a0b8 into main Jan 27, 2025
22 checks passed
@SergeyKopienko SergeyKopienko deleted the dev/skopienko/fix_serial_merge_and_perf branch January 27, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants