Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.

std::execution::par error

bariserkus
Novice
855 Views

I have a simple code:

 

#include <iostream>
#include <vector>
#include <algorithm>
#include <execution>

int main(){
    std::vector<int> vec = {1, 2, 3, 4, 5, 10, 20, 4 };

    std::sort(std::execution::seq, vec.begin(), vec.end()); // sequential
    std::sort(std::execution::par, vec.begin(), vec.end()); // parallel

    return 0;
}

 

I compile with:

g++ -o test3 test3.cpp $(pkg-config --libs --cflags tbb)

This give me error:

error: ‘std::execution’ has not been declared

I am on Ubunu Linux 20.04 and gcc 9.4.0. I have installed oneTBB standalone using Intel's GUI installer and set the enviroment using vars.sh . I have no other oneAPI packages installed.

I have tested examples that comes with oneTBB, they are all working but noe of them have std::execution::par in them. When I include execution in them, they also give error.

I have seen a similar post and I guess this solution requires oneapi/dpl. Can it be done without installing dpl ?

Note: I have tried the above code with

 

#include "oneapi/dpl/algorithm"
#include "oneapi/dpl/execution"

 

and installed oneDPL along with sourcing dpl var.sh and it worked.  Intel's oneTBB web page or oneTBB GitHub page does not make a point to this. Can somebody provide a clarification?

0 Kudos
5 Replies
NoorjahanSk_Intel
Moderator
803 Views

Hi,

Thanks for reaching out to us.


Parallel STL algorithm in libstdc++9, libstdc++10 use interfaces of legacy TBB that are not supported by oneTBB.

You can disable the parallel stl algorithms by defining PSTL_USE_PARALLEL_POLICIES (in libstdc++ 9) or _GLIBCXX_USE_TBB_PAR_BACKEND (in libstdc++ 10) macro to zero.


Please refer to the below link for more details:

https://www.intel.com/content/www/us/en/developer/articles/release-notes/intel-oneapi-threading-building-blocks-release-notes.html


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.


Please refer to the below link for more details:

https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-library-guide/top/parallel-api/execution-policies.html


>> Can it be done without installing dpl ?

As of now, we do not have any other workaround without installing dpl.



Thanks & Regards,

Noorjahan.


bariserkus
Novice
789 Views

Thanks for the clarification. Maybe, a note and an example on this subject can be added to the oneTBB web pages (e.g. here). Otherwise, it is difficult to catch it from other pages. Thanks again.

NoorjahanSk_Intel
Moderator
771 Views

Hi,

 

Thanks for the feedback we will let the concerned team know about this issue.

You can find the examples using oneDPL in the below link:

https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-library-guide/top/parallel-api/execution-policies.html

 

>>Thanks for the clarification

 

As your query is answered, could you please confirm whether we can go ahead and close this issue?

 

Thanks & Regards,

Noorjahan.

 

Mark_L_Intel
Employee
724 Views

Hello,


You are using oneDPL APIs in your example, so it is not about TBB per se. In fact, TBB is just one of the backends that can be used with oneDPL -- another one is OpenMP. With TBB backend, you can get into the errors that are indeed coming from the issues connected to TBB backend incorrect usage -- one aspect of that described in one of the responses above. With oneAPI, we switched to new oneTBB from older (and incompatible with new one) "old" TBB -- that also can spill out into the compilation process. The advice is to put oneDPL headers first into your source code (e.g., before standard library headers) -- that should be sufficient to automatically call correct TBB backend.


We already have documentation regarding oneDPL, e.g., please see

https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-library-guide/top.html


where the solution (found by you) to the errors you first seen.




Mark_L_Intel
Employee
687 Views

Hello,

In case of no response in 5 days since now, the ticket won't be supported by Intel anymore.


Reply