copyin Clause
- Updated2023-02-21
- 1 minute(s) read
copyin Clause
Specifies that the value of the master thread's threadprivate variable or list of threadprivate variables is copied to the threadprivate variable of the other threads in the parallel region.
Format
copyin (list)
Example
#ifdef _OPENMP
#include <omp.h>
#endif
#include <stdlib.h>
float* work;
int size;
float tol;
#pragma omp threadprivate(work,size,tol)
void a32( float t, int n )
{
tol = t;
size = n;
#pragma omp parallel copyin(tol,size)
{
build();
}
}
void build();
{
int i;
work = (float*)malloc(sizeof(float)*size);
for(i=0;i<size;++1) work [i] = tol;
}