[Openmp-commits] [PATCH] D29665: Add an option to bind initial thread at the start of application

Andrey Churbanov via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Feb 7 10:38:13 PST 2017


AndreyChurbanov created this revision.

Introduced environment variable KMP_INITIAL_THREAD_BIND that allows to bind initial thread of OpenMP application to be bound at the very beginning.  To do so call middle library initialization from compiler generated function __kmpc_begin().  The middle initialization includes machine topology discovery and binding of the thread according to requested method if any.

This change is done by request from customer who wanted serial start of application be executed on the same core as the master thread of parallel region.


Repository:
  rL LLVM

https://reviews.llvm.org/D29665

Files:
  runtime/src/kmp_csupport.cpp


Index: runtime/src/kmp_csupport.cpp
===================================================================
--- runtime/src/kmp_csupport.cpp
+++ runtime/src/kmp_csupport.cpp
@@ -46,10 +46,15 @@
 void
 __kmpc_begin(ident_t *loc, kmp_int32 flags)
 {
-    // By default __kmp_ignore_mppbeg() returns TRUE.
-    if (__kmp_ignore_mppbeg() == FALSE) {
+    // By default __kmpc_begin() is no-op.
+    char *env;
+    if ((env = getenv( "KMP_INITIAL_THREAD_BIND" )) != NULL &&
+        __kmp_str_match_true( env )) {
+        __kmp_middle_initialize();
+        KC_TRACE(10, ("__kmpc_begin: middle initialization called\n" ));
+    } else if (__kmp_ignore_mppbeg() == FALSE) {
+        // By default __kmp_ignore_mppbeg() returns TRUE.
         __kmp_internal_begin();
-
         KC_TRACE( 10, ("__kmpc_begin: called\n" ) );
     }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29665.87415.patch
Type: text/x-patch
Size: 824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20170207/41a6069e/attachment.bin>


More information about the Openmp-commits mailing list