Discontinuous Galerkin Library
#include "dg/algorithm.h"
tensor_traits_thrust.h
Go to the documentation of this file.
1#pragma once
2
3#include <thrust/host_vector.h>
4#include <thrust/device_vector.h>
5#include "vector_categories.h"
6#include "tensor_traits.h"
7
8namespace dg
9{
12
14template<class T>
15struct TensorTraits<thrust::host_vector<T>> //, std::enable_if_t< std::is_arithmetic<T>::value>>
16{
17 using value_type = T;
20};
23//template<class T>
24//struct TensorTraits<thrust::host_vector<T>,
25// std::enable_if_t< !std::is_arithmetic<T>::value>>
26//{
27// using value_type = get_value_type<T>;
28// using tensor_category = RecursiveVectorTag;
29// using execution_policy = get_execution_policy<T>;
30//};
31
33template<class T>
34struct TensorTraits<thrust::device_vector<T> >
35{
36 using value_type = T;
38#if THRUST_DEVICE_SYSTEM==THRUST_DEVICE_SYSTEM_CUDA
40#elif THRUST_DEVICE_SYSTEM==THRUST_DEVICE_SYSTEM_OMP
41 using execution_policy = OmpTag ;
42#else
44#endif
45};
48//thrust::cpp is an alias for thrust::system::cpp
49//tag is a class deriving from thrust::execution_policy<tag>
50//raw pointers have the std::random_access_iterator_tag as iterator_category in thrust
51template<class Tag>
52struct ThrustTag { };
53template <>
54struct ThrustTag<SerialTag>
55{
56 using thrust_tag = thrust::cpp::tag;
57};
58#if THRUST_DEVICE_SYSTEM==THRUST_DEVICE_SYSTEM_CUDA
59template <>
60struct ThrustTag<CudaTag>
61{
62 using thrust_tag = thrust::cuda::tag;
63};
64#elif THRUST_DEVICE_SYSTEM==THRUST_DEVICE_SYSTEM_OMP
65template <>
66struct ThrustTag<OmpTag>
67{
68 using thrust_tag = thrust::omp::tag;
69};
70#endif
71template<class Vector>
72using get_thrust_tag = typename ThrustTag<get_execution_policy<Vector>>::thrust_tag;
73
75} //namespace dg
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
CUDA implementation.
Definition: execution_policy.h:27
OpenMP parallel execution.
Definition: execution_policy.h:28
Indicate sequential execution.
Definition: execution_policy.h:26
T value_type
Definition: tensor_traits_thrust.h:36
T value_type
Definition: tensor_traits_thrust.h:17
The vector traits.
Definition: tensor_traits.h:31
Indicate thrust/std - like behaviour.
Definition: vector_categories.h:88