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 C++20 macro in parallel_for_each + fix concepts macro definition #1611

Merged
merged 13 commits into from
Jan 31, 2025

Conversation

kboyarinov
Copy link
Contributor

Description

Add a comprehensive description of proposed changes

Fix two issues:

  • parallel_for_each failed to compile on gcc9 since __TBB_CPP20_PRESENT was while STL concepts were used actually. Changed to __TBB_CPP20_CONCEPTS_PRESENT
  • __TBB_CPP20_CONCEPTS_PRESENT macro was always defined to 0 for Intel Compiler and Clang. Changed to the detection based on Standard feature-test macros (the same approach as previously used for three-way-comparison)

Fixes #1552

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add a respective label(s) to PR if you have permissions

  • bug fix - change that fixes an issue
  • new feature - change that adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Notify the following users

List users with @ to send notifications

Other information

@mmichel11
Copy link

mmichel11 commented Jan 28, 2025

@kboyarinov @dnmokhov @sarathnandu Could this PR please be prioritized for review? The bug is significantly impacting oneDPL's pass rate here as it shows up in our oneTBB backend, and it needs to be fixed for our upcoming milestone.

Copy link
Contributor

@aleksei-fedotov aleksei-fedotov left a comment

Choose a reason for hiding this comment

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

Looks good to me, but some tests on macOS fail. Is it because of the compiler not supporting concept specifics we use?

@kboyarinov
Copy link
Contributor Author

@aleksei-fedotov @pavelkumbrasev @isaevil @sarathnandu @dnmokhov
I faced some unexpected and strange concept issues with clang on MacOS.
I propose to submit all of the other fixes now and keep the concepts disabled on MacOS. I will open an issue to fix that in the future or define the versions of Apple Clang that are not working with all or part of our concepts.
What do you think?

@sarathnandu
Copy link
Contributor

@aleksei-fedotov @pavelkumbrasev @isaevil @sarathnandu @dnmokhov I faced some unexpected and strange concept issues with clang on MacOS. I propose to submit all of the other fixes now and keep the concepts disabled on MacOS. I will open an issue to fix that in the future or define the versions of Apple Clang that are not working with all or part of our concepts. What do you think?

I agree, since this patch is affecting oneDPL's pass rate and they are waiting for this patch to be merged. We can investigate the MacOS build issue separately.

@phprus
Copy link
Contributor

phprus commented Jan 30, 2025

I think this is a bug in Clang (not only AppleClang):
llvm/llvm-project#61763

The bug is fixed in version LLVM 18.1.0.

AppleClang from Xcode 16.2 based on LLVM 17.

Copy link
Contributor

@sarathnandu sarathnandu left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@sarathnandu sarathnandu left a comment

Choose a reason for hiding this comment

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

The icpx compiler is also failing. I have tested on Intel(R) oneAPI DPC++/C++ Compiler 2023.2.0 (2023.2.0.20230721)

I believe you need to disable it for all clang not just clang && APPLE.

@dnmokhov
Copy link
Contributor

dnmokhov commented Jan 30, 2025

I think this is a bug in Clang (not only AppleClang): llvm/llvm-project#61763

The bug is fixed in version LLVM 18.1.0.

AppleClang from Xcode 16.2 based on LLVM 17.

I agree that we should just disable these concepts with any Clang for now.

My results of compiling test_blocked_range.cpp on Ubuntu:

  • Clang 14.0.0 - compiles
  • Clang 15.0.0 - compiles
  • Clang 17.0.1 - same compilation error as in MacOS CI above
  • Clang 18.1.0 - compiles
  • Clang 19.1.0 - internal compiler error

@aleksei-fedotov
Copy link
Contributor

I think this is a bug in Clang (not only AppleClang): llvm/llvm-project#61763
The bug is fixed in version LLVM 18.1.0.
AppleClang from Xcode 16.2 based on LLVM 17.

I agree that we should just disable these concepts with any Clang for now.

My results of compiling test_blocked_range.cpp on Ubuntu:

  • Clang 14.0.0 - compiles
  • Clang 15.0.0 - compiles
  • Clang 17.0.1 - same compilation error as in MacOS CI above
  • Clang 18.1.0 - compiles
  • Clang 19.1.0 - internal compiler error

Should not we then check the clang's version and enable concepts only if the version is not 17 or not 19? We have __TBB_CLANG_VERSION macro.

@kboyarinov
Copy link
Contributor Author

I think this is a bug in Clang (not only AppleClang): llvm/llvm-project#61763
The bug is fixed in version LLVM 18.1.0.
AppleClang from Xcode 16.2 based on LLVM 17.

I agree that we should just disable these concepts with any Clang for now.
My results of compiling test_blocked_range.cpp on Ubuntu:

  • Clang 14.0.0 - compiles
  • Clang 15.0.0 - compiles
  • Clang 17.0.1 - same compilation error as in MacOS CI above
  • Clang 18.1.0 - compiles
  • Clang 19.1.0 - internal compiler error

Should not we then check the clang's version and enable concepts only if the version is not 17 or not 19? We have __TBB_CLANG_VERSION macro.

I agree, we can enable back concepts on the clang versions not affected by the issue described above.
An other option we have is not to disable concepts completely since the issue only affects TBB classes that uses a constrained friend declaration inside (like blocked_range that friends blocked_range2d.

I still propose to keep concepts on clang totally disabled for this release and create a separate issue for enabling it to make sure other fixes introduced in this patch are landed. I still feel that we need to test the potential fix better on different versions of clang on both Linux and MacOS before enabling concepts.

Copy link
Contributor

@aleksei-fedotov aleksei-fedotov left a comment

Choose a reason for hiding this comment

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

Okay, let's have it disabled for Clang in this release.

Copy link
Contributor

@sarathnandu sarathnandu left a comment

Choose a reason for hiding this comment

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

LGTM

@kboyarinov kboyarinov merged commit 409280b into master Jan 31, 2025
24 of 25 checks passed
@kboyarinov kboyarinov deleted the dev/kboyarinov/for_each_concepts_fix branch January 31, 2025 15:32
@mcaryl-digitalbarriers
Copy link

Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tbb::parallel_for_each build fail on gcc 9.4.0 using C++20
7 participants