hidden text to trigger early load of fonts ПродукцияПродукцияПродукцияПродукция Các sản phẩmCác sản phẩmCác sản phẩmCác sản phẩm المنتجاتالمنتجاتالمنتجاتالمنتجات מוצריםמוצריםמוצריםמוצרים
Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Use case of TLS index in Fortran

netphilou31
New Contributor III
143 Views

Hi,

I'am looking for some examples of use of TLS index in Fortran without OpenMP.

Is that possible?

Best regards,

0 Kudos
3 Replies
Steve_Lionel
Honored Contributor III
76 Views

I assume TLS here means Thread Local Storage, but otherwise I don't know what you're asking.

0 Kudos
jimdempseyatthecove
Honored Contributor III
42 Views

>>I'am looking for some examples of use of TLS index in Fortran without OpenMP.

You will have to be more specific.

Your query implies that your Fortran code is run in a multi-threaded environment.

However, while you state "in Fortran without OpenMP", you do not state how/where the additional threads are created/managed.

And, where and how the private variables are declared.

 

Should you have a Fortran library that is called from a multi-threaded main program (e.g. C++ using __declspec(thread) ...),

then have the calling thread pass the argument(s) by value or reference (to its TLS storage).

 

Thread private management is not guaranteed to be the same across different languages. You will have to be creative, and do not rely "it worked in one environment". 

If you have a collection of TLS variables declared in C/C++, and you want individual access in your called Fortran procedures, then I suggest you encapsulate those variables within a struct (that is marked for TLS), then pass the reference to the struct to your Fortran procedure(s). The Fortran code can use BIND(C) on its declaration of the type.

 

Jim Dempsey

0 Kudos
JohnNichols
Valued Contributor III
7 Views

https://github.com/mijacobs

 

and https://learn.microsoft.com/en-us/windows/win32/dlls/using-thread-local-storage-in-a-dynamic-link-library 

 

I would start with someone like this who publishes code about this sort of stuff, indirectly in C++. 

 

Sometimes as Jim indirectly notes, you are the first one down the valley (of death or Fortran failure).  Good luck here, before this Forum it was a lonely path, filled with orcs and trogs. 

 

Fortran is a great language but it is not the other languages, it is for speed and number crunching, it is like writing in Old English, the vocabulary is not modern English, so there is no word for gun in Old English, they call it a firestick.

0 Kudos
Reply