Well, this is pretty straighforward (as long as you do not mind a bit of C++ class writing and placement-new calling
![smiley [:-)]](/file/6746)
, tutorial has easy samples for all this stuff).
1) You create 3 classes derived from
tbb::task. Their methods
execute() should invoke FUN1, FUN2, and FUN3 correspondingly.
2) Then you allocate instances of these tasks by means of
tbb::allocate_root() functions,
3) and place them into
tbb::task_list container.
4) At last you call
tbb::spawn_root_and_wait() passing it the task list (that now contains 3 instances of your tasks).
The call to
tbb::spawn_root_and_wait() will execute your tasks in parallel (depending on the number of available threads), and return when the last of them finishes. Note that this simple form of functional parallelism usually results in significant imbalance (which is really bad as you certainly know). But if your FUNX functions have a potential for data parallelizm, then you'll be all right. You can safely use TBB data parallel algorithms (like parallel_for, parallel_do or pipeline) from inside other TBB tasks. This does not incur any additional overhead, while allows you to achieve great load balance (that is maximally engages all the available computational resourses in doing the work for you).
And do not forget to initialize TBB (by creating an instance of tbb_scheduler_init class) in the main function of your app before you do what is described above.