[Openmp-commits] [PATCH] D34154: Set affinity to none/false in child processes

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Jun 13 10:24:17 PDT 2017


jlpeyton created this revision.

Reset affinity to none (false for proc-bind-var) so that threads in the child
processes are not bound tightly, unless the user explicitly sets this in
KMP_AFFINITY/OMP_PROC_BIND, in child processes.  This can improve
performance for scripting languages which fork for parallelism like Python's
multiprocessing module.


Repository:
  rL LLVM

https://reviews.llvm.org/D34154

Files:
  runtime/src/z_Linux_util.cpp


Index: runtime/src/z_Linux_util.cpp
===================================================================
--- runtime/src/z_Linux_util.cpp
+++ runtime/src/z_Linux_util.cpp
@@ -1280,11 +1280,22 @@
 
   ++__kmp_fork_count;
 
-#if KMP_AFFINITY_SUPPORTED && KMP_OS_LINUX
+#if KMP_AFFINITY_SUPPORTED
+#if KMP_OS_LINUX
   // reset the affinity in the child to the initial thread
   // affinity in the parent
   kmp_set_thread_affinity_mask_initial();
 #endif
+  // Set default not to bind threads tightly in the child (we’re expecting
+  // over-subscription after the fork and this can improve things for
+  // scripting languages that use OpenMP inside process-parallel code).
+  __kmp_affinity_type = affinity_none;
+#if OMP_40_ENABLED
+  if (__kmp_nested_proc_bind.bind_types != NULL) {
+    __kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
+  }
+#endif // OMP_40_ENABLED
+#endif // KMP_AFFINITY_SUPPORTED
 
   __kmp_init_runtime = FALSE;
 #if KMP_USE_MONITOR


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34154.102364.patch
Type: text/x-patch
Size: 965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20170613/8819c71a/attachment.bin>


More information about the Openmp-commits mailing list