Intel® C++ Compiler 16.0 User and Reference Guide
Specifies a list of globally-visible variables that will be allocated private to each thread.
| #pragma omp threadprivate (list) | 
| list | A comma-separated list of variables you want to be private to a thread. | 
A variable listed in this pragma is allocated private to each thread in each parallel team.
| Example: Incrementing the counter whenever the thread executes an iteration of the parallel loop | 
|---|
| int counter;
#pragma omp threadprivate(counter);
  int N, i;
  int *a, *b, *c;
  allocate_and_initialize(a, b, c, N);
#pragma omp parallel for { counter = 0; }
#pragma omp parallel for schedule(dynamic)
  for(i=0; i<N; i++) {
   	a[i] = b[i] + c[i];
   	counter++;
}
 deallocate(a, b, c, N); |