IVF OpenMP THREADRIVATE and non OpenMP threads

IVF OpenMP THREADRIVATE and non OpenMP threads

Steve, TimP, others,

This is not an show stopper as I have a work around

I have a multi-threaded OpenMP Fortran Application. That uses ThreadPrivate data. This is an app that I have been using/developing for years. The OpenMP threads do have seperate ThreadPrivate data. Recently I have had the need to introduce an additional non-OpenMP helperthread(s) created with CreateThread and I noticed a problem (un-expected quirk)....

I have been for years assuming the IVF ThreadPrivate was implimented similar to C __declspec(thread)... but apparently this is not so. Non-OpenMP threads created using CreateThread seem to inherit the VM of the thread issuing CreateThread, which means the new thread "inherits" the mapping of the thread private data of its creator and is not given the same VM of the creator with the exception of a different mapped portion of the VM for the thread private data (as is the case for __declspec(thread) ... declared data).

Is this a known issue? I this an issue?
Any comment on this would be appreciated.

Using IVF 11.0.066
This may be different in 12.n.mm

Jim Dempsey

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


Sorry that this took so long, but it took some time to find someone who knew the answer. It is not a simple question.

No, Intel's THREADPRIVATE is not the same as Microsoft's __declspec(thread), because the Microsoft implementation is buggy and often doesn't have the right semantics.

First, what do you want to accomplish? Is it:

1. You want
each non-OpenMP thread to have its own copy of each OpenMP threadprivate variable

2. You want
each non-OpenMP thread to have its own threadprivate copy compatible with

If it's 1, then try setting the environment variable KMP_FOREIGN_THREADS_THREADPRIVATE=true .

If it's 2, then compile with the option /Qopenmp-threadprivate:compat and define the environment variable as above. Be aware that the "compat" (MS) version various bugs and restrictions and may not work properly for you.

Last, I am not sure how well this works in 11.0.

Let me know what happens.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today