diff --git a/CHANGES b/CHANGES
index 0a71b8f6c35..5dfcb94a437 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,22 @@
------------------------------------------------------------------------
The list of most significant changes made over time in Parallel STL.
+Parallel STL release within Intel(R) Parallel Studio XE 2020 Update 4
+__INTEL_PSTL_VERSION == 212
+
+Features / APIs:
+
+- Improved performance in is_heap, includes, partial_sort algorithms.
+
+Bugs fixed:
+
+- Fixed search_n to return the first element if the requested
+ value count is zero or negative.
+- Usage of non-trivial types is fixed for the following
+ algorithms: remove_if, unique, rotate, partial_sort_copy,
+ set_intersection, set_union, set_difference, set_symmetric_difference.
+
+------------------------------------------------------------------------
Parallel STL release within Intel(R) Parallel Studio XE 2020 Update 1
__INTEL_PSTL_VERSION == 211
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 878b2125952..d94f4864df1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
##===-- CMakeLists.txt ----------------------------------------------------===##
#
-# Copyright (C) 2018-2019 Intel Corporation
+# Copyright (C) 2018-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/README.md b/README.md
index 24ab933aefe..29d5a512f36 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# Parallel STL
-[![Stable release](https://img.shields.io/badge/version-20200330-green.svg)](https://github.com/intel/parallelstl/releases/tag/20200330)
+[![Stable release](https://img.shields.io/badge/version-20201111-green.svg)](https://github.com/intel/parallelstl/releases/tag/20201111)
Parallel STL is an implementation of the C++ standard library algorithms with support for execution policies,
as specified in ISO/IEC 14882:2017 standard, commonly called C++17.
diff --git a/Release_Notes.txt b/Release_Notes.txt
index 9e82c684c0a..57fa1e9bbb0 100644
--- a/Release_Notes.txt
+++ b/Release_Notes.txt
@@ -24,13 +24,13 @@ Hardware - Recommended
macOS* Systems
Intel(R) Core(TM) processor family
Android* Systems
- Intel(R) Atom(TM) processor family
+ Intel Atom(R) processor family
Hardware - Supported
Intel(R) Pentium(R) 4 processor family
Intel(R) Xeon Phi(TM) coprocessor
- Intel(R) Atom(TM) processor family
+ Intel Atom(R) processor family
Non Intel(R) processors compatible with the above processors
Software - Minimum Requirements
diff --git a/build/Makefile b/build/Makefile
index 6e17f42f651..1223467876f 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -1,6 +1,6 @@
##===-- Makefile ----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/Makefile.common b/build/Makefile.common
index 43b74bbe959..307962990d2 100644
--- a/build/Makefile.common
+++ b/build/Makefile.common
@@ -1,6 +1,6 @@
##===-- Makefile.common ---------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/Makefile.pstl b/build/Makefile.pstl
index 7b40372c3c7..8f493635d2e 100644
--- a/build/Makefile.pstl
+++ b/build/Makefile.pstl
@@ -1,6 +1,6 @@
##===-- Makefile.pstl -----------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/android.inc b/build/android.inc
index b6b9542988b..2f7da4947b1 100644
--- a/build/android.inc
+++ b/build/android.inc
@@ -1,6 +1,6 @@
##===-- android.inc -------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/android.linux.launcher.sh b/build/android.linux.launcher.sh
index 1676a1af810..d4721419d42 100755
--- a/build/android.linux.launcher.sh
+++ b/build/android.linux.launcher.sh
@@ -1,7 +1,7 @@
#!/bin/sh
##===-- android.linux.launcher.sh -----------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/clang.inc b/build/clang.inc
index 8a7a276dd57..42ce9634c5e 100644
--- a/build/clang.inc
+++ b/build/clang.inc
@@ -1,6 +1,6 @@
##===-- clang.inc ---------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/gcc.inc b/build/gcc.inc
index ebfe3f9b329..18692a9aa8d 100644
--- a/build/gcc.inc
+++ b/build/gcc.inc
@@ -1,6 +1,6 @@
##===-- gcc.inc -----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/icc.inc b/build/icc.inc
index 43d175230f3..f4d69b5ff9f 100644
--- a/build/icc.inc
+++ b/build/icc.inc
@@ -1,6 +1,6 @@
##===-- icc.inc -----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/icl.inc b/build/icl.inc
index 4b0f4d25c35..f2d5a10b6a6 100644
--- a/build/icl.inc
+++ b/build/icl.inc
@@ -1,6 +1,6 @@
##===-- icl.inc -----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/jni/Android.mk b/build/jni/Android.mk
index 7910ac11c43..9a6a15cf972 100644
--- a/build/jni/Android.mk
+++ b/build/jni/Android.mk
@@ -1,6 +1,6 @@
##===-- Android.mk --------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/jni/Application.mk b/build/jni/Application.mk
index 1e1132cf61a..2ef63eba16c 100644
--- a/build/jni/Application.mk
+++ b/build/jni/Application.mk
@@ -1,6 +1,6 @@
##===-- Application.mk ----------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/macos.inc b/build/macos.inc
index c32d68a8ed8..5e1a34108bc 100644
--- a/build/macos.inc
+++ b/build/macos.inc
@@ -1,6 +1,6 @@
##===-- macos.inc ---------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/mingw.inc b/build/mingw.inc
index e34214598d5..59b314ca92e 100644
--- a/build/mingw.inc
+++ b/build/mingw.inc
@@ -1,6 +1,6 @@
##===-- mingw.inc ---------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/unix.inc b/build/unix.inc
index 4f7c0dc2d29..415db9ac884 100644
--- a/build/unix.inc
+++ b/build/unix.inc
@@ -1,6 +1,6 @@
##===-- unix.inc ----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/build/windows.inc b/build/windows.inc
index 9902c152fe0..9e8484b1584 100644
--- a/build/windows.inc
+++ b/build/windows.inc
@@ -1,6 +1,6 @@
##===-- windows.inc -------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/cmake/ParallelSTLConfig.cmake.in b/cmake/ParallelSTLConfig.cmake.in
index 0e16bfab02e..6583efc3165 100644
--- a/cmake/ParallelSTLConfig.cmake.in
+++ b/cmake/ParallelSTLConfig.cmake.in
@@ -1,6 +1,6 @@
##===-- ParallelSTLConfig.cmake.in ----------------------------------------===##
#
-# Copyright (C) 2018-2019 Intel Corporation
+# Copyright (C) 2018-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/examples/convex_hull/CMakeLists.txt b/examples/convex_hull/CMakeLists.txt
index 3ed8a1226a6..f1b7ece469c 100644
--- a/examples/convex_hull/CMakeLists.txt
+++ b/examples/convex_hull/CMakeLists.txt
@@ -1,6 +1,6 @@
##===-- CMakeLists.txt ----------------------------------------------------===##
#
-# Copyright (C) 2019 Intel Corporation
+# Copyright (C) 2019-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/examples/convex_hull/Makefile b/examples/convex_hull/Makefile
index fc3508ddac5..2e0682df106 100644
--- a/examples/convex_hull/Makefile
+++ b/examples/convex_hull/Makefile
@@ -1,6 +1,6 @@
##===-- Makefile ----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/examples/convex_hull/Makefile.windows b/examples/convex_hull/Makefile.windows
index 844d51b61d2..dc422f689dd 100644
--- a/examples/convex_hull/Makefile.windows
+++ b/examples/convex_hull/Makefile.windows
@@ -1,6 +1,6 @@
##===-- Makefile ----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/examples/convex_hull/convex_hull.cpp b/examples/convex_hull/convex_hull.cpp
index 9ebf48010eb..d6785eec4ac 100644
--- a/examples/convex_hull/convex_hull.cpp
+++ b/examples/convex_hull/convex_hull.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- convex_hull.cpp ---------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/examples/convex_hull/readme.html b/examples/convex_hull/readme.html
index 5cfaa47b72a..b4d0427c7a7 100644
--- a/examples/convex_hull/readme.html
+++ b/examples/convex_hull/readme.html
@@ -391,7 +391,7 @@
Parallel STL.
convex_hull sample
Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
* Other names and brands may be claimed as the property of others.
-
© 2017-2019, Intel Corporation
+
© 2017-2020, Intel Corporation
diff --git a/examples/convex_hull/utils.h b/examples/convex_hull/utils.h
index 7c14e4008c0..195c72501cd 100644
--- a/examples/convex_hull/utils.h
+++ b/examples/convex_hull/utils.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- utils.h -----------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/examples/dot_product/CMakeLists.txt b/examples/dot_product/CMakeLists.txt
index 28c68806004..3a1da73f132 100644
--- a/examples/dot_product/CMakeLists.txt
+++ b/examples/dot_product/CMakeLists.txt
@@ -1,6 +1,6 @@
##===-- CMakeLists.txt ----------------------------------------------------===##
#
-# Copyright (C) 2019 Intel Corporation
+# Copyright (C) 2019-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/examples/dot_product/Makefile b/examples/dot_product/Makefile
index 80caaa38275..aec8b6022a8 100644
--- a/examples/dot_product/Makefile
+++ b/examples/dot_product/Makefile
@@ -1,6 +1,6 @@
##===-- Makefile ----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/examples/dot_product/Makefile.windows b/examples/dot_product/Makefile.windows
index 3853f523244..db07f71c008 100644
--- a/examples/dot_product/Makefile.windows
+++ b/examples/dot_product/Makefile.windows
@@ -1,6 +1,6 @@
##===-- Makefile ----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/examples/dot_product/dot_product.cpp b/examples/dot_product/dot_product.cpp
index d3e6ed01b54..26a2e09b641 100644
--- a/examples/dot_product/dot_product.cpp
+++ b/examples/dot_product/dot_product.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- dot_product.cpp ---------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/examples/dot_product/readme.html b/examples/dot_product/readme.html
index e41d57367e2..1db1266d56f 100644
--- a/examples/dot_product/readme.html
+++ b/examples/dot_product/readme.html
@@ -384,7 +384,7 @@ Parallel STL.
Dot_product sample
Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
* Other names and brands may be claimed as the property of others.
-
© 2017-2019, Intel Corporation
+
© 2017-2020, Intel Corporation
diff --git a/examples/gamma_correction/CMakeLists.txt b/examples/gamma_correction/CMakeLists.txt
index 649e1e7170f..20433837886 100644
--- a/examples/gamma_correction/CMakeLists.txt
+++ b/examples/gamma_correction/CMakeLists.txt
@@ -1,6 +1,6 @@
##===-- CMakeLists.txt ----------------------------------------------------===##
#
-# Copyright (C) 2018-2019 Intel Corporation
+# Copyright (C) 2018-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/examples/gamma_correction/Makefile b/examples/gamma_correction/Makefile
index a700e992395..9c2f45ca907 100644
--- a/examples/gamma_correction/Makefile
+++ b/examples/gamma_correction/Makefile
@@ -1,6 +1,6 @@
##===-- Makefile ----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/examples/gamma_correction/Makefile.windows b/examples/gamma_correction/Makefile.windows
index b13af22b86b..71d89e42516 100644
--- a/examples/gamma_correction/Makefile.windows
+++ b/examples/gamma_correction/Makefile.windows
@@ -1,6 +1,6 @@
##===-- Makefile ----------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/examples/gamma_correction/gamma_correction.cpp b/examples/gamma_correction/gamma_correction.cpp
index a2aca7eb263..7aac2bd15c0 100644
--- a/examples/gamma_correction/gamma_correction.cpp
+++ b/examples/gamma_correction/gamma_correction.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- gamma_correction.cpp ----------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/examples/gamma_correction/readme.html b/examples/gamma_correction/readme.html
index a13e1f6e2dd..3df9c4d7a2b 100644
--- a/examples/gamma_correction/readme.html
+++ b/examples/gamma_correction/readme.html
@@ -394,7 +394,7 @@ Parallel STL.
Gamma_correction sample
Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
* Other names and brands may be claimed as the property of others.
-
© 2017-2019, Intel Corporation
+
© 2017-2020, Intel Corporation
diff --git a/examples/gamma_correction/utils.cpp b/examples/gamma_correction/utils.cpp
index e9eaaf4e599..f51c65c84d7 100644
--- a/examples/gamma_correction/utils.cpp
+++ b/examples/gamma_correction/utils.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- utils.cpp ---------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -89,7 +89,7 @@ void image::write(const char* fname) const {
assert(my_width > 0 && my_height > 0);
- std::ofstream stream(fname);
+ std::ofstream stream(fname, std::ios::binary);
assert(file.sizeRest == sizeof(file)-sizeof(file.sizeRest));
stream.write((char*)&file.type, file.sizeRest);
diff --git a/examples/gamma_correction/utils.h b/examples/gamma_correction/utils.h
index 1f13beb01be..522269911b2 100644
--- a/examples/gamma_correction/utils.h
+++ b/examples/gamma_correction/utils.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- utils.h -----------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/experimental/algorithm b/include/pstl/experimental/algorithm
index 6f81ce1ce8a..05b731133ca 100644
--- a/include/pstl/experimental/algorithm
+++ b/include/pstl/experimental/algorithm
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- algorithm ---------------------------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/experimental/internal/for_loop.h b/include/pstl/experimental/internal/for_loop.h
index b872a03e842..9017362a060 100644
--- a/include/pstl/experimental/internal/for_loop.h
+++ b/include/pstl/experimental/internal/for_loop.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- for_loop.h --------------------------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/experimental/internal/for_loop_impl.h b/include/pstl/experimental/internal/for_loop_impl.h
index d63d2ec9454..991568c9fff 100644
--- a/include/pstl/experimental/internal/for_loop_impl.h
+++ b/include/pstl/experimental/internal/for_loop_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- for_loop_impl.h ---------------------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/experimental/internal/induction.h b/include/pstl/experimental/internal/induction.h
index 7bbb4e1889f..3e1d0bf9781 100644
--- a/include/pstl/experimental/internal/induction.h
+++ b/include/pstl/experimental/internal/induction.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- induction.h -------------------------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/experimental/internal/induction_impl.h b/include/pstl/experimental/internal/induction_impl.h
index 5cd2b5aac44..5e836598991 100644
--- a/include/pstl/experimental/internal/induction_impl.h
+++ b/include/pstl/experimental/internal/induction_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- induction_impl.h --------------------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/experimental/internal/reduction.h b/include/pstl/experimental/internal/reduction.h
index acfe4400ee7..24025134de0 100644
--- a/include/pstl/experimental/internal/reduction.h
+++ b/include/pstl/experimental/internal/reduction.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- reduction.h -------------------------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/experimental/internal/reduction_impl.h b/include/pstl/experimental/internal/reduction_impl.h
index ac51f5e59a5..0e726a88262 100644
--- a/include/pstl/experimental/internal/reduction_impl.h
+++ b/include/pstl/experimental/internal/reduction_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- reduction_impl.h --------------------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/algorithm_fwd.h b/include/pstl/internal/algorithm_fwd.h
index 5f0c8271cec..dc465f22c3d 100644
--- a/include/pstl/internal/algorithm_fwd.h
+++ b/include/pstl/internal/algorithm_fwd.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -1267,6 +1267,30 @@ __pattern_is_heap_until(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccess
/* is_parallel = */ std::true_type);
#endif
+//------------------------------------------------------------------------
+// is_heap
+//------------------------------------------------------------------------
+
+template
+bool __brick_is_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare,
+ /* __is_vector = */ std::false_type) noexcept;
+
+template
+bool __brick_is_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare,
+ /* __is_vector = */ std::true_type) noexcept;
+
+template
+bool
+__pattern_is_heap(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare, _IsVector,
+ /* is_parallel = */ std::false_type) noexcept;
+
+#if _PSTL_USE_PAR_POLICIES
+template
+bool
+__pattern_is_heap(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare, _IsVector,
+ /* is_parallel = */ std::true_type);
+#endif
+
//------------------------------------------------------------------------
// min_element
//------------------------------------------------------------------------
diff --git a/include/pstl/internal/algorithm_impl.h b/include/pstl/internal/algorithm_impl.h
index b647d4208f3..1fb2a6f6628 100644
--- a/include/pstl/internal/algorithm_impl.h
+++ b/include/pstl/internal/algorithm_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -789,9 +789,14 @@ _RandomAccessIterator
__find_subrange(_RandomAccessIterator __first, _RandomAccessIterator __last, _RandomAccessIterator __global_last,
_Size __count, const _Tp& __value, _BinaryPredicate __pred, _IsVector __is_vector) noexcept
{
- if (__global_last - __first < __count || __count < 1)
+ if (__count < 1)
{
- return __last; // According to the standard last shall be returned when count < 1
+ return __first;
+ }
+
+ if (__global_last - __first < __count)
+ {
+ return __last;
}
auto __n = __global_last - __first;
@@ -1121,6 +1126,40 @@ struct __brick_move<_ExecutionPolicy>
}
};
+template
+struct __brick_move_destroy;
+
+template
+struct __brick_move_destroy<_ExecutionPolicy, void>
+{
+ template
+ _OutputIterator
+ operator()(_Iterator __first, _Iterator __last, _OutputIterator __result, /*vec*/ std::true_type) const
+ {
+ using _IteratorValueType = typename std::iterator_traits<_Iterator>::value_type;
+
+ return __unseq_backend::__simd_assign(__first, __last - __first, __result,
+ [](_Iterator __first, _OutputIterator __result) {
+ *__result = std::move(*__first);
+ (*__first).~_IteratorValueType();
+ });
+ }
+
+ template
+ _OutputIterator
+ operator()(_Iterator __first, _Iterator __last, _OutputIterator __result, /*vec*/ std::false_type) const
+ {
+ using _IteratorValueType = typename std::iterator_traits<_Iterator>::value_type;
+
+ for (; __first != __last; ++__first, ++__result)
+ {
+ *__result = std::move(*__first);
+ (*__first).~_IteratorValueType();
+ }
+ return __result;
+ }
+};
+
//------------------------------------------------------------------------
// swap_ranges
//------------------------------------------------------------------------
@@ -1445,11 +1484,16 @@ __remove_elements(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardI
[&__m](_DifferenceType __total) { __m = __total; });
// 3. Elements from result are moved to [first, last)
- __par_backend::__parallel_for(std::forward<_ExecutionPolicy>(__exec), __result, __result + __m,
- [__result, __first, __is_vector](_Tp* __i, _Tp* __j) {
- __brick_move<_ExecutionPolicy>{}(__i, __j, __first + (__i - __result),
- __is_vector);
- });
+ __par_backend::__parallel_for(
+ std::forward<_ExecutionPolicy>(__exec), __result, __result + __m,
+ [__result, __first, __is_vector](_Tp* __i, _Tp* __j) {
+ __invoke_if_else(
+ std::is_trivial<_Tp>(),
+ [&]() { __brick_move<_ExecutionPolicy>{}(__i, __j, __first + (__i - __result), __is_vector); },
+ [&]() {
+ __brick_move_destroy<_ExecutionPolicy>{}(__i, __j, __first + (__i - __result), __is_vector);
+ });
+ });
return __first + __m;
});
}
@@ -1808,8 +1852,8 @@ __pattern_rotate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIt
__par_backend::__parallel_for(std::forward<_ExecutionPolicy>(__exec), __result, __result + (__n - __m),
[__first, __result, __is_vector](_Tp* __b, _Tp* __e) {
- __brick_move<_ExecutionPolicy>{}(__b, __e, __first + (__b - __result),
- __is_vector);
+ __brick_move_destroy<_ExecutionPolicy>{}(
+ __b, __e, __first + (__b - __result), __is_vector);
});
return __first + (__last - __middle);
@@ -1834,7 +1878,7 @@ __pattern_rotate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIt
__par_backend::__parallel_for(std::forward<_ExecutionPolicy>(__exec), __result, __result + __m,
[__n, __m, __first, __result, __is_vector](_Tp* __b, _Tp* __e) {
- __brick_move<_ExecutionPolicy>{}(
+ __brick_move_destroy<_ExecutionPolicy>{}(
__b, __e, __first + ((__n - __m) + (__b - __result)), __is_vector);
});
@@ -2335,7 +2379,8 @@ __pattern_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _Random
__except_handler([&]() {
__par_backend::__parallel_stable_sort(std::forward<_ExecutionPolicy>(__exec), __first, __last, __comp,
[](_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Compare __comp) { std::sort(__first, __last, __comp); });
+ _Compare __comp) { std::sort(__first, __last, __comp); },
+ __last - __first);
});
}
#endif
@@ -2361,7 +2406,8 @@ __pattern_stable_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first,
__internal::__except_handler([&]() {
__par_backend::__parallel_stable_sort(std::forward<_ExecutionPolicy>(__exec), __first, __last, __comp,
[](_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Compare __comp) { std::stable_sort(__first, __last, __comp); });
+ _Compare __comp) { std::stable_sort(__first, __last, __comp); },
+ __last - __first);
});
}
#endif
@@ -2475,9 +2521,13 @@ __pattern_partial_sort_copy(_ExecutionPolicy&& __exec, _ForwardIterator __first,
// 3. Move elements from temporary buffer to output
__par_backend::__parallel_for(std::forward<_ExecutionPolicy>(__exec), __r, __r + __n2,
[__r, __d_first, __is_vector](_T1* __i, _T1* __j) {
- __brick_move<_ExecutionPolicy>{}(__i, __j, __d_first + (__i - __r),
- __is_vector);
+ __brick_move_destroy<_ExecutionPolicy>{}(
+ __i, __j, __d_first + (__i - __r), __is_vector);
});
+ __par_backend::__parallel_for(
+ std::forward<_ExecutionPolicy>(__exec), __r + __n2, __r + __n1,
+ [__is_vector](_T1* __i, _T1* __j) { __brick_destroy(__i, __j, __is_vector); });
+
return __d_first + __n2;
}
});
@@ -2944,7 +2994,7 @@ __pattern_inplace_merge(_ExecutionPolicy&& __exec, _BidirectionalIterator __firs
});
__par_backend::__parallel_for(
std::forward<_ExecutionPolicy>(__exec), __r, __r + __n, [__r, __first, __is_vector](_Tp* __i, _Tp* __j) {
- __brick_move<_ExecutionPolicy>{}(__i, __j, __first + (__i - __r), __is_vector);
+ __brick_move_destroy<_ExecutionPolicy>{}(__i, __j, __first + (__i - __r), __is_vector);
});
});
}
@@ -2973,7 +3023,12 @@ __pattern_includes(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forwa
if (__first2 >= __last2)
return true;
- if (__first1 >= __last1 || __comp(*__first2, *__first1) || __comp(*(__last1 - 1), *(__last2 - 1)))
+ //optimization; {1} - the first sequence, {2} - the second sequence
+ //{1} is empty or size_of{2} > size_of{1}
+ if (__first1 == __last1 || __last2 - __first2 > __last1 - __first1 ||
+ // {1}: [**********] or [**********]
+ // {2}: [***********] [***********]
+ __comp(*__first2, *__first1) || __comp(*(__last1 - 1), *(__last2 - 1)))
return false;
__first1 = std::lower_bound(__first1, __last1, *__first2, __comp);
@@ -3055,8 +3110,9 @@ __parallel_set_op(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forwar
_DifferenceType __m{};
auto __scan = [=](_DifferenceType, _DifferenceType, const _SetRange& __s) { // Scan
if (!__s.empty())
- __brick_move<_ExecutionPolicy>{}(__buffer + __s.__buf_pos, __buffer + (__s.__buf_pos + __s.__len),
- __result + __s.__pos, __is_vector);
+ __brick_move_destroy<_ExecutionPolicy>{}(__buffer + __s.__buf_pos,
+ __buffer + (__s.__buf_pos + __s.__len), __result + __s.__pos,
+ __is_vector);
};
__par_backend::__parallel_strict_scan(
std::forward<_ExecutionPolicy>(__exec), __n1, _SetRange{0, 0, 0}, //-1, 0},
@@ -3240,6 +3296,17 @@ __brick_set_union(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _Forwar
return std::set_union(__first1, __last1, __first2, __last2, __result, __comp);
}
+template
+struct __BrickCopyConstruct
+{
+ template
+ _OutputIterator
+ operator()(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result)
+ {
+ return __brick_uninitialized_copy(__first, __last, __result, _IsVector());
+ }
+};
+
template
_OutputIterator
__brick_set_union(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
@@ -3278,13 +3345,14 @@ __pattern_set_union(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forw
return std::set_union(__first1, __last1, __first2, __last2, __result, __comp);
typedef typename std::iterator_traits<_OutputIterator>::value_type _T;
- 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) {
- return std::set_union(__first1, __last1, __first2, __last2, __result, __comp);
- },
- __is_vector);
+ 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) {
+ return pstl::__utils::__set_union_construct(__first1, __last1, __first2, __last2, __result, __comp,
+ __BrickCopyConstruct<_IsVector>());
+ },
+ __is_vector);
}
#endif
@@ -3360,7 +3428,8 @@ __pattern_set_intersection(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1
[](_DifferenceType __n, _DifferenceType __m) { return std::min(__n, __m); },
[](_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
_ForwardIterator2 __last2, _T* __result, _Compare __comp) {
- return std::set_intersection(__first1, __last1, __first2, __last2, __result, __comp);
+ return pstl::__utils::__set_intersection_construct(__first1, __last1, __first2, __last2, __result,
+ __comp);
},
__is_vector);
}
@@ -3374,7 +3443,8 @@ __pattern_set_intersection(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1
[](_DifferenceType __n, _DifferenceType __m) { return std::min(__n, __m); },
[](_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
_ForwardIterator2 __last2, _T* __result, _Compare __comp) {
- return std::set_intersection(__first2, __last2, __first1, __last1, __result, __comp);
+ return pstl::__utils::__set_intersection_construct(__first2, __last2, __first1, __last1, __result,
+ __comp);
},
__is_vector);
return __result;
@@ -3460,7 +3530,9 @@ __pattern_set_difference(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1,
__comp, [](_DifferenceType __n, _DifferenceType __m) { return __n; },
[](_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
_ForwardIterator2 __last2, _T* __result, _Compare __comp) {
- return std::set_difference(__first1, __last1, __first2, __last2, __result, __comp);
+ return pstl::__utils::__set_difference_construct(
+ __first1, __last1, __first2, __last2, __result, __comp,
+ __BrickCopyConstruct<_IsVector>());
},
__is_vector);
@@ -3524,7 +3596,8 @@ __pattern_set_symmetric_difference(_ExecutionPolicy&& __exec, _ForwardIterator1
std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __result, __comp,
[](_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,
_T* __result, _Compare __comp) {
- return std::set_symmetric_difference(__first1, __last1, __first2, __last2, __result, __comp);
+ return pstl::__utils::__set_symmetric_difference_construct(__first1, __last1, __first2, __last2, __result,
+ __comp, __BrickCopyConstruct<_IsVector>());
},
__is_vector);
}
@@ -3547,8 +3620,6 @@ _RandomAccessIterator
__brick_is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
/* __is_vector = */ std::true_type) noexcept
{
- if (__last - __first < 2)
- return __last;
typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type _SizeType;
return __unseq_backend::__simd_first(
__first, _SizeType(0), __last - __first,
@@ -3570,12 +3641,8 @@ __is_heap_until_local(_RandomAccessIterator __first, _DifferenceType __begin, _D
{
_DifferenceType __i = __begin;
for (; __i < __end; ++__i)
- {
if (__comp(__first[(__i - 1) / 2], __first[__i]))
- {
break;
- }
- }
return __first + __i;
}
@@ -3595,9 +3662,6 @@ _RandomAccessIterator
__pattern_is_heap_until(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp, _IsVector __is_vector, /* is_parallel = */ std::true_type)
{
- if (__last - __first < 2)
- return __last;
-
return __internal::__except_handler([&]() {
return __parallel_find(std::forward<_ExecutionPolicy>(__exec), __first, __last,
[__first, __comp, __is_vector](_RandomAccessIterator __i, _RandomAccessIterator __j) {
@@ -3609,6 +3673,71 @@ __pattern_is_heap_until(_ExecutionPolicy&& __exec, _RandomAccessIterator __first
}
#endif
+//------------------------------------------------------------------------
+// is_heap
+//------------------------------------------------------------------------
+
+template
+bool
+__brick_is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+ /* __is_vector = */ std::false_type) noexcept
+{
+ return std::is_heap(__first, __last, __comp);
+}
+
+template
+bool
+__brick_is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+ /* __is_vector = */ std::true_type) noexcept
+{
+ return !__unseq_backend::__simd_or_iter(__first, __last - __first, [__first, &__comp](_RandomAccessIterator __it) {
+ return __comp(*(__first + (__it - __first - 1) / 2), *__it);
+ });
+}
+
+template
+bool
+__is_heap_local(_RandomAccessIterator __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp,
+ /* __is_vector = */ std::false_type) noexcept
+{
+ return __internal::__is_heap_until_local(__first, __begin, __end, __comp, std::false_type{}) == __first + __end;
+}
+
+template
+bool
+__is_heap_local(_RandomAccessIterator __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp,
+ /* __is_vector = */ std::true_type) noexcept
+{
+ return !__unseq_backend::__simd_or_iter(__first + __begin, __end - __begin,
+ [__first, &__comp](_RandomAccessIterator __it) {
+ return __comp(*(__first + (__it - __first - 1) / 2), *__it);
+ });
+}
+
+template
+bool
+__pattern_is_heap(_ExecutionPolicy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+ _IsVector __is_vector, /* is_parallel = */ std::false_type) noexcept
+{
+ return __internal::__brick_is_heap(__first, __last, __comp, __is_vector);
+}
+
+#if _PSTL_USE_PAR_POLICIES
+template
+bool
+__pattern_is_heap(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last,
+ _Compare __comp, _IsVector __is_vector, /* is_parallel = */ std::true_type)
+{
+ return __internal::__except_handler([&]() {
+ return !__parallel_or(std::forward<_ExecutionPolicy>(__exec), __first, __last,
+ [__first, __comp, __is_vector](_RandomAccessIterator __i, _RandomAccessIterator __j) {
+ return !__internal::__is_heap_local(__first, __i - __first, __j - __first, __comp,
+ __is_vector);
+ });
+ });
+}
+#endif
+
//------------------------------------------------------------------------
// min_element
//------------------------------------------------------------------------
diff --git a/include/pstl/internal/execution_defs.h b/include/pstl/internal/execution_defs.h
index 1486dc47309..f810d42b901 100644
--- a/include/pstl/internal/execution_defs.h
+++ b/include/pstl/internal/execution_defs.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -161,6 +161,15 @@ template
using __enable_if_execution_policy =
typename std::enable_if::type>::value,
T>::type;
+
+template
+struct __ref_or_copy_impl
+{
+ using type = const _T&;
+};
+
+template
+using __ref_or_copy = typename pstl::__internal::__ref_or_copy_impl::type, _T>::type;
} // namespace __internal
} // namespace pstl
diff --git a/include/pstl/internal/execution_impl.h b/include/pstl/internal/execution_impl.h
index 1660e9e69a7..5f55b5c57b0 100644
--- a/include/pstl/internal/execution_impl.h
+++ b/include/pstl/internal/execution_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/glue_algorithm_defs.h b/include/pstl/internal/glue_algorithm_defs.h
index 27283b2a7c3..12d077c53b0 100644
--- a/include/pstl/internal/glue_algorithm_defs.h
+++ b/include/pstl/internal/glue_algorithm_defs.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/glue_algorithm_impl.h b/include/pstl/internal/glue_algorithm_impl.h
index ca9795a3703..6634aa42e71 100644
--- a/include/pstl/internal/glue_algorithm_impl.h
+++ b/include/pstl/internal/glue_algorithm_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/glue_execution_defs.h b/include/pstl/internal/glue_execution_defs.h
index b9bed9aea80..1241adedee6 100644
--- a/include/pstl/internal/glue_execution_defs.h
+++ b/include/pstl/internal/glue_execution_defs.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/glue_memory_defs.h b/include/pstl/internal/glue_memory_defs.h
index dcc217a0ea5..4260b128dfd 100644
--- a/include/pstl/internal/glue_memory_defs.h
+++ b/include/pstl/internal/glue_memory_defs.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/glue_memory_impl.h b/include/pstl/internal/glue_memory_impl.h
index 746fe9511f1..001c264b1bb 100644
--- a/include/pstl/internal/glue_memory_impl.h
+++ b/include/pstl/internal/glue_memory_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -18,6 +18,7 @@
#include "execution_defs.h"
#include "utils.h"
+#include "memory_fwd.h"
#include "algorithm_fwd.h"
#include "execution_impl.h"
diff --git a/include/pstl/internal/iterator_defs.h b/include/pstl/internal/iterator_defs.h
index 257038ef802..3aadbbafb28 100644
--- a/include/pstl/internal/iterator_defs.h
+++ b/include/pstl/internal/iterator_defs.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- iterator_defs.h ---------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/iterator_impl.h b/include/pstl/internal/iterator_impl.h
index 6a47fbf947c..f179daff10b 100644
--- a/include/pstl/internal/iterator_impl.h
+++ b/include/pstl/internal/iterator_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- iterator_impl.h ---------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/memory_fwd.h b/include/pstl/internal/memory_fwd.h
new file mode 100644
index 00000000000..8c1845303ce
--- /dev/null
+++ b/include/pstl/internal/memory_fwd.h
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===-- memory_fwd.h ------------------------------------------------------===//
+//
+// Copyright (C) 2019-2020 Intel Corporation
+//
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+// This file incorporates work covered by the following copyright and permission
+// notice:
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _PSTL_memory_fwd_H
+#define _PSTL_memory_fwd_H
+
+namespace pstl
+{
+namespace __internal
+{
+
+template
+struct __op_uninitialized_copy;
+
+template
+struct __op_uninitialized_move;
+
+template
+struct __op_uninitialized_fill;
+
+template
+struct __op_destroy;
+
+template
+struct __op_uninitialized_default_construct;
+
+template
+struct __op_uninitialized_value_construct;
+
+} // namespace __internal
+} // namespace pstl
+
+#endif /*_PSTL_memory_fwd_H*/
diff --git a/include/pstl/internal/memory_impl.h b/include/pstl/internal/memory_impl.h
index d22e3247684..4c63560fcb2 100644
--- a/include/pstl/internal/memory_impl.h
+++ b/include/pstl/internal/memory_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -18,6 +18,7 @@
#include
+#include "memory_fwd.h"
#include "unseq_backend_simd.h"
namespace pstl
@@ -29,33 +30,183 @@ namespace __internal
// uninitialized_move
//------------------------------------------------------------------------
-template
+template
_OutputIterator
__brick_uninitialized_move(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
/*vector=*/std::false_type) noexcept
{
- typedef typename std::iterator_traits<_OutputIterator>::value_type _ValueType2;
+ using _ValueType = typename std::iterator_traits<_OutputIterator>::value_type;
for (; __first != __last; ++__first, ++__result)
{
- ::new (std::addressof(*__result)) _ValueType2(std::move(*__first));
+ ::new (std::addressof(*__result)) _ValueType(std::move(*__first));
}
return __result;
}
-template
+template
_OutputIterator
__brick_uninitialized_move(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
/*vector=*/std::true_type) noexcept
{
- typedef typename std::iterator_traits<_OutputIterator>::value_type __ValueType2;
- typedef typename std::iterator_traits<_ForwardIterator>::reference _ReferenceType1;
- typedef typename std::iterator_traits<_OutputIterator>::reference _ReferenceType2;
+ using __ValueType = typename std::iterator_traits<_OutputIterator>::value_type;
+ using _ReferenceType1 = typename std::iterator_traits<_ForwardIterator>::reference;
+ using _ReferenceType2 = typename std::iterator_traits<_OutputIterator>::reference;
return __unseq_backend::__simd_walk_2(
__first, __last - __first, __result,
- [](_ReferenceType1 __x, _ReferenceType2 __y) { ::new (std::addressof(__y)) __ValueType2(std::move(__x)); });
+ [](_ReferenceType1 __x, _ReferenceType2 __y) { ::new (std::addressof(__y)) __ValueType(std::move(__x)); });
}
+template
+void
+__brick_destroy(_Iterator __first, _Iterator __last, /*vector*/ std::false_type) noexcept
+{
+ using _ValueType = typename std::iterator_traits<_Iterator>::value_type;
+
+ for (; __first != __last; ++__first)
+ __first->~_ValueType();
+}
+
+template
+void
+__brick_destroy(_Iterator __first, _Iterator __last, /*vector*/ std::true_type) noexcept
+{
+ using _ValueType = typename std::iterator_traits<_Iterator>::value_type;
+ using _ReferenceType = typename std::iterator_traits<_Iterator>::reference;
+
+ __unseq_backend::__simd_walk_1(__first, __last - __first, [](_ReferenceType __x) { __x.~_ValueType(); });
+}
+
+//------------------------------------------------------------------------
+// uninitialized copy
+//------------------------------------------------------------------------
+
+template
+_OutputIterator
+__brick_uninitialized_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
+ /*vector=*/std::false_type) noexcept
+{
+ using _ValueType = typename std::iterator_traits<_OutputIterator>::value_type;
+ for (; __first != __last; ++__first, ++__result)
+ {
+ ::new (std::addressof(*__result)) _ValueType(*__first);
+ }
+ return __result;
+}
+
+template
+_OutputIterator
+__brick_uninitialized_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
+ /*vector=*/std::true_type) noexcept
+{
+ using __ValueType = typename std::iterator_traits<_OutputIterator>::value_type;
+ using _ReferenceType1 = typename std::iterator_traits<_ForwardIterator>::reference;
+ using _ReferenceType2 = typename std::iterator_traits<_OutputIterator>::reference;
+
+ return __unseq_backend::__simd_walk_2(
+ __first, __last - __first, __result,
+ [](_ReferenceType1 __x, _ReferenceType2 __y) { ::new (std::addressof(__y)) __ValueType(__x); });
+}
+
+template
+struct __op_uninitialized_copy<_ExecutionPolicy>
+{
+ template
+ void
+ operator()(_SourceT&& __source, _TargetT& __target)
+ {
+ using _TargetValueType = typename std::decay<_TargetT>::type;
+
+ ::new (std::addressof(__target)) _TargetValueType(std::forward<_SourceT>(__source));
+ }
+};
+
+//------------------------------------------------------------------------
+// uninitialized move
+//------------------------------------------------------------------------
+
+template
+struct __op_uninitialized_move<_ExecutionPolicy>
+{
+ template
+ void
+ operator()(_SourceT&& __source, _TargetT& __target)
+ {
+ using _TargetValueType = typename std::decay<_TargetT>::type;
+
+ ::new (std::addressof(__target)) _TargetValueType(std::move(__source));
+ }
+};
+
+//------------------------------------------------------------------------
+// uninitialized fill
+//------------------------------------------------------------------------
+
+template
+struct __op_uninitialized_fill<_SourceT, _ExecutionPolicy>
+{
+ __ref_or_copy<_ExecutionPolicy, _SourceT> __source;
+
+ template
+ void
+ operator()(_TargetT& __target)
+ {
+ using _TargetValueType = typename std::decay<_TargetT>::type;
+
+ ::new (std::addressof(__target)) _TargetValueType(__source);
+ }
+};
+
+//------------------------------------------------------------------------
+// destroy
+//------------------------------------------------------------------------
+
+template
+struct __op_destroy<_ExecutionPolicy>
+{
+ template
+ void
+ operator()(_TargetT& __target)
+ {
+ using _TargetValueType = typename std::decay<_TargetT>::type;
+ __target.~_TargetValueType();
+ }
+};
+
+//------------------------------------------------------------------------
+// uninitialized default_construct
+//------------------------------------------------------------------------
+
+template
+struct __op_uninitialized_default_construct<_ExecutionPolicy>
+{
+ template
+ void
+ operator()(_TargetT& __target)
+ {
+ using _TargetValueType = typename std::decay<_TargetT>::type;
+
+ ::new (std::addressof(__target)) _TargetValueType;
+ }
+};
+
+//------------------------------------------------------------------------
+// uninitialized value_construct
+//------------------------------------------------------------------------
+
+template
+struct __op_uninitialized_value_construct<_ExecutionPolicy>
+{
+ template
+ void
+ operator()(_TargetT& __target)
+ {
+ using _TargetValueType = typename std::decay<_TargetT>::type;
+
+ ::new (std::addressof(__target)) _TargetValueType();
+ }
+};
+
} // namespace __internal
} // namespace pstl
diff --git a/include/pstl/internal/numeric_fwd.h b/include/pstl/internal/numeric_fwd.h
index 32f1d69198a..1ad4f5d1e83 100644
--- a/include/pstl/internal/numeric_fwd.h
+++ b/include/pstl/internal/numeric_fwd.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -121,6 +121,14 @@ __pattern_transform_scan(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAcces
_UnaryOperation, _Tp, _BinaryOperation, _Inclusive, _IsVector, /*is_parallel=*/std::true_type);
#endif
+// transform_scan without initial element
+template
+_OutputIterator
+__pattern_transform_scan(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last,
+ _OutputIterator __result, _UnaryOperation __unary_op, _BinaryOperation __binary_op, _Inclusive,
+ _IsVector __is_vector, _IsParallel __is_parallel);
+
//------------------------------------------------------------------------
// adjacent_difference
//------------------------------------------------------------------------
diff --git a/include/pstl/internal/numeric_impl.h b/include/pstl/internal/numeric_impl.h
index aa3ffcebd0a..34a6ab4f169 100644
--- a/include/pstl/internal/numeric_impl.h
+++ b/include/pstl/internal/numeric_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -167,9 +167,11 @@ __brick_transform_scan(_ForwardIterator __first, _ForwardIterator __last, _Outpu
{
for (; __first != __last; ++__first, ++__result)
{
+ // Copy the value pointed to by __first to avoid overwriting it when __result == __first
+ _Tp __temp = *__first;
*__result = __init;
_PSTL_PRAGMA_FORCEINLINE
- __init = __binary_op(__init, __unary_op(*__first));
+ __init = __binary_op(__init, __unary_op(__temp));
}
return std::make_pair(__result, __init);
}
@@ -307,6 +309,28 @@ __pattern_transform_scan(_ExecutionPolicy&& __exec, _RandomAccessIterator __firs
}
#endif
+// transform_scan without initial element
+template
+_OutputIterator
+__pattern_transform_scan(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last,
+ _OutputIterator __result, _UnaryOperation __unary_op, _BinaryOperation __binary_op, _Inclusive,
+ _IsVector __is_vector, _IsParallel __is_parallel)
+{
+ typedef typename std::iterator_traits<_ForwardIterator>::value_type _ValueType;
+ if (__first != __last)
+ {
+ _ValueType __tmp = __unary_op(*__first);
+ *__result = __tmp;
+ return __pattern_transform_scan(std::forward<_ExecutionPolicy>(__exec), ++__first, __last, ++__result,
+ __unary_op, __tmp, __binary_op, _Inclusive(), __is_vector, __is_parallel);
+ }
+ else
+ {
+ return __result;
+ }
+}
+
//------------------------------------------------------------------------
// adjacent_difference
diff --git a/include/pstl/internal/parallel_backend.h b/include/pstl/internal/parallel_backend.h
index f74c88fbb47..4a90ee07746 100644
--- a/include/pstl/internal/parallel_backend.h
+++ b/include/pstl/internal/parallel_backend.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/parallel_backend_serial.h b/include/pstl/internal/parallel_backend_serial.h
index 71f4840703e..4f7112ed9a8 100644
--- a/include/pstl/internal/parallel_backend_serial.h
+++ b/include/pstl/internal/parallel_backend_serial.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/parallel_backend_tbb.h b/include/pstl/internal/parallel_backend_tbb.h
index 4c4bacd96ed..a7fc08deeca 100644
--- a/include/pstl/internal/parallel_backend_tbb.h
+++ b/include/pstl/internal/parallel_backend_tbb.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -440,7 +440,6 @@ class __merge_task : public tbb::task
_SizeType _M_ys, _M_ye;
_SizeType _M_zs;
_Compare _M_comp;
- _Cleanup _M_cleanup;
_LeafMerge _M_leaf_merge;
_SizeType _M_nsort; //number of elements to be sorted for partial_sort alforithm
@@ -449,15 +448,7 @@ class __merge_task : public tbb::task
bool _root; //means a task is merging root task
bool _x_orig; //"true" means X(or left ) subrange is in the original container; false - in the buffer
bool _y_orig; //"true" means Y(or right) subrange is in the original container; false - in the buffer
- bool _x_first_move, _y_first_move; //"true" means X and Y subranges are merging into the buffer and move constructor
- //should be called instead of just moving.
- bool _split; //"true" means a merge task is a split task for parallel merging, the execution logic differs
-
- bool
- is_partial() const
- {
- return _M_nsort > 0;
- }
+ bool _split; //"true" means a merge task is a split task for parallel merging, the execution logic differs
struct __move_value
{
@@ -521,13 +512,32 @@ class __merge_task : public tbb::task
}
};
+ struct __cleanup_range
+ {
+ template
+ void
+ operator()(Iterator __first, Iterator __last)
+ {
+ if (__last - __first < __merge_cut_off)
+ _Cleanup()(__first, __last);
+ else
+ {
+ auto __n = __last - __first;
+ tbb::parallel_for(tbb::blocked_range<_SizeType>(0, __n, __merge_cut_off),
+ [__first](const tbb::blocked_range<_SizeType>& __range) {
+ _Cleanup()(__first + __range.begin(), __first + __range.end());
+ });
+ }
+ }
+ };
+
public:
__merge_task(_SizeType __xs, _SizeType __xe, _SizeType __ys, _SizeType __ye, _SizeType __zs, _Compare __comp,
- _Cleanup __cleanup, _LeafMerge __leaf_merge, _SizeType __nsort, _RandomAccessIterator1 __x_beg,
+ _Cleanup, _LeafMerge __leaf_merge, _SizeType __nsort, _RandomAccessIterator1 __x_beg,
_RandomAccessIterator2 __z_beg, bool __x_orig, bool __y_orig, bool __root)
: _M_xs(__xs), _M_xe(__xe), _M_ys(__ys), _M_ye(__ye), _M_zs(__zs), _M_x_beg(__x_beg), _M_z_beg(__z_beg),
- _M_comp(__comp), _M_cleanup(__cleanup), _M_leaf_merge(__leaf_merge), _M_nsort(__nsort), _root(__root),
- _x_orig(__x_orig), _y_orig(__y_orig), _x_first_move(false), _y_first_move(false), _split(false)
+ _M_comp(__comp), _M_leaf_merge(__leaf_merge), _M_nsort(__nsort), _root(__root), _x_orig(__x_orig),
+ _y_orig(__y_orig), _split(false)
{
}
@@ -537,16 +547,6 @@ class __merge_task : public tbb::task
return _M_xs == __idx;
}
- template
- void
- set_first_move(IndexType __idx, bool __on_off)
- {
- if (is_left(__idx))
- _x_first_move = __on_off;
- else
- _y_first_move = __on_off;
- }
-
template
void
set_odd(IndexType __idx, bool __on_off)
@@ -567,23 +567,27 @@ class __merge_task : public tbb::task
bool
x_less_y()
{
- const auto __nx = (_M_xe - _M_xs);
- const auto __ny = (_M_ye - _M_ys);
+ auto __nx = (_M_xe - _M_xs);
+ auto __ny = (_M_ye - _M_ys);
+
assert(__nx > 0 && __ny > 0);
+ assert(_M_nsort > 0);
+
+ auto __kx = std::min(_M_nsort, __nx);
+ auto __ky = std::min(_M_nsort, __ny);
assert(_x_orig == _y_orig);
- assert(!is_partial());
if (_x_orig)
{
- assert(std::is_sorted(_M_x_beg + _M_xs, _M_x_beg + _M_xe, _M_comp));
- assert(std::is_sorted(_M_x_beg + _M_ys, _M_x_beg + _M_ye, _M_comp));
- return !_M_comp(*(_M_x_beg + _M_ys), *(_M_x_beg + _M_xe - 1));
+ assert(std::is_sorted(_M_x_beg + _M_xs, _M_x_beg + _M_xs + __kx, _M_comp));
+ assert(std::is_sorted(_M_x_beg + _M_ys, _M_x_beg + _M_ys + __ky, _M_comp));
+ return !_M_comp(*(_M_x_beg + _M_ys), *(_M_x_beg + _M_xs + __kx - 1));
}
- assert(std::is_sorted(_M_z_beg + _M_xs, _M_z_beg + _M_xe, _M_comp));
- assert(std::is_sorted(_M_z_beg + _M_ys, _M_z_beg + _M_ye, _M_comp));
- return !_M_comp(*(_M_z_beg + _M_zs + __nx), *(_M_z_beg + _M_zs + __nx - 1));
+ assert(std::is_sorted(_M_z_beg + _M_xs, _M_z_beg + _M_xs + __kx, _M_comp));
+ assert(std::is_sorted(_M_z_beg + _M_ys, _M_z_beg + _M_ys + __ky, _M_comp));
+ return !_M_comp(*(_M_z_beg + _M_zs + __nx), *(_M_z_beg + _M_zs + __kx - 1));
}
void
move_x_range()
@@ -593,19 +597,11 @@ class __merge_task : public tbb::task
assert(__nx > 0 && __ny > 0);
if (_x_orig)
- {
- if (_x_first_move)
- {
- __move_range_construct()(_M_x_beg + _M_xs, _M_x_beg + _M_xe, _M_z_beg + _M_zs);
- _x_first_move = false;
- }
- else
- __move_range()(_M_x_beg + _M_xs, _M_x_beg + _M_xe, _M_z_beg + _M_zs);
- }
+ __move_range_construct()(_M_x_beg + _M_xs, _M_x_beg + _M_xe, _M_z_beg + _M_zs);
else
{
- assert(!_x_first_move);
__move_range()(_M_z_beg + _M_zs, _M_z_beg + _M_zs + __nx, _M_x_beg + _M_xs);
+ __cleanup_range()(_M_z_beg + _M_zs, _M_z_beg + _M_zs + __nx);
}
_x_orig = !_x_orig;
@@ -617,19 +613,11 @@ class __merge_task : public tbb::task
const auto __ny = (_M_ye - _M_ys);
if (_y_orig)
- {
- if (_y_first_move)
- {
- __move_range_construct()(_M_x_beg + _M_ys, _M_x_beg + _M_ye, _M_z_beg + _M_zs + __nx);
- _y_first_move = false;
- }
- else
- __move_range()(_M_x_beg + _M_ys, _M_x_beg + _M_ye, _M_z_beg + _M_zs + __nx);
- }
+ __move_range_construct()(_M_x_beg + _M_ys, _M_x_beg + _M_ye, _M_z_beg + _M_zs + __nx);
else
{
- assert(!_y_first_move);
__move_range()(_M_z_beg + _M_zs + __nx, _M_z_beg + _M_zs + __nx + __ny, _M_x_beg + _M_ys);
+ __cleanup_range()(_M_z_beg + _M_zs + __nx, _M_z_beg + _M_zs + __nx + __ny);
}
_y_orig = !_y_orig;
@@ -637,6 +625,7 @@ class __merge_task : public tbb::task
tbb::task*
merge_ranges()
{
+ assert(_M_nsort > 0);
assert(_x_orig == _y_orig); //two merged subrange must be lie into the same buffer
const auto __nx = (_M_xe - _M_xs);
@@ -650,46 +639,15 @@ class __merge_task : public tbb::task
//merge to buffer
if (_x_orig)
{
- assert(is_partial() || std::is_sorted(_M_x_beg + _M_xs, _M_x_beg + _M_xe, _M_comp));
- assert(is_partial() || std::is_sorted(_M_x_beg + _M_ys, _M_x_beg + _M_ye, _M_comp));
-
- if (_x_first_move && _y_first_move)
- {
- _M_leaf_merge(_M_x_beg + _M_xs, _M_x_beg + _M_xe, _M_x_beg + _M_ys, _M_x_beg + _M_ye, _M_z_beg + _M_zs,
- _M_comp, __move_value_construct(), __move_value_construct(), __move_range_construct(),
- __move_range_construct());
- _x_first_move = false, _y_first_move = false;
- }
- else if (_x_first_move && !_y_first_move)
- {
- _M_leaf_merge(_M_x_beg + _M_xs, _M_x_beg + _M_xe, _M_x_beg + _M_ys, _M_x_beg + _M_ye, _M_z_beg + _M_zs,
- _M_comp, __move_value_construct(), __move_value(), __move_range_construct(),
- __move_range());
- _x_first_move = false;
- }
- else if (!_x_first_move && _y_first_move)
- {
- _M_leaf_merge(_M_x_beg + _M_xs, _M_x_beg + _M_xe, _M_x_beg + _M_ys, _M_x_beg + _M_ye, _M_z_beg + _M_zs,
- _M_comp, __move_value(), __move_value_construct(), __move_range(),
- __move_range_construct());
- _y_first_move = false;
- }
- else
- _M_leaf_merge(_M_x_beg + _M_xs, _M_x_beg + _M_xe, _M_x_beg + _M_ys, _M_x_beg + _M_ye, _M_z_beg + _M_zs,
- _M_comp, __move_value(), __move_value(), __move_range(), __move_range());
-
- assert(is_partial() || std::is_sorted(_M_z_beg + _M_zs, _M_z_beg + _M_zs + __nx + __ny, _M_comp));
+ _M_leaf_merge(_M_x_beg + _M_xs, _M_x_beg + _M_xe, _M_x_beg + _M_ys, _M_x_beg + _M_ye, _M_z_beg + _M_zs,
+ _M_comp, __move_value_construct(), __move_value_construct(), __move_range_construct(),
+ __move_range_construct());
assert(parent_merge()); //not root merging task
}
//merge to "origin"
else
{
assert(_x_orig == _y_orig);
- assert(!_x_first_move);
- assert(!_y_first_move);
-
- assert(is_partial() || std::is_sorted(_M_z_beg + _M_xs, _M_z_beg + _M_xe, _M_comp));
- assert(is_partial() || std::is_sorted(_M_z_beg + _M_ys, _M_z_beg + _M_ye, _M_comp));
const auto __nx = (_M_xe - _M_xs);
const auto __ny = (_M_ye - _M_ys);
@@ -697,17 +655,12 @@ class __merge_task : public tbb::task
_M_leaf_merge(_M_z_beg + _M_xs, _M_z_beg + _M_xe, _M_z_beg + _M_ys, _M_z_beg + _M_ye, _M_x_beg + _M_zs,
_M_comp, __move_value(), __move_value(), __move_range(), __move_range());
- assert(is_partial() || std::is_sorted(_M_x_beg + _M_zs, _M_x_beg + _M_zs + __nx + __ny, _M_comp));
-
- //in case of the root merge task - clean the buffer
- if (!parent_merge())
- {
- _M_cleanup(_M_z_beg + _M_xs, _M_z_beg + _M_xe);
- _M_cleanup(_M_z_beg + _M_ys, _M_z_beg + _M_ye);
- }
+ __cleanup_range()(_M_z_beg + _M_xs, _M_z_beg + _M_xe);
+ __cleanup_range()(_M_z_beg + _M_ys, _M_z_beg + _M_ye);
}
return nullptr;
}
+
tbb::task*
process_ranges()
{
@@ -716,49 +669,41 @@ class __merge_task : public tbb::task
auto p = parent_merge();
- //optimization, just for sort algorithm, not for partial_sort
- //{x} <= {y}
- if (!is_partial() && x_less_y())
- {
- if (p)
+ if (!p)
+ { //root merging task
+
+ //optimization, just for sort algorithm, //{x} <= {y}
+ if (x_less_y()) //we have a solution
{
- const auto id_range = _M_zs;
- p->set_odd(id_range, _x_orig);
- p->set_first_move(id_range, _x_first_move);
+ if (!_x_orig)
+ { //we have to move the solution to the origin
+ move_x_range(); //parallel moving
+ move_y_range(); //parallel moving
+ }
+ return nullptr;
}
- else
- { //root task
-
- //clean the buffer
- if (!_x_first_move)
- _M_cleanup(_M_z_beg + _M_xs, _M_z_beg + _M_xe);
-
- if (!_y_first_move)
- _M_cleanup(_M_z_beg + _M_ys, _M_z_beg + _M_ye);
+ //else: if we have data in the origin,
+ //we have to move data to the buffer for final merging into the origin.
+ if (_x_orig)
+ {
+ move_x_range(); //parallel moving
+ move_y_range(); //parallel moving
}
- return nullptr;
+ // need to merge {x} and {y}.
+ return merge_ranges();
}
-
- //in case of the root merge task - move to the buffer firstly
- //the root merging task
- if (!p && _x_orig)
- {
- assert(_y_orig);
-
- move_x_range();
- move_y_range();
- }
-
- //we have to revert "_x(y)_orig" flag of the parent merging task
- if (p)
+ //else: not root merging task (parent_merge() == NULL)
+ //optimization, just for sort algorithm, //{x} <= {y}
+ if (x_less_y())
{
const auto id_range = _M_zs;
- p->set_odd(id_range, !_x_orig);
+ p->set_odd(id_range, _x_orig);
+ return nullptr;
}
+ //else: we have to revert "_x(y)_orig" flag of the parent merging task
+ const auto id_range = _M_zs;
+ p->set_odd(id_range, !_x_orig);
- const _SizeType __n = (_M_xe - _M_xs) + (_M_ye - _M_ys);
-
- // need to merge {x} and {y}
return merge_ranges();
}
@@ -767,38 +712,41 @@ class __merge_task : public tbb::task
split_merging()
{
assert(_x_orig == _y_orig);
+
const auto __nx = (_M_xe - _M_xs);
const auto __ny = (_M_ye - _M_ys);
-
_SizeType __xm{};
_SizeType __ym{};
+
if (__nx < __ny)
{
__ym = _M_ys + __ny / 2;
if (_x_orig)
- __xm = std::upper_bound(_M_x_beg + _M_xs, _M_x_beg + _M_xe, *(_M_x_beg + __ym), _M_comp) - _M_x_beg;
+ __xm =
+ std::upper_bound(_M_x_beg + _M_xs, _M_x_beg + _M_xs + __nx, *(_M_x_beg + __ym), _M_comp) - _M_x_beg;
else
- __xm = std::upper_bound(_M_z_beg + _M_xs, _M_z_beg + _M_xe, *(_M_z_beg + __ym), _M_comp) - _M_z_beg;
+ __xm =
+ std::upper_bound(_M_z_beg + _M_xs, _M_z_beg + _M_xs + __nx, *(_M_z_beg + __ym), _M_comp) - _M_z_beg;
}
else
{
__xm = _M_xs + __nx / 2;
if (_y_orig)
- __ym = std::lower_bound(_M_x_beg + _M_ys, _M_x_beg + _M_ye, *(_M_x_beg + __xm), _M_comp) - _M_x_beg;
+ __ym =
+ std::lower_bound(_M_x_beg + _M_ys, _M_x_beg + _M_ys + __ny, *(_M_x_beg + __xm), _M_comp) - _M_x_beg;
else
- __ym = std::lower_bound(_M_z_beg + _M_ys, _M_z_beg + _M_ye, *(_M_z_beg + __xm), _M_comp) - _M_z_beg;
+ __ym =
+ std::lower_bound(_M_z_beg + _M_ys, _M_z_beg + _M_ys + __ny, *(_M_z_beg + __xm), _M_comp) - _M_z_beg;
}
auto __zm = _M_zs + ((__xm - _M_xs) + (__ym - _M_ys));
__merge_task* __right = new (tbb::task::allocate_additional_child_of(*parent()))
- __merge_task(__xm, _M_xe, __ym, _M_ye, __zm, _M_comp, _M_cleanup, _M_leaf_merge, _M_nsort, _M_x_beg,
+ __merge_task(__xm, _M_xe, __ym, _M_ye, __zm, _M_comp, _Cleanup(), _M_leaf_merge, _M_nsort, _M_x_beg,
_M_z_beg, _x_orig, _y_orig, _root);
- __right->_x_first_move = _x_first_move;
- __right->_y_first_move = _y_first_move;
__right->_split = true;
tbb::task::spawn(*__right);
@@ -891,8 +839,10 @@ __stable_sort_task<_RandomAccessIterator1, _RandomAccessIterator2, _Compare, _Le
__utils::__serial_move_merge>
_MergeTaskType;
+ assert(_M_nsort > 0);
+
const _SizeType __n = _M_xe - _M_xs;
- const _SizeType __nmerge = _M_nsort > 0 ? _M_nsort : __n;
+ const _SizeType __nmerge = std::min(_M_nsort, __n);
const _SizeType __sort_cut_off = _PSTL_STABLE_SORT_CUT_OFF;
if (__n <= __sort_cut_off)
{
@@ -902,7 +852,6 @@ __stable_sort_task<_RandomAccessIterator1, _RandomAccessIterator2, _Compare, _Le
tbb::task* p = parent();
const auto id_range = _M_xs - _M_x_beg;
- static_cast<_MergeTaskType*>(p)->set_first_move(id_range, true);
return nullptr;
}
@@ -931,15 +880,13 @@ __stable_sort_task<_RandomAccessIterator1, _RandomAccessIterator2, _Compare, _Le
template
void
__parallel_stable_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __xs, _RandomAccessIterator __xe,
- _Compare __comp, _LeafSort __leaf_sort, std::size_t __nsort = 0)
+ _Compare __comp, _LeafSort __leaf_sort, std::size_t __nsort)
{
tbb::this_task_arena::isolate([=, &__exec, &__nsort]() {
//sorting based on task tree and parallel merge
typedef typename std::iterator_traits<_RandomAccessIterator>::value_type _ValueType;
typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type _DifferenceType;
const _DifferenceType __n = __xe - __xs;
- if (__nsort == __n)
- __nsort = 0; // 'partial_sort' becomes 'sort'
const _DifferenceType __sort_cut_off = _PSTL_STABLE_SORT_CUT_OFF;
if (__n > __sort_cut_off)
diff --git a/include/pstl/internal/parallel_backend_utils.h b/include/pstl/internal/parallel_backend_utils.h
index 7c736c7ab9f..709a3950e35 100644
--- a/include/pstl/internal/parallel_backend_utils.h
+++ b/include/pstl/internal/parallel_backend_utils.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -140,6 +140,124 @@ struct __serial_move_merge
}
};
+template
+_OutputIterator
+__set_union_construct(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2, _OutputIterator __result, _Compare __comp,
+ _CopyConstructRange __cc_range)
+{
+ using _Tp = typename std::iterator_traits<_OutputIterator>::value_type;
+
+ for (; __first1 != __last1; ++__result)
+ {
+ if (__first2 == __last2)
+ return __cc_range(__first1, __last1, __result);
+ if (__comp(*__first2, *__first1))
+ {
+ ::new (std::addressof(*__result)) _Tp(*__first2);
+ ++__first2;
+ }
+ else
+ {
+ ::new (std::addressof(*__result)) _Tp(*__first1);
+ if (!__comp(*__first1, *__first2))
+ ++__first2;
+ ++__first1;
+ }
+ }
+ return __cc_range(__first2, __last2, __result);
+}
+
+template
+_OutputIterator
+__set_intersection_construct(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ using _Tp = typename std::iterator_traits<_OutputIterator>::value_type;
+
+ for (; __first1 != __last1 && __first2 != __last2;)
+ {
+ if (__comp(*__first1, *__first2))
+ ++__first1;
+ else
+ {
+ if (!__comp(*__first2, *__first1))
+ {
+ ::new (std::addressof(*__result)) _Tp(*__first1);
+ ++__result;
+ ++__first1;
+ }
+ ++__first2;
+ }
+ }
+ return __result;
+}
+
+template
+_OutputIterator
+__set_difference_construct(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2, _OutputIterator __result, _Compare __comp,
+ _CopyConstructRange __cc_range)
+{
+ using _Tp = typename std::iterator_traits<_OutputIterator>::value_type;
+
+ for (; __first1 != __last1;)
+ {
+ if (__first2 == __last2)
+ return __cc_range(__first1, __last1, __result);
+
+ if (__comp(*__first1, *__first2))
+ {
+ ::new (std::addressof(*__result)) _Tp(*__first1);
+ ++__result;
+ ++__first1;
+ }
+ else
+ {
+ if (!__comp(*__first2, *__first1))
+ ++__first1;
+ ++__first2;
+ }
+ }
+ return __result;
+}
+template
+_OutputIterator
+__set_symmetric_difference_construct(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2, _OutputIterator __result, _Compare __comp,
+ _CopyConstructRange __cc_range)
+{
+ using _Tp = typename std::iterator_traits<_OutputIterator>::value_type;
+
+ for (; __first1 != __last1;)
+ {
+ if (__first2 == __last2)
+ return __cc_range(__first1, __last1, __result);
+
+ if (__comp(*__first1, *__first2))
+ {
+ ::new (std::addressof(*__result)) _Tp(*__first1);
+ ++__result;
+ ++__first1;
+ }
+ else
+ {
+ if (__comp(*__first2, *__first1))
+ {
+ ::new (std::addressof(*__result)) _Tp(*__first2);
+ ++__result;
+ }
+ else
+ ++__first1;
+ ++__first2;
+ }
+ }
+ return __cc_range(__first2, __last2, __result);
+}
+
} // namespace __utils
} // namespace pstl
diff --git a/include/pstl/internal/parallel_impl.h b/include/pstl/internal/parallel_impl.h
index 572eb927f1c..b169adad177 100644
--- a/include/pstl/internal/parallel_impl.h
+++ b/include/pstl/internal/parallel_impl.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/include/pstl/internal/pstl_config.h b/include/pstl/internal/pstl_config.h
index f8020be1d14..a2857e17ce1 100644
--- a/include/pstl/internal/pstl_config.h
+++ b/include/pstl/internal/pstl_config.h
@@ -24,7 +24,7 @@
#define _PSTL_VERSION_PATCH (_PSTL_VERSION % 10)
// The version of the Parallel STL implementation released by Intel
-#define __INTEL_PSTL_VERSION 211
+#define __INTEL_PSTL_VERSION 212
#define __INTEL_PSTL_VERSION_MAJOR (__INTEL_PSTL_VERSION / 100)
#define __INTEL_PSTL_VERSION_MINOR (__INTEL_PSTL_VERSION % 100)
@@ -184,9 +184,8 @@
// broken macros
#define _PSTL_CPP11_STD_ROTATE_BROKEN ((__GLIBCXX__ && __GLIBCXX__ < 20150716) || (_MSC_VER && _MSC_VER < 1800))
-// Some C++ standard libraries (GCC 9.1(2) and Clang 9) contain 'exclusive_scan' declaration (version with binary_op)
+// Some C++ standard libraries contain 'exclusive_scan' declaration (version with binary_op)
// w/o "enable_if". So, a call 'exclusive_scan' may be ambiguous in case of a custom policy using.
-#define _PSTL_EXCLUSIVE_SCAN_WITH_BINARY_OP_AMBIGUITY \
- ((_PSTL_GCC_VERSION == 90101 || _PSTL_GCC_VERSION == 90201 || __clang_major__ == 9) && __cplusplus >= 201703L)
+#define _PSTL_EXCLUSIVE_SCAN_WITH_BINARY_OP_AMBIGUITY (__GLIBCXX__ && __GLIBCXX__ > 20190503 && __cplusplus >= 201703L)
#endif /* _PSTL_CONFIG_H */
diff --git a/include/pstl/internal/unseq_backend_simd.h b/include/pstl/internal/unseq_backend_simd.h
index c91739a9455..e9c395674d4 100644
--- a/include/pstl/internal/unseq_backend_simd.h
+++ b/include/pstl/internal/unseq_backend_simd.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -21,7 +21,7 @@
#include "utils.h"
// This header defines the minimum set of vector routines required
-// to support parallel STL.
+// to support Parallel STL.
namespace pstl
{
namespace __unseq_backend
@@ -74,14 +74,14 @@ __simd_walk_3(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _It
// TODO: check whether __simd_first() can be used here
template
bool
-__simd_or(_Index __first, _DifferenceType __n, _Pred __pred) noexcept
+__simd_or_impl(_Index __first, _DifferenceType __n, _Pred __pred) noexcept
{
#if _PSTL_EARLYEXIT_PRESENT
_DifferenceType __i;
_PSTL_PRAGMA_VECTOR_UNALIGNED
_PSTL_PRAGMA_SIMD_EARLYEXIT
for (__i = 0; __i < __n; ++__i)
- if (__pred(__first[__i]))
+ if (__pred(__first + __i))
break;
return __i < __n;
#else
@@ -92,7 +92,7 @@ __simd_or(_Index __first, _DifferenceType __n, _Pred __pred) noexcept
int32_t __flag = 1;
_PSTL_PRAGMA_SIMD_REDUCTION(& : __flag)
for (_DifferenceType __i = 0; __i < __block_size; ++__i)
- if (__pred(*(__first + __i)))
+ if (__pred(__first + __i))
__flag = 0;
if (!__flag)
return true;
@@ -112,6 +112,20 @@ __simd_or(_Index __first, _DifferenceType __n, _Pred __pred) noexcept
#endif
}
+template
+bool
+__simd_or(_Index __first, _DifferenceType __n, _Pred __pred) noexcept
+{
+ return __unseq_backend::__simd_or_impl(__first, __n, [&__pred](_Index __it) { return __pred(*__it); });
+}
+
+template
+bool
+__simd_or_iter(_Index __first, _DifferenceType __n, _Pred __pred) noexcept
+{
+ return __unseq_backend::__simd_or_impl(__first, __n, __pred);
+}
+
template
_Index
__simd_first(_Index __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp) noexcept
diff --git a/include/pstl/internal/utils.h b/include/pstl/internal/utils.h
index 93600c2d2d5..ac41d3a3ede 100644
--- a/include/pstl/internal/utils.h
+++ b/include/pstl/internal/utils.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/linux/pstlvars.csh b/linux/pstlvars.csh
index 6c6b74bd32b..d2f76c633d5 100644
--- a/linux/pstlvars.csh
+++ b/linux/pstlvars.csh
@@ -1,7 +1,7 @@
#!/bin/csh
##===-- pstlvars.csh ------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/linux/pstlvars.sh b/linux/pstlvars.sh
index caee29d0c34..67ca0e4ba22 100644
--- a/linux/pstlvars.sh
+++ b/linux/pstlvars.sh
@@ -1,7 +1,7 @@
#!/bin/sh
##===-- pstlvars.sh -------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/mac/pstlvars.csh b/mac/pstlvars.csh
index 86dc1415904..36d02366353 100644
--- a/mac/pstlvars.csh
+++ b/mac/pstlvars.csh
@@ -1,7 +1,7 @@
#!/bin/csh
##===-- pstlvars.csh ------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/mac/pstlvars.sh b/mac/pstlvars.sh
index ee2e82432a9..d84fa9289ad 100644
--- a/mac/pstlvars.sh
+++ b/mac/pstlvars.sh
@@ -1,7 +1,7 @@
#!/bin/sh
##===-- pstlvars.sh -------------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/stdlib/pstl/algorithm b/stdlib/pstl/algorithm
index 4f3ea1a5909..3e78fa43572 100644
--- a/stdlib/pstl/algorithm
+++ b/stdlib/pstl/algorithm
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- algorithm ---------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/stdlib/pstl/execution b/stdlib/pstl/execution
index 8ac7e4dabf5..be5ef9fcd28 100644
--- a/stdlib/pstl/execution
+++ b/stdlib/pstl/execution
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- execution ---------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/stdlib/pstl/memory b/stdlib/pstl/memory
index 36d6d352da1..2ed3a905ee9 100644
--- a/stdlib/pstl/memory
+++ b/stdlib/pstl/memory
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- memory ------------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/stdlib/pstl/numeric b/stdlib/pstl/numeric
index fcd9f289185..0969efccd06 100644
--- a/stdlib/pstl/numeric
+++ b/stdlib/pstl/numeric
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- numeric -----------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index decc637e541..851b6c5e8d7 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,6 +1,6 @@
##===-- CMakeLists.txt ----------------------------------------------------===##
#
-# Copyright (C) 2017-2019 Intel Corporation
+# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
diff --git a/test/pstl/header_inclusion_order_algorithm_0.pass.cpp b/test/pstl/header_inclusion_order_algorithm_0.pass.cpp
index b6d7096d196..121d2a529ff 100644
--- a/test/pstl/header_inclusion_order_algorithm_0.pass.cpp
+++ b/test/pstl/header_inclusion_order_algorithm_0.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- header_inclusion_order_algorithm_0.pass.cpp -----------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/pstl/header_inclusion_order_algorithm_1.pass.cpp b/test/pstl/header_inclusion_order_algorithm_1.pass.cpp
index e209b63c621..caf0422d353 100644
--- a/test/pstl/header_inclusion_order_algorithm_1.pass.cpp
+++ b/test/pstl/header_inclusion_order_algorithm_1.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- header_inclusion_order_algorithm_1.pass.cpp -----------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/pstl/header_inclusion_order_memory_0.pass.cpp b/test/pstl/header_inclusion_order_memory_0.pass.cpp
index 9e7d87ae55e..fcaf5d32bfd 100644
--- a/test/pstl/header_inclusion_order_memory_0.pass.cpp
+++ b/test/pstl/header_inclusion_order_memory_0.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- header_inclusion_order_memory_0.pass.cpp --------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/pstl/header_inclusion_order_memory_1.pass.cpp b/test/pstl/header_inclusion_order_memory_1.pass.cpp
index 6245576e281..1244d8eb0e4 100644
--- a/test/pstl/header_inclusion_order_memory_1.pass.cpp
+++ b/test/pstl/header_inclusion_order_memory_1.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- header_inclusion_order_memory_1.pass.cpp --------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/pstl/header_inclusion_order_numeric_0.pass.cpp b/test/pstl/header_inclusion_order_numeric_0.pass.cpp
index 1b3c3f78568..6918dabb345 100644
--- a/test/pstl/header_inclusion_order_numeric_0.pass.cpp
+++ b/test/pstl/header_inclusion_order_numeric_0.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- header_inclusion_order_numeric_0.pass.cpp -------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/pstl/header_inclusion_order_numeric_1.pass.cpp b/test/pstl/header_inclusion_order_numeric_1.pass.cpp
index d6454620cd3..bbd572fd6e4 100644
--- a/test/pstl/header_inclusion_order_numeric_1.pass.cpp
+++ b/test/pstl/header_inclusion_order_numeric_1.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- header_inclusion_order_numeric_1.pass.cpp -------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/pstl/version.pass.cpp b/test/pstl/version.pass.cpp
index 457997b0559..9b6808a5e82 100644
--- a/test/pstl/version.pass.cpp
+++ b/test/pstl/version.pass.cpp
@@ -26,9 +26,9 @@ static_assert(_PSTL_VERSION_MAJOR == 10);
static_assert(_PSTL_VERSION_MINOR == 00);
static_assert(_PSTL_VERSION_PATCH == 0);
-static_assert(__INTEL_PSTL_VERSION == 211);
+static_assert(__INTEL_PSTL_VERSION == 212);
static_assert(__INTEL_PSTL_VERSION_MAJOR == 2);
-static_assert(__INTEL_PSTL_VERSION_MINOR == 11);
+static_assert(__INTEL_PSTL_VERSION_MINOR == 12);
int main() {
std::cout << TestUtils::done() << std::endl;
diff --git a/test/std/algorithms/alg.merge/inplace_merge.pass.cpp b/test/std/algorithms/alg.merge/inplace_merge.pass.cpp
index 0d81e7b5870..1c735d9ab9a 100644
--- a/test/std/algorithms/alg.merge/inplace_merge.pass.cpp
+++ b/test/std/algorithms/alg.merge/inplace_merge.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- inplace_merge.pass.cpp --------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -154,6 +154,12 @@ main()
test_algo_basic_single(run_for_rnd_bi>());
+ test_by_type(
+ [](std::size_t idx){ return MemoryChecker{std::int32_t(idx * 2)}; },
+ [](std::size_t idx){ return MemoryChecker{std::int32_t(idx * 2 + 1)}; },
+ [](const MemoryChecker& val1, const MemoryChecker& val2){ return val1.value() < val2.value(); });
+ EXPECT_TRUE(MemoryChecker::alive_objects() == 0, "wrong effect from inplace_merge: number of ctor and dtor calls is not equal");
+
std::cout << done() << std::endl;
return 0;
}
diff --git a/test/std/algorithms/alg.merge/merge.pass.cpp b/test/std/algorithms/alg.merge/merge.pass.cpp
index 218143562e3..54e835d0309 100644
--- a/test/std/algorithms/alg.merge/merge.pass.cpp
+++ b/test/std/algorithms/alg.merge/merge.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- merge.pass.cpp ----------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
index 8485750497c..896ae136330 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- copy_if.pass.cpp --------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
index 9182d94c253..c9756a6cd62 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- is_partitioned.pass.cpp -------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp
index d22c28f8175..55ce4ba3c12 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- partition.pass.cpp ------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
index 61674530a6d..9b8b66da4a2 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- partition_copy.pass.cpp -------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp
index 43e4d32e1ff..aa30bf79cde 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- reverse.pass.cpp --------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
index b9b71929c3a..da1d6bbdfdb 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- reverse_copy.pass.cpp ---------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/copy_move.pass.cpp b/test/std/algorithms/alg.modifying.operations/copy_move.pass.cpp
index 622432bc0e4..f59ccce8f13 100644
--- a/test/std/algorithms/alg.modifying.operations/copy_move.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/copy_move.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- copy_move.pass.cpp ------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/fill.pass.cpp b/test/std/algorithms/alg.modifying.operations/fill.pass.cpp
index e3c58f1ee3e..62255e5c2a0 100644
--- a/test/std/algorithms/alg.modifying.operations/fill.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/fill.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- fill.pass.cpp -----------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/generate.pass.cpp b/test/std/algorithms/alg.modifying.operations/generate.pass.cpp
index 13d38a36b0d..bd87a5cae37 100644
--- a/test/std/algorithms/alg.modifying.operations/generate.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/generate.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- generate.pass.cpp -------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/remove.pass.cpp b/test/std/algorithms/alg.modifying.operations/remove.pass.cpp
index f0837d26e93..a8560baefe5 100644
--- a/test/std/algorithms/alg.modifying.operations/remove.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/remove.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- remove.pass.cpp ---------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -155,6 +155,12 @@ main()
test_algo_basic_single(run_for_rnd_fw());
+ test(MemoryChecker{0}, MemoryChecker{1},
+ [](const MemoryChecker& val){ return val.value() == 1; },
+ [](std::size_t idx){ return MemoryChecker{std::int32_t(idx % 3 == 0)}; }
+ );
+ EXPECT_TRUE(MemoryChecker::alive_objects() == 0, "wrong effect from remove,remove_if: number of ctor and dtor calls is not equal");
+
std::cout << done() << std::endl;
return 0;
}
diff --git a/test/std/algorithms/alg.modifying.operations/remove_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/remove_copy.pass.cpp
index 226458d34a7..cad90f5dd55 100644
--- a/test/std/algorithms/alg.modifying.operations/remove_copy.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/remove_copy.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- remove_copy.pass.cpp ----------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/replace.pass.cpp b/test/std/algorithms/alg.modifying.operations/replace.pass.cpp
index 4959f4d3fa2..ae32808dbba 100644
--- a/test/std/algorithms/alg.modifying.operations/replace.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/replace.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- replace.pass.cpp --------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/replace_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/replace_copy.pass.cpp
index 05310e4dc16..eb42ed1c062 100644
--- a/test/std/algorithms/alg.modifying.operations/replace_copy.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/replace_copy.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- replace_copy.pass.cpp ---------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/rotate.pass.cpp b/test/std/algorithms/alg.modifying.operations/rotate.pass.cpp
index 8a0687898cf..40f34e29119 100644
--- a/test/std/algorithms/alg.modifying.operations/rotate.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/rotate.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- rotate.pass.cpp ---------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -171,6 +171,8 @@ main()
{
test();
test>();
+ test();
+ EXPECT_TRUE(MemoryChecker::alive_objects() == 0, "wrong effect from rotate: number of ctor and dtor calls is not equal");
std::cout << done() << std::endl;
return 0;
diff --git a/test/std/algorithms/alg.modifying.operations/rotate_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/rotate_copy.pass.cpp
index 00f22ce1070..78fc911cd1e 100644
--- a/test/std/algorithms/alg.modifying.operations/rotate_copy.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/rotate_copy.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- rotate_copy.pass.cpp ----------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/swap_ranges.pass.cpp b/test/std/algorithms/alg.modifying.operations/swap_ranges.pass.cpp
index 5af30995b68..413e3a9a28d 100644
--- a/test/std/algorithms/alg.modifying.operations/swap_ranges.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/swap_ranges.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- swap_ranges.pass.cpp ----------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/transform_binary.pass.cpp b/test/std/algorithms/alg.modifying.operations/transform_binary.pass.cpp
index c0a32979b1b..e5693f2446c 100644
--- a/test/std/algorithms/alg.modifying.operations/transform_binary.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/transform_binary.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- transform_binary.pass.cpp -----------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/transform_unary.pass.cpp b/test/std/algorithms/alg.modifying.operations/transform_unary.pass.cpp
index cee70259d36..3fba7ddc5aa 100644
--- a/test/std/algorithms/alg.modifying.operations/transform_unary.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/transform_unary.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- transform_unary.pass.cpp ------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.modifying.operations/unique.pass.cpp b/test/std/algorithms/alg.modifying.operations/unique.pass.cpp
index ebdcbdb8822..26a81bc00d7 100644
--- a/test/std/algorithms/alg.modifying.operations/unique.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/unique.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- unique.pass.cpp ---------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -156,6 +156,11 @@ main()
test_algo_basic_single(run_for_rnd_fw>());
+ test(
+ [](std::size_t idx){ return MemoryChecker{std::int32_t(idx / 3)}; },
+ [](const MemoryChecker& val1, const MemoryChecker& val2){ return val1.value() == val2.value(); });
+ EXPECT_TRUE(MemoryChecker::alive_objects() == 0, "wrong effect from unique: number of ctor and dtor calls is not equal");
+
std::cout << done() << std::endl;
return 0;
}
diff --git a/test/std/algorithms/alg.modifying.operations/unique_copy_equal.pass.cpp b/test/std/algorithms/alg.modifying.operations/unique_copy_equal.pass.cpp
index 6fe52f84e6d..5b1eadd66f0 100644
--- a/test/std/algorithms/alg.modifying.operations/unique_copy_equal.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/unique_copy_equal.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- unique_copy_equal.pass.cpp ----------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp b/test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp
index 66d69a96426..4c227a09e64 100644
--- a/test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- adjacent_find.pass.cpp --------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/all_of.pass.cpp b/test/std/algorithms/alg.nonmodifying/all_of.pass.cpp
index 9d3b77842c2..1fea6e86cd5 100644
--- a/test/std/algorithms/alg.nonmodifying/all_of.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/all_of.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- all_of.pass.cpp ---------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/any_of.pass.cpp b/test/std/algorithms/alg.nonmodifying/any_of.pass.cpp
index 40cdf3b850e..73dd48822ea 100644
--- a/test/std/algorithms/alg.nonmodifying/any_of.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/any_of.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- any_of.pass.cpp ---------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/count.pass.cpp b/test/std/algorithms/alg.nonmodifying/count.pass.cpp
index 29614acd6c2..e487916af72 100644
--- a/test/std/algorithms/alg.nonmodifying/count.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/count.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- count.pass.cpp ----------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/equal.pass.cpp b/test/std/algorithms/alg.nonmodifying/equal.pass.cpp
index 0abe15765f5..343b6cfad1c 100644
--- a/test/std/algorithms/alg.nonmodifying/equal.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/equal.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- equal.pass.cpp ----------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/find.pass.cpp b/test/std/algorithms/alg.nonmodifying/find.pass.cpp
index fc9b336741e..db5b21f0fc4 100644
--- a/test/std/algorithms/alg.nonmodifying/find.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/find.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- find.pass.cpp -----------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/find_end.pass.cpp b/test/std/algorithms/alg.nonmodifying/find_end.pass.cpp
index 402ec7459d9..1697da0f10f 100644
--- a/test/std/algorithms/alg.nonmodifying/find_end.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/find_end.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- find_end.pass.cpp -------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/find_first_of.pass.cpp b/test/std/algorithms/alg.nonmodifying/find_first_of.pass.cpp
index 0122f9f1488..9cedc9e6433 100644
--- a/test/std/algorithms/alg.nonmodifying/find_first_of.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/find_first_of.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- find_first_of.pass.cpp --------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/find_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/find_if.pass.cpp
index f3f3f09fcba..0e5c42edc1c 100644
--- a/test/std/algorithms/alg.nonmodifying/find_if.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/find_if.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- find_if.pass.cpp --------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/for_each.pass.cpp b/test/std/algorithms/alg.nonmodifying/for_each.pass.cpp
index 9207d13f9f1..1ba3d3c25eb 100644
--- a/test/std/algorithms/alg.nonmodifying/for_each.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/for_each.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- for_each.pass.cpp -------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/mismatch.pass.cpp b/test/std/algorithms/alg.nonmodifying/mismatch.pass.cpp
index e4267ad9b08..2d4d486ce36 100644
--- a/test/std/algorithms/alg.nonmodifying/mismatch.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/mismatch.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- mismatch.pass.cpp -------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/none_of.pass.cpp b/test/std/algorithms/alg.nonmodifying/none_of.pass.cpp
index f0dbd589862..eb7130e19a1 100644
--- a/test/std/algorithms/alg.nonmodifying/none_of.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/none_of.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- none_of.pass.cpp --------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/nth_element.pass.cpp b/test/std/algorithms/alg.nonmodifying/nth_element.pass.cpp
index ff4d6919d2d..34b11dcf01d 100644
--- a/test/std/algorithms/alg.nonmodifying/nth_element.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/nth_element.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- nth_element.pass.cpp ----------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.nonmodifying/search_n.pass.cpp b/test/std/algorithms/alg.nonmodifying/search_n.pass.cpp
index 561cadb0bd3..5bfea8d896d 100644
--- a/test/std/algorithms/alg.nonmodifying/search_n.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/search_n.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- search_n.pass.cpp -------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -95,11 +95,6 @@ test()
std::size_t res[] = {0, 1, n1 / 2, n1};
for (auto n2 : sub_n)
{
- // Some of standard libraries return "first" in this case. We return "last" according to the standard
- if (n2 == 0)
- {
- continue;
- }
for (auto r : res)
{
Sequence in(n1, [n1](std::size_t k) { return T(0); });
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/is_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/is_heap.pass.cpp
index 08ddeea6215..56881872c81 100644
--- a/test/std/algorithms/alg.sorting/alg.heap.operations/is_heap.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/is_heap.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- is_heap.pass.cpp --------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp b/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp
index 26c9b777632..5c0c3c3a9ef 100644
--- a/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- lexicographical_compare.pass.cpp ----------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
index ae2245ad040..1355ca508c9 100644
--- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- minmax_element.pass.cpp -------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/includes.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/includes.pass.cpp
index 4e37d077e13..75b6a44f31b 100644
--- a/test/std/algorithms/alg.sorting/alg.set.operations/includes.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/includes.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- includes.pass.cpp -------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp
index 3cd1232ec82..5ab88cce9b2 100644
--- a/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- set.pass.cpp ------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -263,6 +263,10 @@ main()
test_set(pstl::__internal::__pstl_less());
test_set, Num>([](const Num& x, const Num& y) { return x < y; });
+ test_set([](const MemoryChecker& val1, const MemoryChecker& val2) -> bool {
+ return val1.value() < val2.value();
+ });
+ EXPECT_TRUE(MemoryChecker::alive_objects() == 0, "wrong effect from set algorithms: number of ctor and dtor calls is not equal");
test_algo_basic_double(run_for_rnd_fw>());
test_algo_basic_double(run_for_rnd_fw>());
test_algo_basic_double(run_for_rnd_fw>());
diff --git a/test/std/algorithms/alg.sorting/is_sorted.pass.cpp b/test/std/algorithms/alg.sorting/is_sorted.pass.cpp
index 0fd789ed181..6b456a53932 100644
--- a/test/std/algorithms/alg.sorting/is_sorted.pass.cpp
+++ b/test/std/algorithms/alg.sorting/is_sorted.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- is_sorted.pass.cpp ------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.sorting/partial_sort.pass.cpp b/test/std/algorithms/alg.sorting/partial_sort.pass.cpp
index 439f5973151..f852f84e289 100644
--- a/test/std/algorithms/alg.sorting/partial_sort.pass.cpp
+++ b/test/std/algorithms/alg.sorting/partial_sort.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- partial_sort.pass.cpp ---------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/algorithms/alg.sorting/partial_sort_copy.pass.cpp b/test/std/algorithms/alg.sorting/partial_sort_copy.pass.cpp
index 0d3f8b4b51b..17b375cc0d1 100644
--- a/test/std/algorithms/alg.sorting/partial_sort_copy.pass.cpp
+++ b/test/std/algorithms/alg.sorting/partial_sort_copy.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- partial_sort_copy.pass.cpp ----------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -192,6 +192,10 @@ main()
test_algo_basic_double(run_for_rnd>());
+ test_partial_sort_copy(
+ [](const MemoryChecker& val1, const MemoryChecker& val2){ return val1.value() < val2.value(); });
+ EXPECT_TRUE(MemoryChecker::alive_objects() == 0, "wrong effect from partial_sort_copy: number of ctor and dtor calls is not equal");
+
std::cout << done() << std::endl;
return 0;
}
diff --git a/test/std/algorithms/alg.sorting/sort.pass.cpp b/test/std/algorithms/alg.sorting/sort.pass.cpp
index 105c7f0f4b3..bb2715d5e1c 100644
--- a/test/std/algorithms/alg.sorting/sort.pass.cpp
+++ b/test/std/algorithms/alg.sorting/sort.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- sort.pass.cpp -----------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/experimental/for_loop.pass.cpp b/test/std/experimental/for_loop.pass.cpp
index 923e4f21995..7f708fd37ab 100644
--- a/test/std/experimental/for_loop.pass.cpp
+++ b/test/std/experimental/for_loop.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- for_loop.pass.cpp -------------------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/experimental/for_loop_induction.pass.cpp b/test/std/experimental/for_loop_induction.pass.cpp
index 594205d2ec2..905b80904c2 100644
--- a/test/std/experimental/for_loop_induction.pass.cpp
+++ b/test/std/experimental/for_loop_induction.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- for_loop_induction.pass.cpp ---------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/experimental/for_loop_reduction.pass.cpp b/test/std/experimental/for_loop_reduction.pass.cpp
index 54a52b90ec0..ff866e33405 100644
--- a/test/std/experimental/for_loop_reduction.pass.cpp
+++ b/test/std/experimental/for_loop_reduction.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- for_loop_reduction.pass.cpp ---------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/numerics/numeric.ops/adjacent_difference.pass.cpp b/test/std/numerics/numeric.ops/adjacent_difference.pass.cpp
index 055115a454c..d53046acc76 100644
--- a/test/std/numerics/numeric.ops/adjacent_difference.pass.cpp
+++ b/test/std/numerics/numeric.ops/adjacent_difference.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- adjacent_difference.pass.cpp --------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/numerics/numeric.ops/reduce.pass.cpp b/test/std/numerics/numeric.ops/reduce.pass.cpp
index bae1e5b30c9..cb8dabcb371 100644
--- a/test/std/numerics/numeric.ops/reduce.pass.cpp
+++ b/test/std/numerics/numeric.ops/reduce.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- reduce.pass.cpp ---------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/numerics/numeric.ops/transform_reduce.pass.cpp b/test/std/numerics/numeric.ops/transform_reduce.pass.cpp
index 844cbcf0c9b..71ffd2bf189 100644
--- a/test/std/numerics/numeric.ops/transform_reduce.pass.cpp
+++ b/test/std/numerics/numeric.ops/transform_reduce.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- transform_reduce.pass.cpp -----------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/numerics/numeric.ops/transform_scan.pass.cpp b/test/std/numerics/numeric.ops/transform_scan.pass.cpp
index 0e497b60fac..0d099f8e1dd 100644
--- a/test/std/numerics/numeric.ops/transform_scan.pass.cpp
+++ b/test/std/numerics/numeric.ops/transform_scan.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- transform_scan.pass.cpp -------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized_construct.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized_construct.pass.cpp
index 68cea822f53..0bb14b4231e 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized_construct.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized_construct.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- uninitialized_construct.pass.cpp ----------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized_copy_move.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized_copy_move.pass.cpp
index 331a5973de5..b79a137e797 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized_copy_move.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized_copy_move.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- uninitialized_copy_move.pass.cpp ----------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized_fill_destroy.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized_fill_destroy.pass.cpp
index f6829ebd7f2..d1e01e7b906 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized_fill_destroy.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized_fill_destroy.pass.cpp
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- uninitialized_fill_destroy.pass.cpp -------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/support/iterator_utils.h b/test/support/iterator_utils.h
index 95008018089..749a0217d56 100644
--- a/test/support/iterator_utils.h
+++ b/test/support/iterator_utils.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- iterator_utils.h --------------------------------------------------===//
//
-// Copyright (C) 2019 Intel Corporation
+// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/support/pstl_test_config.h b/test/support/pstl_test_config.h
index e07daf92ef3..68fc2f804ad 100644
--- a/test/support/pstl_test_config.h
+++ b/test/support/pstl_test_config.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- pstl_test_config.h ------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/test/support/utils.h b/test/support/utils.h
index dc6ad99c131..f689533f400 100644
--- a/test/support/utils.h
+++ b/test/support/utils.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
//===-- utils.h -----------------------------------------------------------===//
//
-// Copyright (C) 2017-2019 Intel Corporation
+// Copyright (C) 2017-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -149,6 +149,84 @@ fill_data(Iterator first, Iterator last, F f)
}
}
+struct MemoryChecker {
+ // static counters and state tags
+ static std::atomic alive_object_counter; // initialized outside
+ // since it can truncate the value on 32-bit platforms
+ // we have to explicitly cast it to desired type to avoid any warnings
+ static constexpr std::size_t alive_state = std::size_t(0xAAAAAAAAAAAAAAAA);
+ static constexpr std::size_t dead_state = 0; // only used as a set value to cancel alive_state
+
+ std::int32_t _value; // object value used for algorithms
+ std::size_t _state; // state tag used for checks
+
+ // ctors, dtors, assign ops
+ explicit MemoryChecker(std::int32_t value = 0) : _value(value) {
+ // check for EXPECT_TRUE(state() != alive_state, ...) has not been done since we cannot guarantee that
+ // raw memory for object being constructed does not have a bit sequence being equal to alive_state
+
+ // set constructed state and increment counter for living object
+ inc_alive_objects();
+ _state = alive_state;
+ }
+ MemoryChecker(MemoryChecker&& other) : _value(other.value()) {
+ // check for EXPECT_TRUE(state() != alive_state, ...) has not been done since
+ // compiler can optimize out the move ctor call that results in false positive failure
+ EXPECT_TRUE(other.state() == alive_state, "wrong effect from MemoryChecker(MemoryChecker&&): attemp to construct an object from non-existing object");
+ // set constructed state and increment counter for living object
+ inc_alive_objects();
+ _state = alive_state;
+ }
+ MemoryChecker(const MemoryChecker& other) : _value(other.value()) {
+ // check for EXPECT_TRUE(state() != alive_state, ...) has not been done since
+ // compiler can optimize out the copy ctor call that results in false positive failure
+ EXPECT_TRUE(other.state() == alive_state, "wrong effect from MemoryChecker(const MemoryChecker&): attemp to construct an object from non-existing object");
+ // set constructed state and increment counter for living object
+ inc_alive_objects();
+ _state = alive_state;
+ }
+ MemoryChecker& operator=(MemoryChecker&& other) {
+ // check if we do not assign over uninitialized memory
+ EXPECT_TRUE(state() == alive_state, "wrong effect from MemoryChecker::operator=(MemoryChecker&& other): attemp to assign to non-existing object");
+ EXPECT_TRUE(other.state() == alive_state, "wrong effect from MemoryChecker::operator=(MemoryChecker&& other): attemp to assign from non-existing object");
+ // just assign new value, counter is the same, state is the same
+ _value = other.value();
+
+ return *this;
+ }
+ MemoryChecker& operator=(const MemoryChecker& other) {
+ // check if we do not assign over uninitialized memory
+ EXPECT_TRUE(state() == alive_state, "wrong effect from MemoryChecker::operator=(const MemoryChecker& other): attemp to assign to non-existing object");
+ EXPECT_TRUE(other.state() == alive_state, "wrong effect from MemoryChecker::operator=(const MemoryChecker& other): attemp to assign from non-existing object");
+ // just assign new value, counter is the same, state is the same
+ _value = other.value();
+
+ return *this;
+ }
+ ~MemoryChecker() {
+ // check if we do not double destruct the object
+ EXPECT_TRUE(state() == alive_state, "wrong effect from ~MemoryChecker(): attemp to destroy non-existing object");
+ // set destructed state and decrement counter for living object
+ static_cast(_state) = dead_state;
+ dec_alive_objects();
+ }
+
+ // getters
+ std::int32_t value() const { return _value; }
+ std::size_t state() const { return _state; }
+ static std::size_t alive_objects() { return alive_object_counter.load(); }
+private:
+ // setters
+ void inc_alive_objects() { alive_object_counter.fetch_add(1); }
+ void dec_alive_objects() { alive_object_counter.fetch_sub(1); }
+};
+
+std::atomic MemoryChecker::alive_object_counter{0};
+
+std::ostream& operator<<(std::ostream& os, const MemoryChecker& val) { return (os << val.value()); }
+bool operator==(const MemoryChecker& v1, const MemoryChecker& v2) { return v1.value() == v2.value(); }
+bool operator<(const MemoryChecker& v1, const MemoryChecker& v2) { return v1.value() < v2.value(); }
+
// Sequence is a container of a sequence of T with lots of kinds of iterators.
// Prefixes on begin/end mean:
// c = "const"
diff --git a/windows/pstlvars.bat b/windows/pstlvars.bat
index 84d1879611b..52bf6ddfbb6 100755
--- a/windows/pstlvars.bat
+++ b/windows/pstlvars.bat
@@ -1,7 +1,7 @@
@echo off
REM ===-- pstlvars.bat ------------------------------------------------------===##
REM
-REM Copyright (C) 2017-2019 Intel Corporation
+REM Copyright (C) 2017-2020 Intel Corporation
REM
REM SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
REM