Fix for bugzilla https://bugs.llvm.org/show_bug.cgi?id=39137.
authorAndrey Churbanov <Andrey.Churbanov@intel.com>
Wed, 14 Nov 2018 13:49:41 +0000 (13:49 +0000)
committerAndrey Churbanov <Andrey.Churbanov@intel.com>
Wed, 14 Nov 2018 13:49:41 +0000 (13:49 +0000)
Do not write to internal structure if it keeps same value.

Differential Revision: https://reviews.llvm.org/D54305

llvm-svn: 346862

openmp/runtime/src/kmp_runtime.cpp

index b861c06..f2e9956 100644 (file)
@@ -2649,6 +2649,8 @@ void __kmp_set_num_threads(int new_nth, int gtid) {
 
   KMP_COUNT_VALUE(OMP_set_numthreads, new_nth);
   thread = __kmp_threads[gtid];
+  if (thread->th.th_current_task->td_icvs.nproc == new_nth)
+    return; // nothing to do
 
   __kmp_save_internal_controls(thread);