Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I did some experiments, maybe it helps: When building with modules (I don't have much experience with modules), I couldn't find any symbol for tbb when using nm, when I replaced modules with #incl...
#1: Initial revision
I did some experiments, maybe it helps:
When building with modules (I don't have much experience with modules), I couldn't find any symbol for tbb when using `nm`, when I replaced modules with `#include`s, tbb was used, `task_arena`s to be more specific.
Using `perf record -s ./parallel` I could confirm, that the module version doesn't use tbb or threads, but using includes, 8 threads (my core count × 2) are used for 100 inputs.
Here is my code:
```c++
#include <execution>
#include <print>
#include <ranges>
#include <thread>
int main() {
auto values{std::ranges::views::iota(0, 100)};
std::for_each(
std::execution::par,
std::begin(values), std::end(values),
[] (const auto value) {
std::println("value: {}, thread: {}",
value, std::this_thread::get_id());
}
);
return 0;
}
```
and my output:
<details>
- TBB: 2023.1
```shell
$ g++ --version
g++ (GCC) 16.1.1 20260728
$ g++ -std=c++26 -O2 -Wall -ltbb parallel.cpp -o parallel
$ ./parallel
value: 0, thread: 140232593692544
value: 1, thread: 140232593692544
value: 2, thread: 140232593692544
value: 3, thread: 140232593692544
value: 4, thread: 140232593692544
value: 5, thread: 140232593692544
value: 6, thread: 140232593692544
value: 7, thread: 140232593692544
value: 8, thread: 140232593692544
value: 9, thread: 140232593692544
value: 10, thread: 140232593692544
value: 11, thread: 140232593692544
value: 12, thread: 140232593692544
value: 13, thread: 140232593692544
value: 14, thread: 140232593692544
value: 15, thread: 140232593692544
value: 16, thread: 140232593692544
value: 17, thread: 140232593692544
value: 18, thread: 140232593692544
value: 19, thread: 140232593692544
value: 20, thread: 140232593692544
value: 21, thread: 140232593692544
value: 22, thread: 140232593692544
value: 23, thread: 140232593692544
value: 24, thread: 140232593692544
value: 25, thread: 140232593692544
value: 26, thread: 140232593692544
value: 50, thread: 140232580118208
value: 51, thread: 140232580118208
value: 52, thread: 140232580118208
value: 27, thread: 140232593692544
value: 28, thread: 140232593692544
value: 29, thread: 140232593692544
value: 30, thread: 140232593692544
value: 31, thread: 140232593692544
value: 53, thread: 140232580118208
value: 54, thread: 140232580118208
value: 55, thread: 140232580118208
value: 56, thread: 140232580118208
value: 57, thread: 140232580118208
value: 58, thread: 140232580118208
value: 59, thread: 140232580118208
value: 60, thread: 140232580118208
value: 61, thread: 140232580118208
value: 62, thread: 140232580118208
value: 63, thread: 140232580118208
value: 64, thread: 140232580118208
value: 65, thread: 140232580118208
value: 66, thread: 140232580118208
value: 67, thread: 140232580118208
value: 68, thread: 140232580118208
value: 69, thread: 140232580118208
value: 32, thread: 140232593692544
value: 33, thread: 140232593692544
value: 34, thread: 140232593692544
value: 87, thread: 140232567523008
value: 35, thread: 140232593692544
value: 36, thread: 140232593692544
value: 70, thread: 140232580118208
value: 37, thread: 140232575919808
value: 74, thread: 140232580118208
value: 75, thread: 140232571721408
value: 71, thread: 140232489952960
value: 76, thread: 140232571721408
value: 78, thread: 140232580118208
value: 79, thread: 140232580118208
value: 84, thread: 140232494151360
value: 85, thread: 140232494151360
value: 86, thread: 140232494151360
value: 43, thread: 140232494151360
value: 44, thread: 140232494151360
value: 45, thread: 140232494151360
value: 46, thread: 140232494151360
value: 47, thread: 140232494151360
value: 48, thread: 140232494151360
value: 49, thread: 140232494151360
value: 40, thread: 140232494151360
value: 41, thread: 140232494151360
value: 81, thread: 140232485754560
value: 38, thread: 140232575919808
value: 39, thread: 140232575919808
value: 72, thread: 140232489952960
value: 93, thread: 140232575919808
value: 73, thread: 140232593692544
value: 83, thread: 140232593692544
value: 98, thread: 140232593692544
value: 99, thread: 140232593692544
value: 90, thread: 140232593692544
value: 91, thread: 140232593692544
value: 92, thread: 140232593692544
value: 95, thread: 140232593692544
value: 80, thread: 140232580118208
value: 82, thread: 140232485754560
value: 94, thread: 140232575919808
value: 88, thread: 140232567523008
value: 89, thread: 140232567523008
value: 42, thread: 140232494151360
value: 77, thread: 140232571721408
value: 96, thread: 140232489952960
value: 97, thread: 140232489952960
```
</details>
