I implemented a multi-threaded library in Fortran and C++, and on the Fortran side, I need thread-local variables for making Fortran-side thread-safe. Currently, thread-local variables are possible to implement via OpenMP, unfortunately, it does not give any guarantees when the threads library is used for parallelization. I found that the IBM compiler supports only thread-local common blocks via directives to the compiler (see more here: https://www.ibm.com/docs/en/xl-fortran-aix/16.1.0?topic=directives-threadlocal).
So, I would like to have in modern Fortran threadlocal keyword for any available data.
Probably, it can be written as:
integer, threadlocal :: variable
I also found some useful documents which describe the use cases of TLS:
Dear all,
I implemented a multi-threaded library in Fortran and C++, and on the Fortran side, I need thread-local variables for making Fortran-side thread-safe. Currently, thread-local variables are possible to implement via OpenMP, unfortunately, it does not give any guarantees when the threads library is used for parallelization. I found that the IBM compiler supports only thread-local common blocks via directives to the compiler (see more here: https://www.ibm.com/docs/en/xl-fortran-aix/16.1.0?topic=directives-threadlocal).
So, I would like to have in modern Fortran
threadlocal
keyword for any available data. Probably, it can be written as:I also found some useful documents which describe the use cases of TLS: