Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7957 Discussions

OpenMP: implementation of threadprivate directive

Wenlong_L_Intel
Employee
288 Views
Hi, guys, I tried ICC8.0 and IFC8.0 compiler under Linux to compile C and Fortran code with openmp directive, and found that for each threadprivate variable, there is an explicit barrier operation for its initiation. I just wonder why each threadprivate variable requires one barrier, is one barrier for all threadprivate variables enough. I think the threadprivate directive is not effecient as we expect, can you further optimize it?
0 Kudos
1 Reply
jimdempseyatthecove
Honored Contributor III
288 Views

threadprivate should be used for global-lifetime objects. The(se) barriers are enterend only once at thread creation time and should not add significant latency time to the start of your application. Once the thread pool is created these barriers will not be entered again. Also note that as the main thread is initiating the thread pool, each spawned thread will likely make it through the barriers reasonably close to the completion of the creation of the last thread in the thread pool. IOW _beginthread latency may exceed the barriers execution times by already created threads.

Jim Dempsey

0 Kudos
Reply