While omp_thread_num
is maintained for a full iteration, the same underlying thread won't necessarily perform the execution.
This made me wonder how omp deals non omp thread locals, i.e. __thread int;
or errno
, which are thread local to the underlying thread.
I can't find the information in the doc, but it seems like
#pragma omp parallel for
for (int i = 0; i < 10000; ++i) {
// exec by omp thread 1, using underlying thread a
fileptr = fopen(filenames[i], "rb");
variable_heavy_op(); // or just yield, or nothing,
// exec by omp thread 1, using underlying thread b,
if (!fileptr) // local to omp thread 1
perror(filename[i]); // // uses errno, local to underlying thread b,
}
would risk a really painful to debug rare threading error.
errno
is a catastrophic design choice, I know, but some crap is difficult to avoid. Another example would be reading the result of a try lock operation in pthreads, or using omp with any non omp threading primitives or derived libraries like the standard template library.
The question is, is my assertion correct. Or simplified. If i create a __thread variable ( non omp thread bound variable) how does that interact with the omp threadpool?