Each copy of a threadprivate variable is initialized once, in the manner specified by the program, but at an unspecified point in the program prior to the first reference to that copy. The storage of all copies of a threadprivate variable is freed according to how static variables are handled in the base language, but at an unspecified point in the program.
A program in which a thread references another thread’s copy of a threadprivate variable is non-conforming.
The content of a threadprivate variable can change across a task scheduling point if the executing thread switches to another schedulable task that modifies the variable. For more details on task scheduling, see Section 1.3 on page 11 and Section 2.7 on page 59.
In parallel regions, references by the master thread will be to the copy of the variable in the thread which encountered the parallel region.
During the sequential part references will be to the initial thread’s copy of the variable. The values of data in the initial thread’s copy of a threadprivate variable are guaranteed to persist between any two consecutive references to the variable in the program.
The values of data in the threadprivate variables of non-initial threads are guaranteed to persist between two consecutive active parallel regions only if all the following conditions hold:
• Neither parallel region is nested inside another explicit parallel region.
• The number of threads used to execute both parallel regions is the same.
• The value of the dyn-var internal control variable in the enclosing task region is false at entry to both parallel regions.
If these conditions all hold, and if a threadprivate variable is referenced in both regions, then threads with the same thread number in their respective regions will reference the same copy of that variable.
Users browsing this forum: Google [Bot] and 8 guests