Skip to content

Commit aad1cce

Browse files
authored
Merge pull request #3887 from branh/patch-2
Clarify master and single directives.
2 parents 5437251 + ace1574 commit aad1cce

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

docs/parallel/openmp/reference/openmp-clauses.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ For data-sharing attributes:
3232
|[shared](#shared-openmp)|Specifies that one or more variables should be shared among all threads.|
3333
|[default](#default-openmp)|Specifies the behavior of unscoped variables in a parallel region.|
3434
|[reduction](#reduction)|Specifies that one or more variables that are private to each thread are the subject of a reduction operation at the end of the parallel region.|
35-
|[copyin](#copyin)|Allows threads to access the master thread's value, for a [threadprivate](openmp-directives.md#threadprivate) variable.|
35+
|[copyin](#copyin)|Allows threads to access the main thread's value, for a [threadprivate](openmp-directives.md#threadprivate) variable.|
3636
|[copyprivate](#copyprivate)|Specifies that one or more variables should be shared among all threads.|
3737

3838
## <a name="copyin"></a> copyin
3939

40-
Allows threads to access the master thread's value, for a [threadprivate](openmp-directives.md#threadprivate) variable.
40+
Allows threads to access the main thread's value, for a [threadprivate](openmp-directives.md#threadprivate) variable.
4141

4242
```cpp
4343
copyin(var)
@@ -46,7 +46,7 @@ copyin(var)
4646
### Parameters
4747
4848
*var*<br/>
49-
The `threadprivate` variable that will be initialized with the variable's value in the master thread, as it exists before the parallel construct.
49+
The `threadprivate` variable that will be initialized with the variable's value in the main thread, as it exists before the parallel construct.
5050
5151
### Remarks
5252
@@ -513,7 +513,7 @@ int main() {
513513
printf_s("These are the variables after exit from "
514514
"the parallel region.\n");
515515
printf_s("nThreadPrivate = %d (The last value in the "
516-
"master thread)\n", nThreadPrivate);
516+
"main thread)\n", nThreadPrivate);
517517
printf_s(" nPrivate = %d (The value prior to "
518518
"entering parallel region)\n", nPrivate);
519519
printf_s(" nFirstPrivate = %d (The value prior to "
@@ -591,7 +591,7 @@ nFirstPrivate = 3
591591
nShared = 3
592592
593593
These are the variables after exit from the parallel region.
594-
nThreadPrivate = 0 (The last value in the master thread)
594+
nThreadPrivate = 0 (The last value in the main thread)
595595
nPrivate = 4 (The value prior to entering parallel region)
596596
nFirstPrivate = 4 (The value prior to entering parallel region)
597597
nLastPrivate = 3 (The value from the last iteration of the loop)

docs/parallel/openmp/reference/openmp-directives.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ For parallel work-sharing:
1919
|[parallel](#parallel)|Defines a parallel region, which is code that will be executed by multiple threads in parallel.|
2020
|[for](#for-openmp)|Causes the work done in a `for` loop inside a parallel region to be divided among threads.|
2121
|[sections](#sections-openmp)|Identifies code sections to be divided among all threads.|
22-
|[single](#single)|Lets you specify that a section of code should be executed on a single thread, not necessarily the master thread.|
22+
|[single](#single)|Lets you specify that a section of code should be executed on a single thread, not necessarily the main thread.|
2323

24-
For master and synchronization:
24+
For main thread and synchronization:
2525

2626
|Directive|Description|
2727
|---------|-----------|
28-
|[master](#master)|Specifies that only the master thread should execute a section of the program.|
28+
|[master](#master)|Specifies that only the main thread should execute a section of the program.|
2929
|[critical](#critical)|Specifies that code is only executed on one thread at a time.|
3030
|[barrier](#barrier)|Synchronizes all threads in a team; all threads pause at the barrier, until all threads execute the barrier.|
3131
|[atomic](#atomic)|Specifies that a memory location that will be updated atomically.|
@@ -356,7 +356,7 @@ The sum of 1 through 10 is 55
356356

357357
## <a name="master"></a> master
358358

359-
Specifies that only the master thread should execute a section of the program.
359+
Specifies that only the main thread should execute a section of the program.
360360

361361
```cpp
362362
#pragma omp master
@@ -369,14 +369,13 @@ Specifies that only the master thread should execute a section of the program.
369369

370370
The `master` directive supports no clauses.
371371

372-
The [single](#single) directive lets you specify that a section of code should be executed on a single thread, not necessarily the master thread.
373-
374372
For more information, see [2.6.1 master construct](../2-directives.md#261-master-construct).
375373

374+
To specify that a section of code should be executed on a single thread, not necessarily the main thread, use the [single](#single) directive instead.
375+
376376
### Example
377377

378378
```cpp
379-
// omp_master.cpp
380379
// compile with: /openmp
381380
#include <omp.h>
382381
#include <stdio.h>
@@ -606,7 +605,7 @@ Hello from thread 0
606605

607606
## <a name="single"></a> single
608607

609-
Lets you specify that a section of code should be executed on a single thread, not necessarily the master thread.
608+
Lets you specify that a section of code should be executed on a single thread, not necessarily the main thread.
610609

611610
```cpp
612611
#pragma omp single [clauses]
@@ -629,10 +628,10 @@ The `single` directive supports the following clauses:
629628
- [copyprivate](openmp-clauses.md#copyprivate)
630629
- [nowait](openmp-clauses.md#nowait)
631630

632-
The [master](#master) directive lets you specify that a section of code should be executed only on the master thread.
633-
634631
For more information, see [2.4.3 single construct](../2-directives.md#243-single-construct).
635632

633+
To specify that a section of code should only be executed on the main thread, use the [master](#master) directive instead.
634+
636635
### Example
637636

638637
```cpp

0 commit comments

Comments
 (0)