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!

publicaciones de 2 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

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


Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya