does including <execution> require linking against tbb?
Asked Answered
H

1

9

In my project on a Ubuntu 20 platform (with g++ 9.3.0), I use the following line

#include <execution>

to support parallel processing via standard library functions. I don't include anything from TBB, the parallel execution library from Intel. But then when I build the program I get the message:

/usr/bin/ld: CMakeFiles/probis.dir/src/probis.cpp.o: in function `tbb::interface7::task_arena::current_thread_index()':
/usr/include/tbb/task_arena.h:449: undefined reference to `tbb::interface7::internal::task_arena_base::internal_current_slot()'

This is easy enough to solve (as in: make the message go away) by adding -ltbb to the linker line. But then I have a dependency on libtbb that I did not count on.

Is this dependency expected? Is it possible to use parallel execution without installing tbb (but that tbb overrides the default setting when it is installed)?

Hindsight answered 20/4, 2021 at 9:56 Comment(2)
gcc/libstdc++ implements execution language facilities in terms of libtbb. It is required in order to use this header.Adrenocorticotropic
Ah OK, that clears it up, thanks! So when you install the latest g++ in Linux, TBB is always also installed? Would you mind typing it as an anser, then I'll mark it "solved". It seems others were looking for this too.Hindsight
S
4

As @[n. 'pronouns' m.] rightly said, you may need libtbb in order to make your code work. You can download the Intel® oneAPI Base Toolkit which contains TBB as one of the components. Link to download Intel® oneAPI Base Toolkit: https://software.intel.com/content/www/us/en/develop/tools/oneapi/base-toolkit/download.html

Societal answered 7/5, 2021 at 5:4 Comment(3)
? You can just use the libtbb-dev package for your distro. No need to install some external toolkit.Terms
Thanks! In fact that's what I've been doing. My question was not how to get it to work (very easy with APT) but whether this is the only way / does GNU have an alternative.Hindsight
Incredibly annoying (and disappointing). Relying on an external library (especially an Intel one) is probably one of the worse decisions GCC has made. Clang 15 fails quietly, and requires an explicit -stdlib=libstdc++ to work. Neither compiler throws linker errors (anymore?), they just fail quietly. Even MSVC managed to implement their own out-of-the-box parallelism. I really hope GCC and Clang revisit this mistake in the future, and find any other solutionTerpineol

© 2022 - 2024 — McMap. All rights reserved.