[PATCH] Destructor support for C++11 thread_local variables

Torvald Riegel triegel@redhat.com
Fri Oct 12 11:28:00 GMT 2012


On Thu, 2012-10-11 at 16:25 -0700, Roland McGrath wrote:
> > (wouldn't work e.g. for OpenMP though, as that keeps some threads around
> > to avoid constant pthread_create/pthread_join).
> 
> Use of any long-lived TLS data in OpenMP-annotated code seems inherently
> ill-defined for exactly that reason.  AIUI the OpenMP annotations don't
> give you any guarantee about how much parallelism you actually get, so
> using __thread or thread_local variables in such code fragments seems like
> it ought to be out of spec entirely.  Is it well-specified in some way I'm
> not thinking of?

There are some rules, including whether tasks are tied to particular
threads or not, which thread teams are generated and scuh (see Section
1.3 of the OpenMP spec).
I'm not aware of any real integration of OpenMP and TLS life-cycles as
defined by C++, for example, but I wouldn't say that it's entirely out
of the spec.

Torvald



More information about the Libc-alpha mailing list