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

后端 未结 2 1532
生来不讨喜
生来不讨喜 2021-02-13 10:59

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

2条回答
  •  半阙折子戏
    2021-02-13 11:22

    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

提交回复
热议问题