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

TBB:2021 oneAPI compatibility #178

Closed
wants to merge 1 commit into from

Conversation

bartoszek
Copy link
Contributor

@bartoszek bartoszek commented Dec 19, 2021

Description: TBB:2021 compatibility fix

Implementation remarks

  • replace tbb::mutex with std::mutex
  • replace tbb::mutex::scoped_lock with std::scoped_lock
  • bump to cpp17 if tbb>2020
  • use cmake config to find tbb:2021 in FindTBB.cmake

Fix #177

@simogasp
Copy link
Member

simogasp commented Dec 20, 2021

Thanks for this!
We may need to better handle the c++17 flag because that also affects the cuda compiler and the minimum cuda version that is supported (11+).
We have a CCTAG_CXX_STANDARD that we can use to determine the standard to use.

CCTag/CMakeLists.txt

Lines 68 to 72 in a0f4630

set(CCTAG_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD ${CCTAG_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_STANDARD ${CCTAG_CXX_STANDARD})
set(CMAKE_CUDA_STANDARD_REQUIRED ON)

So maybe we need to move the code around in the CMakeLists to first determine if it is c++17 or c++14 and set the value.

@bartoszek
Copy link
Contributor Author

bartoszek commented Dec 20, 2021

Yea, I saw this, just tried the minimum required changes to allow tbb:2021 support, haven't thought about aberrations form cuda compiler.

##################################
find_package(TBB CONFIG)
if(TBB_FOUND)
return()
Copy link
Member

Choose a reason for hiding this comment

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

we need something like this before returning

set(TBB_LIBRARIES TBB::tbb)

Otherwise in CONFIG mode TBB_LIBRARIES is empty and it won't link with tbb

@@ -102,7 +106,11 @@ static void constructFlowComponentFromSeed(
}

{
#if TBB_VERSION_MAJOR > 2020
std::scoped_lock lock(G_SortMutex);
Copy link
Member

Choose a reason for hiding this comment

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

another alternative is to use boost::scoped_lock() since Boost.Thread is already among the dependencies.
This would have the advantage of avoiding raising the standard to c++17.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think std::lock_guard would work just fine in this particular case.

@p12tic
Copy link
Contributor

p12tic commented Sep 27, 2022

@simogasp Could we maybe just use std::mutex and std::lock_guard to avoid conditional compilation? The project uses C++14 as a minimum, so std::mutex should perform just as well.

@simogasp
Copy link
Member

simogasp commented Sep 27, 2022

@simogasp Could we maybe just use std::mutex and std::lock_guard to avoid conditional compilation? The project uses C++14 as a minimum, so std::mutex should perform just as well.

yes that's what they just did on vcpkg a couple of days ago when they updated TBB version
microsoft/vcpkg@5f6dfcb#diff-8a60cbd7865e2b41380671bdb5e4dcde34d4a1b7d51463019e270ff7bb8d6f84
I will rework this PR to make it more clean, I think at this point we can require a more recent version of TBB as managing cmake config and cmake old style is painful.
We need to update the docker images for the CI though.
@fabiencastan

@simogasp simogasp mentioned this pull request Oct 6, 2022
@simogasp
Copy link
Member

simogasp commented Oct 9, 2022

Thanks for initiating this PR!
The issue is now addressed in #200 so I'm closing this one.

@simogasp simogasp closed this Oct 9, 2022
@simogasp simogasp removed this from the v1.1.0 milestone Oct 9, 2022
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.

[bug] tbb:2021 compatibility.
3 participants