Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

parallel_invoke

pascual__carlos
Beginner
245 Views

Hi,

I have tried to use tbb::parallel_invoke to parallelize two functions. I have the next functins:

bool isValidDate(string order)

int checkOrder(string order)

isValidDate check that the order date is correct and checkOrder check the format of the order. 

Actually, I execute these functions sequentially, firstly I check the date and then the format. Now, I want to execute both functions in parallel,  for this, I use parallel_invoke as follows:

tbb::parallel_invoke (
[&]{isValidDate(order);}, [&]{checkOrder(order);} );

This code execute correctly, but is slower than the secquential code. I don´t urdenstand why this is so.

Anybody could say me the reason or some way to parallelize the functions well?

Thank you so much!

0 Kudos
1 Reply
Aleksei_F_Intel
Employee
245 Views

Hi carlos,

It seems that in your case these functions take so little time to execute so that it is not justified to execute them in parallel because overheads involved exceed the payload inside these functions.

Please consider do more work in this functions like call them passing several orders to process.

Regards, Aleksei

 

0 Kudos
Reply