How to resolve “no member named 'task' in namespace 'tbb'” error when using oneDPL?
Asked Answered
H

1

6

When I use oneDPL in my code, I face the following issue:

/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/pstl/parallel_backend_tbb.h:70:10: error: no member named 'task' in namespace 'tbb'

Why does this happen and how can I fix it?

Honeybunch answered 10/6, 2021 at 14:32 Comment(0)
K
6

It happens when you use oneTBB because oneTBB is not compatible with legacy TBB.

libstdc++9, libstdc++10 use interfaces of legacy TBB that are not supported by oneTBB. It's fixed for libstdc++11 (See details).

oneTBB release notes say:

An application using Parallel STL algorithms in libstdc++ versions 9 and 10 may fail to compile due to incompatible interface changes between earlier versions of Threading Building Blocks (TBB) and oneAPI Threading Building Blocks (oneTBB). Disable support for Parallel STL algorithms by defining PSTL_USE_PARALLEL_POLICIES (in libstdc++ 9) or _GLIBCXX_USE_TBB_PAR_BACKEND (in libstdc++ 10) macro to zero before inclusion of the first standard header file in each translation unit.

If you use oneDPL, you don't have to apply these workarounds, because oneDPL does it for you, but you need to include its headers before the standard ones. Meanwhile, you can still use Parallel STL algorithms as before since oneDPL implements them.

If reordering of the headers is not suitable for you, you can define the macros, e.g.:

dpcpp my_app.cpp -DPSTL_USE_PARALLEL_POLICIES=0 # for libstdc++ 9
dpcpp my_app.cpp -D_GLIBCXX_USE_TBB_PAR_BACKEND=0 # for libstdc++ 10

If it's also not applicable, try to use legacy TBB instead of oneTBB.

Kabyle answered 10/6, 2021 at 15:41 Comment(3)
Actually, you need to include oneDPL headers before any other ones, as the standard library headers might be brought in through other headers as well.Urian
And what is that "dpcpp" thingie? :)Urian
dpcpp is a compiler for the Data Parallel C++ code. See details by the following link: software.intel.com/content/www/us/en/develop/documentation/…Kabyle

© 2022 - 2024 — McMap. All rights reserved.