Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move execution policies, algorithm, numeric, memory details to internal headers #9

Merged
merged 6 commits into from May 15, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
901 changes: 1 addition & 900 deletions include/pstl/algorithm

Large diffs are not rendered by default.

103 changes: 4 additions & 99 deletions include/pstl/execution
Expand Up @@ -21,111 +21,16 @@
#ifndef __PSTL_execution_policy
#define __PSTL_execution_policy

#include <type_traits>
#include "internal/pstl_config.h"
#include "internal/execution_defs.h"

namespace pstl {
namespace execution {
inline namespace v1 {

// 2.4, Sequential execution policy
class sequenced_policy {
public:
// For internal use only
static constexpr std::false_type __allow_unsequenced() {return std::false_type{};}
static constexpr std::false_type __allow_vector() {return std::false_type{};}
static constexpr std::false_type __allow_parallel() {return std::false_type{};}
};

#if __PSTL_USE_PAR_POLICIES
// 2.5, Parallel execution policy
class parallel_policy {
public:
// For internal use only
static constexpr std::false_type __allow_unsequenced() {return std::false_type{};}
static constexpr std::false_type __allow_vector() {return std::false_type{};}
static constexpr std::true_type __allow_parallel() {return std::true_type{};}
};

// 2.6, Parallel+Vector execution policy
class parallel_unsequenced_policy {
public:
// For internal use only
static constexpr std::true_type __allow_unsequenced() {return std::true_type{};}
static constexpr std::true_type __allow_vector() {return std::true_type{};}
static constexpr std::true_type __allow_parallel() {return std::true_type{};}
};
#endif

class unsequenced_policy {
public:
// For internal use only
static constexpr std::true_type __allow_unsequenced() {return std::true_type{};}
static constexpr std::true_type __allow_vector() {return std::true_type{};}
static constexpr std::false_type __allow_parallel() {return std::false_type{};}
};


// 2.8, Execution policy objects
constexpr sequenced_policy seq{};
#if __PSTL_USE_PAR_POLICIES
constexpr parallel_policy par{};
constexpr parallel_unsequenced_policy par_unseq{};
#endif
constexpr unsequenced_policy unseq{};

// 2.3, Execution policy type trait
template<class T> struct is_execution_policy: std::false_type {};

template<> struct is_execution_policy<sequenced_policy >: std::true_type {};
#if __PSTL_USE_PAR_POLICIES
template<> struct is_execution_policy<parallel_policy >: std::true_type {};
template<> struct is_execution_policy<parallel_unsequenced_policy>: std::true_type {};
#endif
template<> struct is_execution_policy<unsequenced_policy >: std::true_type {};

#if __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
template<class T> constexpr bool is_execution_policy_v = is_execution_policy<T>::value;
#endif

} //namespace v1
} //namespace execution
} //namespace pstl
// Algorithm implementation
#include "internal/glue_algorithm_impl.h"

#if __PSTL_CPP17_EXECUTION_POLICIES_PRESENT
__PSTL_PRAGMA_MESSAGE_POLICIES("The <Parallel STL> execution policies are defined in the namespace pstl::execution")
#else
namespace std {
// Type trait
using pstl::execution::is_execution_policy;
#if __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
#if __INTEL_COMPILER
template<class T> constexpr bool is_execution_policy_v = is_execution_policy<T>::value;
#else
using pstl::execution::is_execution_policy_v;
#endif
#endif

namespace execution {
// Standard C++ policy classes
using pstl::execution::sequenced_policy;
#if __PSTL_USE_PAR_POLICIES
using pstl::execution::parallel_policy;
using pstl::execution::parallel_unsequenced_policy;
#endif
// Standard predefined policy instances
using pstl::execution::seq;
#if __PSTL_USE_PAR_POLICIES
using pstl::execution::par;
using pstl::execution::par_unseq;
#endif
// Implementation-defined names
// Unsequenced policy is not yet standard, but for consistency
// we include it into namespace std::execution as well
using pstl::execution::unseq;
using pstl::execution::unsequenced_policy;
}
}
#include "internal/glue_execution_defs.h"
__PSTL_PRAGMA_MESSAGE_POLICIES("The <Parallel STL> execution policies are injected into the standard namespace std::execution")
#endif

Expand Down
99 changes: 99 additions & 0 deletions include/pstl/internal/execution_defs.h
@@ -0,0 +1,99 @@

/*
Copyright (c) 2017-2018 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_execution_policy_defs_H
#define __PSTL_execution_policy_defs_H

#include <type_traits>

namespace pstl {
namespace execution {
inline namespace v1 {

// 2.4, Sequential execution policy
class sequenced_policy {
public:
// For internal use only
static constexpr std::false_type __allow_unsequenced() {return std::false_type{};}
static constexpr std::false_type __allow_vector() {return std::false_type{};}
static constexpr std::false_type __allow_parallel() {return std::false_type{};}
};

#if __PSTL_USE_PAR_POLICIES
// 2.5, Parallel execution policy
class parallel_policy {
public:
// For internal use only
static constexpr std::false_type __allow_unsequenced() {return std::false_type{};}
static constexpr std::false_type __allow_vector() {return std::false_type{};}
static constexpr std::true_type __allow_parallel() {return std::true_type{};}
};

// 2.6, Parallel+Vector execution policy
class parallel_unsequenced_policy {
public:
// For internal use only
static constexpr std::true_type __allow_unsequenced() {return std::true_type{};}
static constexpr std::true_type __allow_vector() {return std::true_type{};}
static constexpr std::true_type __allow_parallel() {return std::true_type{};}
};
#endif

class unsequenced_policy {
public:
// For internal use only
static constexpr std::true_type __allow_unsequenced() {return std::true_type{};}
static constexpr std::true_type __allow_vector() {return std::true_type{};}
static constexpr std::false_type __allow_parallel() {return std::false_type{};}
};


// 2.8, Execution policy objects
constexpr sequenced_policy seq{};
#if __PSTL_USE_PAR_POLICIES
constexpr parallel_policy par{};
constexpr parallel_unsequenced_policy par_unseq{};
#endif
constexpr unsequenced_policy unseq{};

// 2.3, Execution policy type trait
template<class T> struct is_execution_policy: std::false_type {};

template<> struct is_execution_policy<sequenced_policy >: std::true_type {};
#if __PSTL_USE_PAR_POLICIES
template<> struct is_execution_policy<parallel_policy >: std::true_type {};
template<> struct is_execution_policy<parallel_unsequenced_policy>: std::true_type {};
#endif
template<> struct is_execution_policy<unsequenced_policy >: std::true_type {};

#if __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
template<class T> constexpr bool is_execution_policy_v = is_execution_policy<T>::value;
#endif

} //namespace v1
} //namespace execution

namespace internal {
template<class ExecPolicy, class T> using enable_if_execution_policy = typename std::enable_if<
pstl::execution::is_execution_policy<typename std::decay<ExecPolicy>::type>::value, T>::type;
} // namespace internal
} //namespace pstl
#endif /* __PSTL_execution_policy_defs_H */
4 changes: 3 additions & 1 deletion include/pstl/internal/execution_impl.h
Expand Up @@ -24,7 +24,7 @@
#include <iterator>
#include <type_traits>

#include "../execution"
#include "execution_defs.h"

namespace pstl {
namespace internal {
Expand Down Expand Up @@ -96,8 +96,10 @@ struct policy_traits<parallel_unsequenced_policy> {
};
#endif

/*
template<class ExecPolicy, class T> using enable_if_execution_policy = typename std::enable_if<
is_execution_policy<typename std::decay<ExecPolicy>::type>::value, T>::type;
*/

template<typename ExecutionPolicy> using collector_t =
typename policy_traits<typename std::decay<ExecutionPolicy>::type>::collector_type;
Expand Down