[OpenMP][NFC] libomp: fix wrong debug assertion.
authorAndreyChurbanov <andrey.churbanov@intel.com>
Thu, 24 Jun 2021 23:02:14 +0000 (02:02 +0300)
committerAndreyChurbanov <andrey.churbanov@intel.com>
Thu, 24 Jun 2021 23:02:14 +0000 (02:02 +0300)
Normalized bounds of chunk of iterations to steal from are inclusive,
so upper bound should not be decremented in expression to check.
Problem was in attempt to steal iterations 0:0, that caused assertion after
wrong decrement. Reported in comment to https://reviews.llvm.org/D103648.

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

openmp/runtime/src/kmp_dispatch.cpp

index 6687c37..cc2d001 100644 (file)
@@ -1450,7 +1450,7 @@ int __kmp_dispatch_next_algorithm(int gtid,
             } else {
               vnew.p.ub -= 1; // steal 1 chunk of 1..7 remaining
             }
-            KMP_DEBUG_ASSERT((vnew.p.ub - 1) * (UT)chunk <= trip);
+            KMP_DEBUG_ASSERT(vnew.p.ub * (UT)chunk <= trip);
             if (KMP_COMPARE_AND_STORE_REL64(
                     (volatile kmp_int64 *)&v->u.p.count,
                     *VOLATILE_CAST(kmp_int64 *) & vold.b,