Bug 101228 - tbb/task.h is Deprecated in newer TBB.
Summary: tbb/task.h is Deprecated in newer TBB.
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 11.1.0
: P3 normal
Target Milestone: ---
Assignee: Thomas Rodgers
Depends on:
Reported: 2021-06-27 01:13 UTC by Kip Warner
Modified: 2021-06-28 17:23 UTC (History)
5 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2021-06-27 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Kip Warner 2021-06-27 01:13:14 UTC
I've managed to reproduce this issue on two different machines, one amd64 and the other ppc64le. Both were using g++-11 (Ubuntu 11.1.0-1ubuntu1~21.04) 11.1.0.

Here is a minimal:

#include <algorithm>
#include <execution>

using namespace std;

int main()
    vector<long int> Container(3'000'000);
    iota(begin(Container), end(Container), 1);

    sort(execution::par, begin(Container), end(Container));

    return 0;

Compiling raises the following pragma in header generated warning:

$ g++-11 test.cpp -o test -Wall -Werror -std=c++17 -ltbb && ./test
In file included from /usr/include/c++/11/pstl/parallel_backend_tbb.h:26,
                 from /usr/include/c++/11/pstl/parallel_backend.h:20,
                 from /usr/include/c++/11/pstl/algorithm_impl.h:22,
                 from /usr/include/c++/11/pstl/glue_execution_defs.h:50,
                 from /usr/include/c++/11/execution:32,
                 from test.cpp:4:
/usr/include/tbb/task.h:21:139: note: ‘#pragma message: TBB Warning: tbb/task.h is deprecated. For details, please see Deprecated Features appendix in the TBB reference manual.’
   21 | ("TBB Warning: tbb/task.h is deprecated. For details, please see Deprecated Features appendix in the TBB reference manual.")
      |                                                                                                                            ^

Compiling again with #define TBB_SUPPRESS_DEPRECATED_MESSAGES 1 prepended to the beginning and the warning disappears.

This appears to have crept in some how with the 11 series. The <execution> header is indirectly including some deprecated Intel header from the TBB library.
Comment 1 Kip Warner 2021-06-27 02:49:34 UTC
Suggestion: Maybe a unit test that includes all the standard STL headers, does nothing with them, and that's expected to emit no warnings would mitigate problems like this occurring in the future.
Comment 2 Andrew Pinski 2021-06-27 03:22:59 UTC
tbb/task.h just got deprecated last year and after parallel_backend_tbb.h was added to GCC.


It depends on the version of TBB that is installed really.  Looks like Ubuntu 11.1.0 is using a much newer version.  You really should file a bug with Ubuntu about this issue since you are getting both GCC and TBB from them.  We won't fixing Ubuntu's compiler even with this bug filed by the way.
Comment 3 Kip Warner 2021-06-28 00:59:13 UTC
Thanks Andrew. I've opened an issue downstream:

Comment 4 Jonathan Wakely 2021-06-28 09:09:26 UTC
<execution> requires TBB, as documented:

"Note 3: The Parallel Algorithms have an external dependency on Intel TBB 2018 or later. If the <execution> header is included then -ltbb must be used to link to TBB."

If you use the parallel algos (or just include their headers) then the TBB headers are included. That's by design, they don't work otherwise. We can't do anythign about the fact that Intel deprecated their own API shortly after using contributing the PSTL headers to GCC, which depend on that API.
Comment 5 Matthias Klose 2021-06-28 09:32:10 UTC
No, the gcc packages don't depend on any tbb package.  Probably tbb needs an update to a new upstream version in the distro.
Comment 6 Jonathan Wakely 2021-06-28 09:36:40 UTC
There's no easy solution. Intel contributed the PSTL headers with a dependency on TBB task.h header, then deprecated that header in a later TBB release. You need to either use an older TBB, or suppress the warning.

There is a plan to add an OpenMP backend to PSTL, which will remove the TBB dependency, but it's not ready yet.
Comment 7 Pilar Latiesa 2021-06-28 11:47:57 UTC
This appears to be fixed upstream: https://reviews.llvm.org/D87380
Comment 8 Jonathan Wakely 2021-06-28 13:29:09 UTC
Tom, it looks like that fix landed upstream after our last sync. Should we use it?
Comment 9 Thomas Rodgers 2021-06-28 17:23:29 UTC
Yes (I already reviewed it when it arrived upstream). It is probably also safe to backport to GCC-11 since there's no ABI or ABI stability concerns. I will have a go at applying *just* this patch (I don't want to commit to trying a full rebase against upstream at this point).