34
template<typename Tag>
35
namespace select_system_detail
39
// min_system case 1: both systems have the same type, just return the first one
40
template<typename System>
42
System &min_system(thrust::execution_policy<System> &system1,
43
thrust::execution_policy<System> &)
45
return thrust::detail::derived_cast(system1);
49
// min_system case 2: systems have differing type and the first type is considered the minimum
50
template<typename System1, typename System2>
52
typename thrust::detail::enable_if<
53
thrust::detail::is_same<
55
typename thrust::detail::minimum_system<System1,System2>::type
59
min_system(thrust::execution_policy<System1> &system1, thrust::execution_policy<System2> &)
61
return thrust::detail::derived_cast(system1);
65
// min_system case 3: systems have differing type and the second type is considered the minimum
66
template<typename System1, typename System2>
68
typename thrust::detail::enable_if<
69
thrust::detail::is_same<
71
typename thrust::detail::minimum_system<System1,System2>::type
75
min_system(thrust::execution_policy<System1> &, thrust::execution_policy<System2> &system2)
77
return thrust::detail::derived_cast(system2);
81
} // end select_system_detail
84
template<typename System>
35
85
__host__ __device__
36
86
typename thrust::detail::disable_if<
37
select_system1_exists<Tag>::value,
43
} // end select_system()
45
template<typename Tag1, typename Tag2>
47
typename thrust::detail::lazy_disable_if<
48
select_system2_exists<Tag1,Tag2>::value,
49
thrust::detail::minimum_system<Tag1,Tag2>
51
select_system(Tag1, Tag2)
53
// for now, return minimum_system
54
return typename thrust::detail::minimum_system<Tag1,Tag2>::type();
55
} // end select_system()
57
template<typename Tag1, typename Tag2, typename Tag3>
59
typename thrust::detail::lazy_disable_if<
60
select_system3_exists<Tag1,Tag2,Tag3>::value,
61
thrust::detail::minimum_system<Tag1,Tag2,Tag3>
63
select_system(Tag1, Tag2, Tag3)
65
// for now, return minimum_system
66
return typename thrust::detail::minimum_system<Tag1,Tag2,Tag3>::type();
67
} // end select_system()
69
template<typename Tag1, typename Tag2, typename Tag3, typename Tag4>
71
typename thrust::detail::lazy_disable_if<
72
select_system4_exists<Tag1,Tag2,Tag3,Tag4>::value,
73
thrust::detail::minimum_system<Tag1,Tag2,Tag3,Tag4>
75
select_system(Tag1, Tag2, Tag3, Tag4)
77
// for now, return minimum_system
78
return typename thrust::detail::minimum_system<Tag1,Tag2,Tag3,Tag4>::type();
79
} // end select_system()
87
select_system1_exists<System>::value,
90
select_system(thrust::execution_policy<System> &system)
92
return thrust::detail::derived_cast(system);
93
} // end select_system()
96
template<typename System1, typename System2>
98
typename thrust::detail::enable_if_defined<
99
thrust::detail::minimum_system<System1,System2>
101
&select_system(thrust::execution_policy<System1> &system1,
102
thrust::execution_policy<System2> &system2)
104
return select_system_detail::min_system(system1,system2);
105
} // end select_system()
108
template<typename System1, typename System2, typename System3>
110
typename thrust::detail::lazy_disable_if<
111
select_system3_exists<System1,System2,System3>::value,
112
thrust::detail::minimum_system<System1,System2,System3>
114
&select_system(thrust::execution_policy<System1> &system1,
115
thrust::execution_policy<System2> &system2,
116
thrust::execution_policy<System3> &system3)
118
return select_system(select_system(system1,system2), system3);
119
} // end select_system()
122
template<typename System1, typename System2, typename System3, typename System4>
124
typename thrust::detail::lazy_disable_if<
125
select_system4_exists<System1,System2,System3,System4>::value,
126
thrust::detail::minimum_system<System1,System2,System3,System4>
128
&select_system(thrust::execution_policy<System1> &system1,
129
thrust::execution_policy<System2> &system2,
130
thrust::execution_policy<System3> &system3,
131
thrust::execution_policy<System4> &system4)
133
return select_system(select_system(system1,system2,system3), system4);
134
} // end select_system()
137
template<typename System1, typename System2, typename System3, typename System4, typename System5>
139
typename thrust::detail::lazy_disable_if<
140
select_system5_exists<System1,System2,System3,System4,System5>::value,
141
thrust::detail::minimum_system<System1,System2,System3,System4,System5>
143
&select_system(thrust::execution_policy<System1> &system1,
144
thrust::execution_policy<System2> &system2,
145
thrust::execution_policy<System3> &system3,
146
thrust::execution_policy<System4> &system4,
147
thrust::execution_policy<System5> &system5)
149
return select_system(select_system(system1,system2,system3,system4), system5);
150
} // end select_system()
153
template<typename System1, typename System2, typename System3, typename System4, typename System5, typename System6>
155
typename thrust::detail::lazy_disable_if<
156
select_system6_exists<System1,System2,System3,System4,System5,System6>::value,
157
thrust::detail::minimum_system<System1,System2,System3,System4,System5,System6>
159
&select_system(thrust::execution_policy<System1> &system1,
160
thrust::execution_policy<System2> &system2,
161
thrust::execution_policy<System3> &system3,
162
thrust::execution_policy<System4> &system4,
163
thrust::execution_policy<System5> &system5,
164
thrust::execution_policy<System6> &system6)
166
return select_system(select_system(system1,system2,system3,system4,system5), system6);
167
} // end select_system()
81
170
// map a single any_system_tag to device_system_tag
82
171
inline __host__ __device__