Global variables as thread local storage


#1

Is there any plan to add some syntax to mark global variables as being in thread-local storage? (as in C and C++)
There are a number of things in Base (BigFloats, @printf, etc.) and in packages (DecFP) where global variables really need to be thread local (such as the current rounding mode and default precision, the DIGITS buffer in base), which means that currently you can get bad results if you use those modules/packages simultaneously in different threads.

I brought this up before last year’s JuliaCon, but haven’t seen any fix for it yet.


Multithreading in Julia
#2

This could be an interesting option, the problem comes when we consider the overhead in GPU-SIMD applications with many threads,
where having a local frame copy of each global variable can result in an impressive memory waste.

Maybe implementing it as a general solution can not be doable, but I would like to try to write an interface similar to TLS for the GLOBAL_RNG.

For I\O buffers it can be more tricky : as libuv is not thread safe I wonder if it is only needed to guard each file handler by a lock acquiring/releasing method.