So I started learning TBB just today. I'm working on Ubuntu system, so installed TBB using sudo apt
sudo apt-get install libtbb-dev
now I'm trying to compile and run HELLO_TBB
#include <iostream>
#include <tbb/tbb.h>
int main() {
tbb::parallel_invoke(
[]() { std::cout << " Hello " << std::endl; },
[]() { std::cout << " TBB! " << std::endl; }
);
return 0;
}
and when trying to compile it I get the next note:
$ g Hello_TBB.cpp -o test -ltbb
In file included from Hello_TBB.cpp:2:
/usr/local/include/tbb/tbb.h:21:154: note: #pragma message: TBB Warning: tbb.h contains deprecated functionality. For details, please see Deprecated Features appendix in the TBB reference manual.
21 | ee Deprecated Features appendix in the TBB reference manual.")
and when running the code it actually prints Hello TBB only once! is that how it works? or am I missing something? and what the deal with that note?
CodePudding user response:
Regarding the output:
tbb::parallel_invoke
is a:
Function template that evaluates several functions in parallel.
As you can see in the link, you can pass several functions, and the tbb framework will attempt to run them in parallel (each function in a separate thread). Each of the functions will be executed once.
Note BTW that the level of parallelism is not guaranteed, and depends on your system properties and hardware.
In your case you passed 2 functions. One prints " Hello " and the other " TBB! ". they might run in parallel, but each will run once. So overall they will print these 2 strings once.
Regarding the note:
I am not familiar with it specifically. In general depracated functions are those which are discouraged to use since they will probably be removed in future versions. I don't think it is the case with tbb::parallel_invoke
but you can verify in the documentation link above.