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

Require TBB without captured exceptions #8169

Merged
merged 2 commits into from
May 18, 2021
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
21 changes: 20 additions & 1 deletion cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# For the list of contributors see $ROOTSYS/README/CREDITS.

#---Check for installed packages depending on the build options/components enabled --
include(CheckCXXSourceCompiles)
include(ExternalProject)
include(FindPackageHandleStandardArgs)

Expand Down Expand Up @@ -1238,6 +1239,25 @@ if(imt AND NOT builtin_tbb)
set(builtin_tbb ON CACHE BOOL "Enabled because imt is enabled, but TBB was not found" FORCE)
endif()
endif()

# Check that the found TBB does not use captured exceptions.
if(TBB_FOUND)
set(CMAKE_REQUIRED_INCLUDES "${TBB_INCLUDE_DIRS}")
check_cxx_source_compiles("
#include <tbb/tbb_config.h>
Copy link

@makortel makortel May 26, 2021

Choose a reason for hiding this comment

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

oneTBB 2021.2 does not have this header, so this check fails falsely claiming TBB being built with "tbb::captured_exception" that doesn't even exist anymore in that version.

(found out in cms-sw/cmsdist#6936)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for testing and reporting. Indeed, oneTBB doesn't have the header anymore nor the "captured exceptions" thing, so #8239 skips the test under those conditions.

@oshadura our FindTBB.cmake cannot detect versions of newer TBBs because, guess what, they don't have the header tbb/tbb_stddef.h either. I was first checking TBB_VERSION, but that's empty in such case. Probably somebody with proper CMake skills should take a look and make the detection work properly...

Copy link
Contributor

@oshadura oshadura May 27, 2021

Choose a reason for hiding this comment

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

@hahnjo thanks a lot for fix! could you please open a GH issue/improvement to revisit FindTBB.cmake? I will recheck it ASAP

#if TBB_USE_CAPTURED_EXCEPTION == 1
#error TBB uses tbb::captured_exception, not suitable for ROOT!
#endif
int main() { return 0; }" tbb_exception_result)
if(NOT tbb_exception_result)
if(fail-on-missing)
message(FATAL_ERROR "Found TBB uses tbb::captured_exception, not suitable for ROOT!")
endif()
message(STATUS "Found TBB uses tbb::captured_exception, enabling 'builtin_tbb' option")
set(builtin_tbb ON CACHE BOOL "Enabled because imt is enabled and found TBB is not suitable" FORCE)
endif()
endif()

set(TBB_CXXFLAGS "-DTBB_SUPPRESS_DEPRECATED_MESSAGES=1")
endif()

Expand Down Expand Up @@ -1891,7 +1911,6 @@ endif()
# using atomic operations without the help of a library. Only if it can't do we start
# looking for libatomic for the build.
#
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <atomic>
#include <cstdint>
Expand Down
4 changes: 4 additions & 0 deletions core/imt/src/RTaskArena.cxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Require TBB without captured exceptions
#define TBB_USE_CAPTURED_EXCEPTION 0
#include "tbb/tbb_config.h"

#include "ROOT/RTaskArena.hxx"
#include "ROpaqueTaskArena.hxx"
#include "TError.h"
Expand Down
4 changes: 4 additions & 0 deletions core/imt/src/TThreadExecutor.cxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Require TBB without captured exceptions
#define TBB_USE_CAPTURED_EXCEPTION 0
#include "tbb/tbb_config.h"

#include "ROOT/TThreadExecutor.hxx"
#include "ROpaqueTaskArena.hxx"
#if !defined(_MSC_VER)
Expand Down