[libcxx-commits] [pstl] 26b0a23 - [pstl] Fix a few errors when running PSTL tests through the libc++ test suite

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 8 11:39:24 PDT 2020


Author: Louis Dionne
Date: 2020-07-08T14:39:16-04:00
New Revision: 26b0a23084f049f4084fc9f1d599ade66e4af185

URL: https://github.com/llvm/llvm-project/commit/26b0a23084f049f4084fc9f1d599ade66e4af185
DIFF: https://github.com/llvm/llvm-project/commit/26b0a23084f049f4084fc9f1d599ade66e4af185.diff

LOG: [pstl] Fix a few errors when running PSTL tests through the libc++ test suite

Added: 
    

Modified: 
    pstl/include/pstl/internal/algorithm_impl.h
    pstl/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp
    pstl/test/std/numerics/numeric.ops/transform_reduce.pass.cpp

Removed: 
    


################################################################################
diff  --git a/pstl/include/pstl/internal/algorithm_impl.h b/pstl/include/pstl/internal/algorithm_impl.h
index 01a9405e6130..b4e1c146188f 100644
--- a/pstl/include/pstl/internal/algorithm_impl.h
+++ b/pstl/include/pstl/internal/algorithm_impl.h
@@ -3057,11 +3057,11 @@ __pattern_set_union(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forw
     if (__n1 + __n2 <= __set_algo_cut_off)
         return std::set_union(__first1, __last1, __first2, __last2, __result, __comp);
 
-    typedef typename std::iterator_traits<_OutputIterator>::value_type _T;
+    typedef typename std::iterator_traits<_OutputIterator>::value_type _Tp;
     return __parallel_set_union_op(
         std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __result, __comp,
         [](_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,
-           _T* __result, _Compare __comp) {
+           _Tp* __result, _Compare __comp) {
             return __pstl::__utils::__set_union_construct(__first1, __last1, __first2, __last2, __result, __comp,
                                                           __BrickCopyConstruct<_IsVector>());
         },
@@ -3248,7 +3248,7 @@ __pattern_set_
diff erence(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1,
 
     if (__n1 + __n2 > __set_algo_cut_off)
         return __parallel_set_op(std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __result,
-                                 __comp, [](_DifferenceType __n, _DifferenceType __m) { return __n; },
+                                 __comp, [](_DifferenceType __n, _DifferenceType) { return __n; },
                                  [](_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
                                     _ForwardIterator2 __last2, _Tp* __result, _Compare __comp) {
                                      return __pstl::__utils::__set_
diff erence_construct(

diff  --git a/pstl/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp b/pstl/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp
index c85d0e9244fc..4b2b93dc8e30 100644
--- a/pstl/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp
+++ b/pstl/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp
@@ -76,8 +76,7 @@ struct test_set_union
 
     template <typename Policy, typename InputIterator1, typename InputIterator2, typename Compare>
     typename std::enable_if<TestUtils::isReverse<InputIterator1>::value, void>::type
-    operator()(Policy&& exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
-               Compare comp)
+    operator()(Policy&&, InputIterator1, InputIterator1, InputIterator2, InputIterator2, Compare)
     {
     }
 };
@@ -107,8 +106,7 @@ struct test_set_intersection
 
     template <typename Policy, typename InputIterator1, typename InputIterator2, typename Compare>
     typename std::enable_if<TestUtils::isReverse<InputIterator1>::value, void>::type
-    operator()(Policy&& exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
-               Compare comp)
+    operator()(Policy&&, InputIterator1, InputIterator1, InputIterator2, InputIterator2, Compare)
     {
     }
 };
@@ -138,8 +136,7 @@ struct test_set_
diff erence
 
     template <typename Policy, typename InputIterator1, typename InputIterator2, typename Compare>
     typename std::enable_if<TestUtils::isReverse<InputIterator1>::value, void>::type
-    operator()(Policy&& exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
-               Compare comp)
+    operator()(Policy&&, InputIterator1, InputIterator1, InputIterator2, InputIterator2, Compare)
     {
     }
 };
@@ -190,7 +187,7 @@ test_set(Compare compare)
         for (std::size_t m = 0; m < n_max; m = m <= 16 ? m + 1 : size_t(2.71828 * m))
         {
             //prepare the input ranges
-            Sequence<T1> in1(n, [n](std::size_t k) { return rand() % (2 * k + 1); });
+            Sequence<T1> in1(n, [](std::size_t k) { return rand() % (2 * k + 1); });
             Sequence<T2> in2(m, [m](std::size_t k) { return (m % 2) * rand() + rand() % (k + 1); });
 
             std::sort(in1.begin(), in1.end(), compare);

diff  --git a/pstl/test/std/numerics/numeric.ops/transform_reduce.pass.cpp b/pstl/test/std/numerics/numeric.ops/transform_reduce.pass.cpp
index 7341ed570cd9..dd8bb875e8e3 100644
--- a/pstl/test/std/numerics/numeric.ops/transform_reduce.pass.cpp
+++ b/pstl/test/std/numerics/numeric.ops/transform_reduce.pass.cpp
@@ -18,14 +18,6 @@
 
 using namespace TestUtils;
 
-// Equal for all types
-template <typename T>
-static bool
-Equal(T x, T y)
-{
-    return x == y;
-}
-
 // Functor for xor-operation for modeling binary operations in inner_product
 class XOR
 {
@@ -57,11 +49,13 @@ class MyClass
     {
         return MyClass(-x.my_field);
     }
-    friend MyClass operator*(const MyClass& x, const MyClass& y) { return MyClass(x.my_field * y.my_field); }
-    bool
-    operator==(const MyClass& in)
+    friend MyClass operator*(const MyClass& x, const MyClass& y)
+    {
+        return MyClass(x.my_field * y.my_field);
+    }
+    friend bool operator==(const MyClass& x, const MyClass& y)
     {
-        return my_field == in.my_field;
+        return x.my_field == y.my_field;
     }
 };
 
@@ -69,7 +63,7 @@ template <typename T>
 void
 CheckResults(const T& expected, const T& in)
 {
-    EXPECT_TRUE(Equal(expected, in), "wrong result of transform_reduce");
+    EXPECT_TRUE(expected == in, "wrong result of transform_reduce");
 }
 
 // We need to check correctness only for "int" (for example) except cases


        


More information about the libcxx-commits mailing list