- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am having trouble properly using oneTBB on my Ubuntu 20.04. The problem occurs when I want to use std::execution::par with std::for_each for both using CLI g++ and cmake. I have gcc 9.4.0.
This is the procedure I follow:
1. I have installed oneTBB using the Intel GUI from Intels web page (here).
2. I have set the environment using "source vars.sh" in /tbb/latest/env (explained here ).
3. I have a sample code:
// test.cpp
#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;
}
4. I tried the following command :
g++ -std=c++17 -o test test.cpp -ltbb
this does not work and give many errors.
5. I try the command line as explained here:
g++ -o test test.cpp $(pkg-config --libs --cflags tbb)
it gives the following error:
error: ‘std::execution’ has not been declared
pointing to the line std::sort lines.
6. I tried the following (based on here) cmake file with no luck:
cmake_minimum_required(VERSION 3.22)
project(test)
set(CMAKE_CXX_STANDARD 20)
list(APPEND CMAKE_MODULE_PATH "/home/username/oneapi/tbb/latest/lib/cmake/tbb")
#set(CMAKE_MODULE_PATH "/home/username/oneapi/tbb/latest/lib/cmake/tbb") #this did not work either
add_executable(test test.cpp)
find_package(TBB REQUIRED)
target_link_libraries(${PROJECT_NAME} tbb)
7. Interestingly, the examples given here are all working. I can build and run them all (except the MKL examples). None of these examples have #include <execution> and std::execution::par in them tough, as far as I can see.
In one of the oneTBB examples (e.g. fibonacci), if I only include <execution> to the example source code, it does not give error with the 5th and 6th option above. But when I want to use std::execution::par in the code, it does not compile. So examples are not working when std::execution::par comes into play.
8. Older version of TBB that can be installed using apt, does not give this error.
Any help is appreciated.
Link Copied
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page