diff --git a/CHANGES b/CHANGES
index 330c0602b80..b3bebc316ee 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,41 @@
+------------------------------------------------------------------------
+The list of most significant changes made over time in Parallel STL.
+
+Parallel STL 20171127 release
+PSTL_VERSION == 102
+
+Features / APIs:
+
+- Added Parallel STL version macros:
+ PSTL_VERSION, PSTL_VERSION_MAJOR, PSTL_VERSION_MINOR.
+- More algorithms support parallel and vector execution policies:
+ move, partition_copy, mismatch.
+- More algorithms support parallel execution policies:
+ min_element, max_element, minmax_element.
+
+------------------------------------------------------------------------
+Parallel STL release within Intel(R) Parallel Studio XE 2018 Update 1
+
+Features / APIs:
+
+- More algorithms support parallel and vector execution policies:
+ destroy, destroy_n, uninitialized_copy, uninitialized_copy_n,
+ uninitialized_default_construct, uninitialized_default_construct_n,
+ uninitialized_fill, uninitialized_fill_n, uninitialized_move,
+ uninitialized_move_n, uninitialized_value_construct,
+ uninitialized_value_construct_n.
+- Improved performance in find_end and search algorithms.
+- Added macro PSTL_USE_NONTEMPORAL_STORES that can improve performance
+ of copy, copy_n, fill, fill_n, generate, generate_n algorithms with
+ unseq and par_unseq policies; by default the macro is not defined.
+
+Bugs fixed:
+
+- Fixed transform_inclusive_scan to correctly process the first element.
+- Fixed compile time error in sort algorithm when used with zip_iterator
+ and some other custom iterator types.
+- Fixed several algorithms to allow use of non-const functors.
+
------------------------------------------------------------------------
Parallel STL release within Intel(R) Parallel Studio XE 2018
diff --git a/README.md b/README.md
index 5bc468d5f9e..f70f728f8ae 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# Parallel STL
-[![Stable release](https://img.shields.io/badge/version-20170726-green.svg)](https://github.com/intel/parallelstl/releases/tag/20170726)
+[![Stable release](https://img.shields.io/badge/version-20171127-green.svg)](https://github.com/intel/parallelstl/releases/tag/20171127)
[![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE)
Parallel STL is an implementation of the C++ standard library algorithms with support for execution policies,
diff --git a/doc/Release_Notes.txt b/doc/Release_Notes.txt
index c57a683b066..a72a6889782 100644
--- a/doc/Release_Notes.txt
+++ b/doc/Release_Notes.txt
@@ -8,8 +8,8 @@ System Requirements
Parallel STL is available as a part of Intel(R) Parallel Studio XE 2018
and Intel(R) System Studio 2018.
- Parallel STL distributions are validated and officially supported for
-the hardware, software, operating systems and compilers listed here.
+ Parallel STL distributions are validated and officially supported
+for the hardware, software, operating systems and compilers listed here.
Hardware - Recommended
@@ -71,6 +71,9 @@ Software - Supported Operating Systems
Software - Supported Compilers
Intel(R) C++ Compiler 16, 17 and 18 version
+ Note: Using Intel C++ Compiler 18.0 might result
+ in better performance for many of Parallel STL algorithms,
+ comparing to previous compiler versions.
Microsoft* Visual C++ 14.0 (Microsoft* Visual Studio* 2015,
Windows* OS only)
Microsoft* Visual C++ 14.1 (Microsoft* Visual Studio* 2017,
@@ -95,8 +98,8 @@ Known Issues or limitations
------------------------------------------------------------------------
-Intel, the Intel logo, Intel Core, Intel Atom, Xeon, Intel Xeon Phi, and
-Pentium are trademarks of Intel Corporation in the U.S. and/or other
-countries.
+Intel, the Intel logo, Intel Core, Intel Atom, Xeon, Intel Xeon Phi,
+and Pentium 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.
diff --git a/examples/convex_hull/Makefile b/examples/convex_hull/Makefile
index 4395c9d3ad5..a6e75bd3d51 100644
--- a/examples/convex_hull/Makefile
+++ b/examples/convex_hull/Makefile
@@ -22,17 +22,20 @@ PROG=convex_hull.exe
ARGS=
CXXFLAGS += -D__PSTL_USE_TBB -std=c++11
-# The C++ compiler
+
+# Set by default icc as C++ compiler if it's present
ifneq (,$(shell which icc 2>/dev/null))
-CXX=icc
+CXX = icc
+endif # which icc
+ifeq ($(CXX),icc)
+CXXFLAGS += -qopenmp-simd
ifneq (, $(filter $(target), mic))
CXXFLAGS += -mmic
-else
+else
CXXFLAGS += -xHOST
-endif
-CXXFLAGS += -qopenmp-simd
-endif # which icc
+endif # target is mic or host?
+endif # icc?
ifeq ($(shell uname), Linux)
LIBS+= -lrt
diff --git a/examples/convex_hull/msvs/convex_hull.vcxproj b/examples/convex_hull/msvs/convex_hull.vcxproj
index d073fde9521..093f60c21aa 100644
--- a/examples/convex_hull/msvs/convex_hull.vcxproj
+++ b/examples/convex_hull/msvs/convex_hull.vcxproj
@@ -28,14 +28,14 @@
Application
true
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
Unicode
true
Application
false
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
true
Unicode
true
@@ -43,14 +43,14 @@
Application
true
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
Unicode
true
Application
false
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
true
Unicode
true
diff --git a/examples/dot_product/Makefile b/examples/dot_product/Makefile
index 5b7dd467241..2e70dc98252 100644
--- a/examples/dot_product/Makefile
+++ b/examples/dot_product/Makefile
@@ -22,17 +22,20 @@ PROG=dot_product.exe
ARGS=
CXXFLAGS += -D__PSTL_USE_TBB -std=c++11
-# The C++ compiler
+
+# Set by default icc as C++ compiler if it's present
ifneq (,$(shell which icc 2>/dev/null))
-CXX=icc
+CXX = icc
+endif # which icc
+ifeq ($(CXX),icc)
+CXXFLAGS += -qopenmp-simd
ifneq (, $(filter $(target), mic))
CXXFLAGS += -mmic
-else
+else
CXXFLAGS += -xHOST
-endif
-CXXFLAGS += -qopenmp-simd
-endif # which icc
+endif # target is mic or host?
+endif # icc?
ifeq ($(shell uname), Linux)
LIBS+= -lrt
diff --git a/examples/dot_product/msvs/dot_product.vcxproj b/examples/dot_product/msvs/dot_product.vcxproj
index 88c897950b2..00584190ab2 100644
--- a/examples/dot_product/msvs/dot_product.vcxproj
+++ b/examples/dot_product/msvs/dot_product.vcxproj
@@ -28,14 +28,14 @@
Application
true
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
Unicode
true
Application
false
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
true
Unicode
true
@@ -43,14 +43,14 @@
Application
true
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
Unicode
true
Application
false
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
true
Unicode
true
diff --git a/examples/gamma_correction/Makefile b/examples/gamma_correction/Makefile
index d315e485c63..3ea680d528f 100644
--- a/examples/gamma_correction/Makefile
+++ b/examples/gamma_correction/Makefile
@@ -22,17 +22,20 @@ PROG=gamma_correction.exe
ARGS=
CXXFLAGS += -D__PSTL_USE_TBB -std=c++11
-# The C++ compiler
+
+# Set by default icc as C++ compiler if it's present
ifneq (,$(shell which icc 2>/dev/null))
-CXX=icc
+CXX = icc
+endif # which icc
+ifeq ($(CXX),icc)
+CXXFLAGS += -qopenmp-simd
ifneq (, $(filter $(target), mic))
CXXFLAGS += -mmic
-else
+else
CXXFLAGS += -xHOST
-endif
-CXXFLAGS += -qopenmp-simd
-endif # which icc
+endif # target is mic or host?
+endif # icc?
ifeq ($(shell uname), Linux)
LIBS+= -lrt
diff --git a/examples/gamma_correction/msvs/gamma_correction.sln b/examples/gamma_correction/msvs/gamma_correction.sln
index f5d204c585d..f968409992d 100644
--- a/examples/gamma_correction/msvs/gamma_correction.sln
+++ b/examples/gamma_correction/msvs/gamma_correction.sln
@@ -8,19 +8,19 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
+ Debug|Win32 = Debug|Win32
Release|x64 = Release|x64
- Release|x86 = Release|x86
+ Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{33020498-816E-4A1D-A073-B0E4834AC979}.Debug|x64.ActiveCfg = Debug|x64
{33020498-816E-4A1D-A073-B0E4834AC979}.Debug|x64.Build.0 = Debug|x64
- {33020498-816E-4A1D-A073-B0E4834AC979}.Debug|x86.ActiveCfg = Debug|Win32
- {33020498-816E-4A1D-A073-B0E4834AC979}.Debug|x86.Build.0 = Debug|Win32
+ {33020498-816E-4A1D-A073-B0E4834AC979}.Debug|Win32.ActiveCfg = Debug|Win32
+ {33020498-816E-4A1D-A073-B0E4834AC979}.Debug|Win32.Build.0 = Debug|Win32
{33020498-816E-4A1D-A073-B0E4834AC979}.Release|x64.ActiveCfg = Release|x64
{33020498-816E-4A1D-A073-B0E4834AC979}.Release|x64.Build.0 = Release|x64
- {33020498-816E-4A1D-A073-B0E4834AC979}.Release|x86.ActiveCfg = Release|Win32
- {33020498-816E-4A1D-A073-B0E4834AC979}.Release|x86.Build.0 = Release|Win32
+ {33020498-816E-4A1D-A073-B0E4834AC979}.Release|Win32.ActiveCfg = Release|Win32
+ {33020498-816E-4A1D-A073-B0E4834AC979}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/examples/gamma_correction/msvs/gamma_correction.vcxproj b/examples/gamma_correction/msvs/gamma_correction.vcxproj
index 63ceba6e568..b5ce12fc59f 100644
--- a/examples/gamma_correction/msvs/gamma_correction.vcxproj
+++ b/examples/gamma_correction/msvs/gamma_correction.vcxproj
@@ -28,14 +28,14 @@
Application
true
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
Unicode
true
Application
false
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
true
Unicode
true
@@ -43,14 +43,14 @@
Application
true
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
Unicode
true
Application
false
- Intel C++ Compiler 17.0
+ Intel C++ Compiler 18.0
true
Unicode
true
diff --git a/include/pstl/_internal/memory_impl.h b/include/pstl/_internal/memory_impl.h
deleted file mode 100644
index 0dbd74203dc..00000000000
--- a/include/pstl/_internal/memory_impl.h
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- Copyright (c) 2017 Intel Corporation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
-
-
-*/
-
-#ifndef __PSTL_memory_impl_H
-#define __PSTL_memory_impl_H
-
-#include
-#include
-#include "execution_policy_impl.h"
-
-namespace __icp_algorithm {
-
-//------------------------------------------------------------------------
-// uninitialized_copy
-//------------------------------------------------------------------------
-
-template
-ForwardIterator brick_uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result, /*is_vector=*/std::false_type) noexcept {
- return std::uninitialized_copy(first, last, result);
-}
-
-template
-ForwardIterator brick_uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result, /*is_vector=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Vectorial algorithm unimplemented, redirected to serial");
- return std::uninitialized_copy(first, last, result);
-}
-
-template
-ForwardIterator pattern_uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- return brick_uninitialized_copy(first, last, result, is_vector);
-}
-
-template
-ForwardIterator pattern_uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- return brick_uninitialized_copy(first, last, result, is_vector);
-}
-
-//------------------------------------------------------------------------
-// uninitialized_copy_n
-//------------------------------------------------------------------------
-
-template
-ForwardIterator brick_uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result, /*is_vector=*/std::false_type) noexcept {
- return std::uninitialized_copy_n(first, n, result);
-}
-
-template
-ForwardIterator brick_uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result, /*is_vector=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Vectorial algorithm unimplemented, redirected to serial");
- return std::uninitialized_copy_n(first, n, result);
-}
-
-template
-ForwardIterator pattern_uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- return brick_uninitialized_copy_n(first, n, result, is_vector);
-}
-
-template
-ForwardIterator pattern_uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- return brick_uninitialized_copy_n(first, n, result, is_vector);
-}
-
-//------------------------------------------------------------------------
-// uninitialized_move
-//------------------------------------------------------------------------
-
-template
-void destroy_serial(ForwardIterator first, ForwardIterator last) {
- typedef typename std::iterator_traits::value_type T;
- while (first != last) {
- (*first).~T();
- ++first;
- }
-}
-
-template
-ForwardIterator brick_uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result, /*is_vector=*/std::false_type) noexcept {
- typedef typename std::iterator_traits::value_type Value;
- ForwardIterator current = result;
-
- try {
- while (first != last)
- new (static_cast(std::addressof(*(result++)))) Value(std::move(*(first++)));
-
- return result;
- } catch (...) {
- destroy_serial(current, result);
- std::terminate();
- }
-
- return result;
-}
-
-template
-ForwardIterator brick_uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result, /*is_vector=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Vectorial algorithm unimplemented, redirected to serial");
- return brick_uninitialized_move(first, last, result, std::false_type());
-}
-
-template
-ForwardIterator pattern_uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- return brick_uninitialized_move(first, last, result, is_vector);
-}
-
-template
-ForwardIterator pattern_uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- return brick_uninitialized_move(first, last, result, is_vector);
-}
-
-//------------------------------------------------------------------------
-// uninitialized_move_n
-//------------------------------------------------------------------------
-
-template
-ForwardIterator brick_uninitialized_move_n(InputIterator first, Size n, ForwardIterator result, /*is_vector=*/std::false_type) noexcept {
- typedef typename std::iterator_traits::value_type Value;
- ForwardIterator current = result;
-
- try {
- while (n-- > 0)
- new (static_cast(std::addressof(*(result++)))) Value(std::move(*(first++)));
-
- return result;
- } catch (...) {
- destroy_serial(current, result);
- std::terminate();
- }
-
- return result;
-}
-
-template
-ForwardIterator brick_uninitialized_move_n(InputIterator first, Size n, ForwardIterator result, /*is_vector=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Vectorial algorithm unimplemented, redirected to serial");
- return brick_uninitialized_move_n(first, n, result, std::false_type());
-}
-
-template
-ForwardIterator pattern_uninitialized_move_n(InputIterator first, Size n, ForwardIterator result, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- return brick_uninitialized_move_n(first, n, result, is_vector);
-}
-
-template
-ForwardIterator pattern_uninitialized_move_n(InputIterator first, Size n, ForwardIterator result, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- return brick_uninitialized_move_n(first, n, result, is_vector);
-}
-
-//------------------------------------------------------------------------
-// uninitialized_fill
-//------------------------------------------------------------------------
-
-template
-void brick_uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x, /*is_vector=*/std::false_type) noexcept {
- std::uninitialized_fill(first, last, x);
-}
-
-template
-void brick_uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x, /*is_vector=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Vectorial algorithm unimplemented, redirected to serial");
- std::uninitialized_fill(first, last, x);
-}
-
-template
-void pattern_uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- brick_uninitialized_fill(first, last, x, is_vector);
-}
-
-template
-void pattern_uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- brick_uninitialized_fill(first, last, x, is_vector);
-}
-
-//------------------------------------------------------------------------
-// uninitialized_fill_n
-//------------------------------------------------------------------------
-// Some C++11 compilers don't have a version of the algorithm std::uninitialized_fill_n that returns an iterator to the element past the last element filled.
-template< class ForwardIterator, class Size, class T >
-ForwardIterator uninitialized_fill_n_serial(ForwardIterator first, Size n, const T& x)
-{
- typedef typename std::iterator_traits::value_type Value;
- auto cur = first;
- try {
- while (n--) {
- ::new (static_cast(std::addressof(*cur))) Value(x);
- ++cur;
- }
- return cur;
- }
- catch (...) {
- destroy_serial(first, cur);
- std::terminate();
- }
-}
-
-template
-ForwardIterator brick_uninitialized_fill_n(ForwardIterator first, Size n, const T& x, /*is_vector=*/std::false_type) noexcept {
- return uninitialized_fill_n_serial(first, n, x);
-}
-
-template
-ForwardIterator brick_uninitialized_fill_n(ForwardIterator first, Size n, const T& x, /*is_vector=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Vectorial algorithm unimplemented, redirected to serial");
- return brick_uninitialized_fill_n(first, n, x, std::false_type());
-}
-
-template
-ForwardIterator pattern_uninitialized_fill_n(ForwardIterator first, Size n, const T& x, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- return brick_uninitialized_fill_n(first, n, x, is_vector);
-}
-
-template
-ForwardIterator pattern_uninitialized_fill_n(ForwardIterator first, Size n, const T& x, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- return brick_uninitialized_fill_n(first, n, x, is_vector);
-}
-
-//------------------------------------------------------------------------
-// destroy
-//------------------------------------------------------------------------
-
-template
-void brick_destroy(ForwardIterator first, ForwardIterator last, /*is_vector=*/std::false_type) noexcept {
- destroy_serial(first, last);
-}
-
-template
-void brick_destroy(ForwardIterator first, ForwardIterator last, /*is_vector=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Vectorial algorithm unimplemented, redirected to serial");
- brick_destroy(first, last, std::false_type());
-}
-
-template
-void pattern_destroy(ForwardIterator first, ForwardIterator last, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- brick_destroy(first, last, is_vector);
-}
-
-template
-void pattern_destroy(ForwardIterator first, ForwardIterator last, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- brick_destroy(first, last, is_vector);
-}
-
-//------------------------------------------------------------------------
-// destroy_n
-//------------------------------------------------------------------------
-
-template
-ForwardIterator destroy_n_serial(ForwardIterator first, Size n) {
- typedef typename std::iterator_traits::value_type T;
- while (n--) {
- (*first).~T();
- ++first;
- }
- return first;
-}
-
-template
-ForwardIterator brick_destroy_n(ForwardIterator first, Size n, /*is_vector=*/std::false_type) noexcept {
- return destroy_n_serial(first, n);
-}
-
-template
-ForwardIterator brick_destroy_n(ForwardIterator first, Size n, /*is_vector=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Vectorial algorithm unimplemented, redirected to serial");
- return brick_destroy_n(first, n, std::false_type());
-}
-
-template
-ForwardIterator pattern_destroy_n(ForwardIterator first, Size n, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- return brick_destroy_n(first, n, is_vector);
-}
-
-template
-ForwardIterator pattern_destroy_n(ForwardIterator first, Size n, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
-__PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- return brick_destroy_n(first, n, is_vector);
-}
-
-//------------------------------------------------------------------------
-// uninitialized_default_construct
-//------------------------------------------------------------------------
-template
-struct Construct {
- void operator()(void* ptr) {
- ::new (ptr) T;
- }
-};
-
-template
-struct Construct {
- void operator()(void* ptr) {
- ::new (ptr) T();
- }
-};
-
-template
-void brick_uninitialized_construct(ForwardIterator first, ForwardIterator last, /*is_vector=*/std::false_type) noexcept {
- typedef typename std::iterator_traits::value_type value_type;
- auto cur = first; // Save the iterator for catching exceptions
- try {
- for (; cur != last; ++cur)
- Construct()(static_cast(std::addressof(*cur)));
- }
- catch (...) {
- destroy_serial(first, cur);
- std::terminate();
- }
-}
-
-template
-void brick_uninitialized_construct(ForwardIterator first, ForwardIterator last, /*is_vector=*/std::true_type) noexcept {
- __PSTL_PRAGMA_MESSAGE("Vectorial algorithm unimplemented, redirected to serial");
- brick_uninitialized_construct(first, last, std::false_type());
-}
-
-template
-void pattern_uninitialized_default_construct(ForwardIterator first, ForwardIterator last, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- brick_uninitialized_construct(first, last, is_vector);
-}
-
-template
-void pattern_uninitialized_default_construct(ForwardIterator first, ForwardIterator last, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
- __PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- brick_uninitialized_construct(first, last, is_vector);
-}
-
-//------------------------------------------------------------------------
-// uninitialized_default_construct_n
-//------------------------------------------------------------------------
-
-template
-ForwardIterator brick_uninitialized_construct_n(ForwardIterator first, Size n, /*is_vector=*/std::false_type) noexcept {
- typedef typename std::iterator_traits::value_type value_type;
- auto cur = first;
- try {
- for (; n > 0; ++cur, --n)
- Construct()(static_cast(std::addressof(*cur)));
- return cur;
- }
- catch (...) {
- destroy_serial(first, cur);
- std::terminate();
- }
-}
-
-template
-ForwardIterator brick_uninitialized_construct_n(ForwardIterator first, Size n, /*is_vector=*/std::true_type) noexcept {
- __PSTL_PRAGMA_MESSAGE("Vectorial algorithm unimplemented, redirected to serial");
- return brick_uninitialized_construct_n(first, n, std::false_type());
-}
-
-template
-ForwardIterator pattern_uninitialized_default_construct_n(ForwardIterator first, Size n, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- return brick_uninitialized_construct_n(first, n, is_vector);
-}
-
-template
-ForwardIterator pattern_uninitialized_default_construct_n(ForwardIterator first, Size n, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
- __PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- return brick_uninitialized_construct_n(first, n, is_vector);
-}
-
-//------------------------------------------------------------------------
-// uninitialized_value_construct
-//------------------------------------------------------------------------
-
-template
-void pattern_uninitialized_value_construct(ForwardIterator first, ForwardIterator last, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- brick_uninitialized_construct(first, last, is_vector);
-}
-
-template
-void pattern_uninitialized_value_construct(ForwardIterator first, ForwardIterator last, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
- __PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- brick_uninitialized_construct(first, last, is_vector);
-}
-
-//------------------------------------------------------------------------
-// uninitialized_value_construct_n
-//------------------------------------------------------------------------
-
-template
-ForwardIterator pattern_uninitialized_value_construct_n(ForwardIterator first, Size n, IsVector is_vector, /*is_parallel=*/std::false_type) noexcept {
- return brick_uninitialized_construct_n(first, n, is_vector);
-}
-
-template
-ForwardIterator pattern_uninitialized_value_construct_n(ForwardIterator first, Size n, IsVector is_vector, /*is_parallel=*/std::true_type) noexcept {
- __PSTL_PRAGMA_MESSAGE("Parallel algorithm unimplemented, redirected to serial");
- return brick_uninitialized_construct_n(first, n, is_vector);
-}
-} // namespace __icp_algorithm
-#endif //__PSTL_memory_impl_H
diff --git a/include/pstl/algorithm b/include/pstl/algorithm
index 6cc7952b513..d6a18ddc5a3 100644
--- a/include/pstl/algorithm
+++ b/include/pstl/algorithm
@@ -23,136 +23,137 @@
#include
-#include "_internal/pstl_config.h"
-#include "_internal/common.h"
-#include "_internal/simd_impl.h"
-#include "_internal/algorithm_impl.h"
-#include "_internal/numeric_impl.h" /* count and count_if use pattern_transform_reduce */
-#if __PSTL_USE_TBB
- #include "_internal/parallel_impl_tbb.h"
-#else
- __PSTL_PRAGMA_MESSAGE("Backend was not specified");
-#endif
+#include "internal/pstl_config.h"
+#include "internal/common.h"
+#include "internal/simd_impl.h"
+#include "internal/algorithm_impl.h"
+#include "internal/numeric_impl.h" /* count and count_if use pattern_transform_reduce */
namespace std {
// [alg.any_of]
template
-__icp_algorithm::enable_if_execution_policy
-any_of( ExecutionPolicy&& exec, InputIterator first, InputIterator last, Predicate pred ) {
- return __icp_algorithm::pattern_any_of( first, last, pred,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+pstl::internal::enable_if_execution_policy
+any_of(ExecutionPolicy&& exec, InputIterator first, InputIterator last, Predicate pred) {
+ using namespace pstl::internal;
+ return pattern_any_of( first, last, pred,
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
// [alg.all_of]
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
all_of(ExecutionPolicy&& exec, InputIterator first, InputIterator last, Pred pred) {
- return !any_of(std::forward(exec), first, last, __icp_algorithm::not_pred(pred));
+ return !any_of(std::forward(exec), first, last, pstl::internal::not_pred(pred));
}
// [alg.none_of]
template
-__icp_algorithm::enable_if_execution_policy
-none_of( ExecutionPolicy&& exec, InputIterator first, InputIterator last, Predicate pred ) {
+pstl::internal::enable_if_execution_policy
+none_of(ExecutionPolicy&& exec, InputIterator first, InputIterator last, Predicate pred) {
return !any_of( std::forward(exec), first, last, pred );
}
// [alg.foreach]
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
for_each(ExecutionPolicy&& exec, InputIterator first, InputIterator last, Function f) {
- __icp_algorithm::pattern_walk1(
+ using namespace pstl::internal;
+ pattern_walk1(
first, last, f,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
for_each_n(ExecutionPolicy&& exec, InputIterator first, Size n, Function f) {
- return __icp_algorithm::pattern_walk1_n( first, n, f,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ using namespace pstl::internal;
+ return pattern_walk1_n(first, n, f,
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
// [alg.find]
template
-__icp_algorithm::enable_if_execution_policy
-find_if(ExecutionPolicy&& exec, InputIterator first, InputIterator last,
-Predicate pred) {
- return __icp_algorithm::pattern_find_if( first, last, pred,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+pstl::internal::enable_if_execution_policy
+find_if(ExecutionPolicy&& exec, InputIterator first, InputIterator last, Predicate pred) {
+ using namespace pstl::internal;
+ return pattern_find_if( first, last, pred,
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
find_if_not(ExecutionPolicy&& exec, InputIterator first, InputIterator last,
Predicate pred) {
- return find_if(exec,first,last,__icp_algorithm::not_pred(pred));
+ return find_if(exec, first, last, pstl::internal::not_pred(pred));
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
find(ExecutionPolicy&& exec, InputIterator first, InputIterator last,
const T& value) {
- return find_if(exec, first, last, __icp_algorithm::equal_value(value));
+ return find_if(exec, first, last, pstl::internal::equal_value(value));
}
// [alg.find.end]
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
find_end(ExecutionPolicy &&exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 s_first, ForwardIterator2 s_last, BinaryPredicate pred) {
- return __icp_algorithm::pattern_find_end(first, last, s_first, s_last, pred,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ using namespace pstl::internal;
+ return pattern_find_end(first, last, s_first, s_last, pred,
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
find_end(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 s_first, ForwardIterator2 s_last) {
return find_end(exec, first, last, s_first, s_last, std::equal_to::value_type>());
}
// [alg.find_first_of]
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
find_first_of(ExecutionPolicy&& exec, InputIterator first, InputIterator last, ForwardIterator s_first, ForwardIterator s_last, BinaryPredicate pred) {
- return __icp_algorithm::pattern_find_first_of(first, last, s_first, s_last, pred,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ using namespace pstl::internal;
+ return pattern_find_first_of(first, last, s_first, s_last, pred,
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
find_first_of(ExecutionPolicy&& exec, InputIterator first, InputIterator last, ForwardIterator s_first, ForwardIterator s_last) {
return find_first_of(exec, first, last, s_first, s_last, std::equal_to::value_type>());
}
// [alg.adjacent_find]
template< class ExecutionPolicy, class ForwardIt >
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
adjacent_find(ExecutionPolicy&& exec, ForwardIt first, ForwardIt last) {
typedef typename iterator_traits::value_type value_type;
-
- return __icp_algorithm::pattern_adjacent_find(first, last, std::equal_to(),
- __icp_algorithm::is_parallelization_preferred(exec),
- __icp_algorithm::is_vectorization_preferred(exec), /*first_semantic*/ false);
+ using namespace pstl::internal;
+ return pattern_adjacent_find(first, last, std::equal_to(),
+ is_parallelization_preferred(exec),
+ is_vectorization_preferred(exec), /*first_semantic*/ false);
}
template< class ExecutionPolicy, class ForwardIt, class BinaryPredicate>
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
adjacent_find(ExecutionPolicy&& exec, ForwardIt first, ForwardIt last, BinaryPredicate pred) {
-return __icp_algorithm::pattern_adjacent_find(first, last, pred,
- __icp_algorithm::is_parallelization_preferred(exec),
- __icp_algorithm::is_vectorization_preferred(exec), /*first_semantic*/ false);
+ using namespace pstl::internal;
+ return pattern_adjacent_find(first, last, pred,
+ is_parallelization_preferred(exec),
+ is_vectorization_preferred(exec), /*first_semantic*/ false);
}
// [alg.count]
@@ -161,35 +162,37 @@ return __icp_algorithm::pattern_adjacent_find(first, last, pred,
// so that we do not have to include .
template
-__icp_algorithm::enable_if_execution_policy::difference_type>
+pstl::internal::enable_if_execution_policy::difference_type>
count(ExecutionPolicy&& exec, InputIterator first, InputIterator last, const T& value) {
typedef typename iterator_traits::value_type value_type;
-
- return __icp_algorithm::pattern_count(first, last, [&value](value_type x) {return value==x;},
- __icp_algorithm::is_parallelization_preferred(exec),
- __icp_algorithm::is_vectorization_preferred(exec));
+ using namespace pstl::internal;
+ return pattern_count(first, last, [&value](value_type x) {return value==x;},
+ is_parallelization_preferred(exec),
+ is_vectorization_preferred(exec));
}
template
-__icp_algorithm::enable_if_execution_policy::difference_type>
+pstl::internal::enable_if_execution_policy::difference_type>
count_if(ExecutionPolicy&& exec, InputIterator first, InputIterator last, Predicate pred) {
- return __icp_algorithm::pattern_count(first, last, pred,
- __icp_algorithm::is_parallelization_preferred(exec),
- __icp_algorithm::is_vectorization_preferred(exec));
+ using namespace pstl::internal;
+ return pattern_count(first, last, pred,
+ is_parallelization_preferred(exec),
+ is_vectorization_preferred(exec));
}
// [alg.search]
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
search(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 s_first, ForwardIterator2 s_last, BinaryPredicate pred) {
- return __icp_algorithm::pattern_search(first, last, s_first, s_last, pred,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ using namespace pstl::internal;
+ return pattern_search(first, last, s_first, s_last, pred,
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
search(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 s_first, ForwardIterator2 s_last) {
typedef typename iterator_traits::value_type value_type;
@@ -197,15 +200,16 @@ search(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, Fo
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
search_n(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Size count, const T& value, BinaryPredicate pred) {
- return __icp_algorithm::pattern_search_n(first, last, count, value, pred,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ using namespace pstl::internal;
+ return pattern_search_n(first, last, count, value, pred,
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
search_n(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Size count, const T& value) {
return search_n(exec, first, last, count, value, std::equal_to::value_type>());
}
@@ -213,286 +217,311 @@ search_n(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Si
// [alg.copy]
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
copy(ExecutionPolicy&& exec, InputIterator first, InputIterator last, OutputIterator result) {
- return __icp_algorithm::pattern_copy(
- first, last, result,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ using namespace pstl::internal;
+ const auto is_vector = is_vectorization_preferred(exec);
+
+ return pattern_walk2_brick(first, last, result, [is_vector](InputIterator begin, InputIterator end, OutputIterator res){
+ return brick_copy(begin, end, res, is_vector);
+ }, is_parallelization_preferred(exec));
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
copy_n(ExecutionPolicy&& exec, InputIterator first, Size n, OutputIterator result) {
- return __icp_algorithm::pattern_copy_n(
- first, n, result,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ using namespace pstl::internal;
+ const auto is_vector = is_vectorization_preferred(exec);
+
+ return pattern_walk2_brick_n(first, n, result, [is_vector](InputIterator begin, Size sz, OutputIterator res){
+ return brick_copy_n(begin, sz, res, is_vector);
+ }, is_parallelization_preferred(exec));
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
copy_if(ExecutionPolicy&& exec,
InputIterator first, InputIterator last,
OutputIterator result, Predicate pred) {
- return __icp_algorithm::pattern_copy_if(
+ using namespace pstl::internal;
+ return pattern_copy_if(
first, last, result, pred,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
// [alg.swap]
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
swap_ranges(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) {
- return __icp_algorithm::pattern_swap_ranges(first1, last1, first2,
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ using namespace pstl::internal;
+ return pattern_swap_ranges(first1, last1, first2,
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
// [alg.transform]
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
transform( ExecutionPolicy&& exec, InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op ) {
typedef typename iterator_traits::value_type input_type;
typedef typename iterator_traits::value_type output_type;
- return __icp_algorithm::pattern_walk2(first, last, result,
- [op]( input_type x, output_type& y ) mutable {y = op(x);},
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ using namespace pstl::internal;
+ return pattern_walk2(first, last, result,
+ [op](input_type x, output_type& y ) mutable { y = op(x);},
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
template
-__icp_algorithm::enable_if_execution_policy
+pstl::internal::enable_if_execution_policy
transform( ExecutionPolicy&& exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryOperation op ) {
typedef typename iterator_traits::value_type input1_type;
typedef typename iterator_traits::value_type input2_type;
typedef typename iterator_traits::value_type output_type;
- return __icp_algorithm::pattern_walk3(first1, last1, first2, result, [op]( input1_type x, input2_type y, output_type& z ) mutable {z = op(x,y);},
- __icp_algorithm::is_vectorization_preferred(exec),
- __icp_algorithm::is_parallelization_preferred(exec));
+ using namespace pstl::internal;
+ return pattern_walk3(first1, last1, first2, result, [op]( input1_type x, input2_type y, output_type& z ) mutable {z = op(x,y);},
+ is_vectorization_preferred(exec),
+ is_parallelization_preferred(exec));
}
// [alg.replace]
template
-__icp_algorithm::enable_if_execution_policy