Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the benefit of '#pragma omp master' as opposed to '#pragma omp single'?

Tags:

openmp

In OpenMP any code inside a #pragma omp master directive is executed by a single thread (the master), without an implied barrier at end of the region. (See section on MASTER directive in the LLNL OpenMP tutorial).

This seems equivalent to #pragma omp single nowait (with the exception that rather than the 'master', any thread may execute the single region).

Under what circumstances, if any, is it beneficial to use #pragma omp master?

like image 852
Josh Milthorpe Avatar asked Sep 16 '13 04:09

Josh Milthorpe


People also ask

What is benefit used for?

Definition of benefit c : a service (such as health insurance) or right (as to take vacation time) provided by an employer in addition to wages or salary The job doesn't pay much, but the benefits are good.

What is the verb of benefit?

verb (used without object), ben·e·fit·ed or ben·e·fit·ted, ben·e·fit·ing or ben·e·fit·ting. to derive benefit or advantage; profit; make improvement: He has never benefited from all that experience.

Is it benefit from or benefit by?

The expression benefit from means to receive an advantage because of the action or existence of something. Aspiring athletes benefit greatly not only from participating in regional competitive events, but also from watching world-class athletes in the Olympics.

What is the noun of benefit?

benefit. noun. noun. /ˈbɛnəfɪt/ 1[uncountable, countable] an advantage that something gives you; a helpful and useful effect that something has I've had the benefit of a good education.


2 Answers

Though a single nowait construct is most of the time equivalent to a master construct:

  1. The master construct can be used inside a work-sharing construct, should any need arise. This is not the case for a single nowait construct, as two work-sharing constructs can't be nested within the same parallel region

  2. Some libraries want the main thread to perform certain operations. For instance the MPI library, when initialized with a level of thread support equal to MPI_THREAD_FUNNELED, allows only the main threads to make MPI calls

like image 176
Massimiliano Avatar answered Nov 23 '22 07:11

Massimiliano


In addition to nesting limitations single construct can be implemented slower than master construct because it is more complicated and flexible. You may want to check your particular implementation, but in general master can be implemented faster, so multiple invocations of it may benefit comparing to single nowait construct.

like image 21
Andrey Churbanov Avatar answered Nov 23 '22 07:11

Andrey Churbanov