Replace direct PSTL uses of assert() with a macro
authorThomas Rodgers <trodgers@redhat.com>
Thu, 11 Apr 2019 20:40:40 +0000 (20:40 +0000)
committerThomas Rodgers <rodgertq@gcc.gnu.org>
Thu, 11 Apr 2019 20:40:40 +0000 (20:40 +0000)
This also replaces calls to __TBB_ASSERT so that there are two macro
definitions provided by c++config -
    __PSTL_ASSERT(_Condition)
    __PSTL_ASSERT_MSG(_Condition, _Message)

    * include/bits/c++config:
    Add definition for __PSTL_ASSERT.
    Add definition for __PSTL_ASSERT_MSG.
    * include/pstl/algorithm_impl.h: Replace use of assert().
    * include/pstl/numeric_impl.h: Replace use of assert().
    * include/pstl/parallel_backend_tbb.h:
    Replace use of assert().
    Replace use of __TBB_ASSERT().

    * include/pstl/parallel_backend_utils.h: Replace use of assert().

From-SVN: r270293

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/c++config
libstdc++-v3/include/pstl/algorithm_impl.h
libstdc++-v3/include/pstl/numeric_impl.h
libstdc++-v3/include/pstl/parallel_backend_tbb.h
libstdc++-v3/include/pstl/parallel_backend_utils.h

index d49ce7c050fff500c37234b8609d1b99cc019268..ae1ec87f229ab113d4305be5b420a1385722b274 100644 (file)
@@ -1,3 +1,16 @@
+2019-04-11  Thomas Rodgers  <trodgers@redhat.com>
+
+       * include/bits/c++config:
+       Add definition for __PSTL_ASSERT.
+       Add definition for __PSTL_ASSERT_MSG.
+       * include/pstl/algorithm_impl.h: Replace use of assert().
+       * include/pstl/numeric_impl.h: Replace use of assert().
+       * include/pstl/parallel_backend_tbb.h:
+       Replace use of assert().
+       Replace use of __TBB_ASSERT().
+
+       * include/pstl/parallel_backend_utils.h: Replace use of assert().
+
 2019-04-11  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/90046
index 66420a9a3f25dec59cceaac977ea60dcb554d063..ef8ba96737bb731929f059e961dd7635e1d41087 100644 (file)
@@ -690,6 +690,10 @@ namespace std
 #  undef __PSTL_PAR_BACKEND_TBB
 # endif
 
+# define __PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition)
+# define __PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition)
+
+
 # define __PSTL_PRAGMA(x) _Pragma (#x)
 
 # define __PSTL_STRING_AUX(x) #x
index e06bf60151e7b2a09745750198868d31193f267e..b0d60baae142d04199ca45420f37741ebc19c9fd 100644 (file)
@@ -2731,8 +2731,8 @@ __pattern_includes(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forwa
          return !__internal::__parallel_or(
             std::forward<_ExecutionPolicy>(__exec), __first2, __last2,
             [__first1, __last1, __first2, __last2, &__comp](_ForwardIterator2 __i, _ForwardIterator2 __j) {
-                assert(__j > __i);
-                //assert(__j - __i > 1);
+                __PSTL_ASSERT(__j > __i);
+                //__PSTL_ASSERT(__j - __i > 1);
 
                 //1. moving boundaries to "consume" subsequence of equal elements
                 auto __is_equal = [&__comp](_ForwardIterator2 __a, _ForwardIterator2 __b) -> bool {
@@ -2756,8 +2756,8 @@ __pattern_includes(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forwa
                 //2. testing is __a subsequence of the second range included into the first range
                 auto __b = std::lower_bound(__first1, __last1, *__i, __comp);
 
-                assert(!__comp(*(__last1 - 1), *__b));
-                assert(!__comp(*(__j - 1), *__i));
+                __PSTL_ASSERT(!__comp(*(__last1 - 1), *__b));
+                __PSTL_ASSERT(!__comp(*(__j - 1), *__i));
                 return !std::includes(__b, __last1, __i, __j, __comp);
             });
     });
@@ -2948,7 +2948,7 @@ __parallel_set_union_op(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _
     }
 
     const auto __m2 = __left_bound_seq_2 - __first2;
-    assert(__m1 == 0 || __m2 == 0);
+    __PSTL_ASSERT(__m1 == 0 || __m2 == 0);
     if (__m2 > __set_algo_cut_off)
     {
         auto __res_or = __result;
index 49a4abf5a95c879b4e454ef5d7367f869b485038..738a61d92f639a223a1ccd335154f4519e289a1a 100644 (file)
@@ -314,7 +314,7 @@ _ForwardIterator2
 __brick_adjacent_difference(_ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first,
                             BinaryOperation __op, /*is_vector=*/std::true_type) noexcept
 {
-    assert(__first != __last);
+    __PSTL_ASSERT(__first != __last);
 
     typedef typename std::iterator_traits<_ForwardIterator1>::reference _ReferenceType1;
     typedef typename std::iterator_traits<_ForwardIterator2>::reference _ReferenceType2;
@@ -344,7 +344,7 @@ __pattern_adjacent_difference(_ExecutionPolicy&& __exec, _ForwardIterator1 __fir
                               _ForwardIterator2 __d_first, _BinaryOperation __op, _IsVector __is_vector,
                               /*is_parallel=*/std::true_type)
 {
-    assert(__first != __last);
+    __PSTL_ASSERT(__first != __last);
     typedef typename std::iterator_traits<_ForwardIterator1>::reference _ReferenceType1;
     typedef typename std::iterator_traits<_ForwardIterator2>::reference _ReferenceType2;
 
index f09f47a8a8923d146a42745075f9baf4e0e27956..fc1ffa7383f6e300ec94c27fbe6f2d7867086d07 100644 (file)
@@ -10,7 +10,6 @@
 #ifndef __PSTL_parallel_backend_tbb_H
 #define __PSTL_parallel_backend_tbb_H
 
-#include <cassert>
 #include <algorithm>
 #include <type_traits>
 
@@ -139,7 +138,7 @@ struct __par_trans_red_body
     _Tp&
     sum()
     {
-        __TBB_ASSERT(_M_has_sum, "sum expected");
+        __PSTL_ASSERT_MSG(_M_has_sum, "sum expected");
         return *(_Tp*)_M_sum_storage;
     }
     __par_trans_red_body(_Up __u, _Tp __init, _Cp __c, _Rp __r)
@@ -173,7 +172,7 @@ struct __par_trans_red_body
         _Index __j = __range.end();
         if (!_M_has_sum)
         {
-            __TBB_ASSERT(__range.size() > 1, "there should be at least 2 elements");
+            __PSTL_ASSERT_MSG(__range.size() > 1, "there should be at least 2 elements");
             new (&_M_sum_storage)
                 _Tp(_M_combine(_M_u(__i), _M_u(__i + 1))); // The condition i+1 < j is provided by the grain size of 3
             _M_has_sum = true;
@@ -233,7 +232,7 @@ class __trans_scan_body
     _Tp&
     sum() const
     {
-        __TBB_ASSERT(_M_has_sum, "sum expected");
+        __PSTL_ASSERT_MSG(_M_has_sum, "sum expected");
         return *const_cast<_Tp*>(reinterpret_cast<_Tp const*>(_M_sum_storage));
     }
 
@@ -591,7 +590,7 @@ __parallel_stable_sort(_ExecutionPolicy&&, _RandomAccessIterator __xs, _RandomAc
         const _DifferenceType __sort_cut_off = __PSTL_STABLE_SORT_CUT_OFF;
         if (__n > __sort_cut_off)
         {
-            assert(__nsort > 0 && __nsort <= __n);
+            __PSTL_ASSERT(__nsort > 0 && __nsort <= __n);
             __buffer<_ValueType> __buf(__n);
             using tbb::task;
             task::spawn_root_and_wait(*new (task::allocate_root())
index 6313890144a8b620019032cfed53f7d8d2ef4c6d..4ec5319a9377337bfbeb65c04f8793ffd95564ef 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <iterator>
 #include <utility>
-#include <cassert>
 #include "utils.h"
 
 namespace __pstl
@@ -54,7 +53,7 @@ struct __serial_move_merge
                _RandomAccessIterator2 __ye, _RandomAccessIterator3 __zs, _Compare __comp)
     {
         auto __n = _M_nmerge;
-        assert(__n > 0);
+        __PSTL_ASSERT(__n > 0);
         if (__xs != __xe)
         {
             if (__ys != __ye)
@@ -146,7 +145,7 @@ class __stack
 
     ~__stack()
     {
-        assert(size() <= _M_maxsize);
+        __PSTL_ASSERT(size() <= _M_maxsize);
         while (!empty())
             pop();
     }
@@ -159,20 +158,20 @@ class __stack
     size_t
     size() const
     {
-        assert(_M_ptr - _M_buf.get() <= _M_maxsize);
-        assert(_M_ptr - _M_buf.get() >= 0);
+        __PSTL_ASSERT(_M_ptr - _M_buf.get() <= _M_maxsize);
+        __PSTL_ASSERT(_M_ptr - _M_buf.get() >= 0);
         return _M_ptr - _M_buf.get();
     }
     bool
     empty() const
     {
-        assert(_M_ptr >= _M_buf.get());
+        __PSTL_ASSERT(_M_ptr >= _M_buf.get());
         return _M_ptr == _M_buf.get();
     }
     void
     push(const _ValueType& __v)
     {
-        assert(size() < _M_maxsize);
+        __PSTL_ASSERT(size() < _M_maxsize);
         new (_M_ptr) _ValueType(__v);
         ++_M_ptr;
     }
@@ -184,7 +183,7 @@ class __stack
     void
     pop()
     {
-        assert(_M_ptr > _M_buf.get());
+        __PSTL_ASSERT(_M_ptr > _M_buf.get());
         --_M_ptr;
         (*_M_ptr).~_ValueType();
     }