c++ - How do I explicitely thread tasks? -


suppose have 2 functions:

fun1(); fun2(); 

these functions independent , task improved if run them in parallel (that is, run fun1 on 1 thread , fun2 on another. using visual studio 2012 - open mp 2.0.

is there straight-forward way (without parallel region thread number testing or for loop dodginess) achieve this? openmp provide kind of functionality?

i tried looking @ parallel , task directives place start find of literature thoroughly incomprehensible , couldn't find examples...

you may use sections work-sharing construct:

#pragma omp parallel sections { #pragma omp section   fun1(); #pragma omp section   fun2(); } 

quoting openmp 2.0 specifications (sec. 2.4.2):

the sections directive identifies noniterative work-sharing construct specifies set of constructs divided among threads in team. each section executed once thread in team.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -