stdgpu/execution.h Source File

stdgpu/execution.h Source File#

stdgpu: stdgpu/execution.h Source File
stdgpu Latest
Efficient STL-like Data Structures on the GPU
execution.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Patrick Stotko
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef STDGPU_EXECUTION_H
17#define STDGPU_EXECUTION_H
18
24#include <type_traits>
25
26#include <stdgpu/type_traits.h>
27
32#include <thrust/execution_policy.h>
33
34namespace stdgpu
35{
36
41template <typename T>
42struct is_execution_policy : std::is_base_of<thrust::execution_policy<T>, T>
43{
44};
45
47template <typename T>
48inline constexpr bool is_execution_policy_v = is_execution_policy<T>::value;
50
51} // namespace stdgpu
52
53namespace stdgpu::execution
54{
55
60template <typename T>
61using execution_policy = thrust::execution_policy<T>;
62
67using device_policy = std::remove_const_t<decltype(thrust::device)>;
68
69static_assert(is_execution_policy_v<remove_cvref_t<device_policy>>,
70 "stdgpu::execution::device_policy: Should be an execution policy but is not");
71
76using host_policy = std::remove_const_t<decltype(thrust::host)>;
77
78static_assert(is_execution_policy_v<remove_cvref_t<host_policy>>,
79 "stdgpu::execution::host_policy: Should be an execution policy but is not");
80
86
91constexpr host_policy host;
92
93} // namespace stdgpu::execution
94
95#endif // STDGPU_EXECUTION_H
thrust::execution_policy< T > execution_policy
The base execution policy class from which all policies are derived and custom ones must be derived.
Definition: execution.h:61
std::remove_const_t< decltype(thrust::host)> host_policy
The host execution policy class.
Definition: execution.h:76
constexpr device_policy device
The device execution policy.
Definition: execution.h:85
constexpr host_policy host
The host execution policy.
Definition: execution.h:91
std::remove_const_t< decltype(thrust::device)> device_policy
The device execution policy class.
Definition: execution.h:67
Type trait to check whether the provided class is an execution policy.
Definition: execution.h:43