1/* 2 * Copyright 2008-2013 NVIDIA Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17// Portions of this code are derived from 18// 19// Manjunath Kudlur's Carbon library 20// 21// and 22// 23// Based on Boost.Phoenix v1.2 24// Copyright (c) 2001-2002 Joel de Guzman 25 26#include <thrust/detail/config.h> 27#include <thrust/detail/functional/composite.h> 28#include <thrust/detail/functional/operators/assignment_operator.h> 29#include <thrust/functional.h> 30 31namespace thrust 32{ 33 34namespace detail 35{ 36namespace functional 37{ 38 39template<typename Eval> 40 __host__ __device__ 41 actor<Eval> 42 ::actor(void) 43 : eval_type() 44{} 45 46template<typename Eval> 47 __host__ __device__ 48 actor<Eval> 49 ::actor(const Eval &base) 50 : eval_type(base) 51{} 52 53template<typename Eval> 54 __host__ __device__ 55 typename apply_actor< 56 typename actor<Eval>::eval_type, 57 typename thrust::null_type 58 >::type 59 actor<Eval> 60 ::operator()(void) const 61{ 62 return eval_type::eval(thrust::null_type()); 63} // end basic_environment::operator() 64 65template<typename Eval> 66 template<typename T0> 67 __host__ __device__ 68 typename apply_actor< 69 typename actor<Eval>::eval_type, 70 typename thrust::tuple<T0&> 71 >::type 72 actor<Eval> 73 ::operator()(T0 &_0) const 74{ 75 return eval_type::eval(thrust::tie(_0)); 76} // end basic_environment::operator() 77 78template<typename Eval> 79 template<typename T0, typename T1> 80 __host__ __device__ 81 typename apply_actor< 82 typename actor<Eval>::eval_type, 83 typename thrust::tuple<T0&,T1&> 84 >::type 85 actor<Eval> 86 ::operator()(T0 &_0, T1 &_1) const 87{ 88 return eval_type::eval(thrust::tie(_0,_1)); 89} // end basic_environment::operator() 90 91template<typename Eval> 92 template<typename T0, typename T1, typename T2> 93 __host__ __device__ 94 typename apply_actor< 95 typename actor<Eval>::eval_type, 96 typename thrust::tuple<T0&,T1&,T2&> 97 >::type 98 actor<Eval> 99 ::operator()(T0 &_0, T1 &_1, T2 &_2) const 100{ 101 return eval_type::eval(thrust::tie(_0,_1,_2)); 102} // end basic_environment::operator() 103 104template<typename Eval> 105 template<typename T0, typename T1, typename T2, typename T3> 106 __host__ __device__ 107 typename apply_actor< 108 typename actor<Eval>::eval_type, 109 typename thrust::tuple<T0&,T1&,T2&,T3&> 110 >::type 111 actor<Eval> 112 ::operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3) const 113{ 114 return eval_type::eval(thrust::tie(_0,_1,_2,_3)); 115} // end basic_environment::operator() 116 117template<typename Eval> 118 template<typename T0, typename T1, typename T2, typename T3, typename T4> 119 __host__ __device__ 120 typename apply_actor< 121 typename actor<Eval>::eval_type, 122 typename thrust::tuple<T0&,T1&,T2&,T3&,T4&> 123 >::type 124 actor<Eval> 125 ::operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4) const 126{ 127 return eval_type::eval(thrust::tie(_0,_1,_2,_3,_4)); 128} // end basic_environment::operator() 129 130template<typename Eval> 131 template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5> 132 __host__ __device__ 133 typename apply_actor< 134 typename actor<Eval>::eval_type, 135 typename thrust::tuple<T0&,T1&,T2&,T3&,T4&,T5&> 136 >::type 137 actor<Eval> 138 ::operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4, T5 &_5) const 139{ 140 return eval_type::eval(thrust::tie(_0,_1,_2,_3,_4,_5)); 141} // end basic_environment::operator() 142 143template<typename Eval> 144 template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> 145 __host__ __device__ 146 typename apply_actor< 147 typename actor<Eval>::eval_type, 148 typename thrust::tuple<T0&,T1&,T2&,T3&,T4&,T5&,T6&> 149 >::type 150 actor<Eval> 151 ::operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4, T5 &_5, T6 &_6) const 152{ 153 return eval_type::eval(thrust::tie(_0,_1,_2,_3,_4,_5,_6)); 154} // end basic_environment::operator() 155 156template<typename Eval> 157 template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> 158 __host__ __device__ 159 typename apply_actor< 160 typename actor<Eval>::eval_type, 161 typename thrust::tuple<T0&,T1&,T2&,T3&,T4&,T5&,T6&,T7&> 162 >::type 163 actor<Eval> 164 ::operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4, T5 &_5, T6 &_6, T7 &_7) const 165{ 166 return eval_type::eval(thrust::tie(_0,_1,_2,_3,_4,_5,_6,_7)); 167} // end basic_environment::operator() 168 169template<typename Eval> 170 template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> 171 __host__ __device__ 172 typename apply_actor< 173 typename actor<Eval>::eval_type, 174 typename thrust::tuple<T0&,T1&,T2&,T3&,T4&,T5&,T6&,T7&,T8&> 175 >::type 176 actor<Eval> 177 ::operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4, T5 &_5, T6 &_6, T7 &_7, T8 &_8) const 178{ 179 return eval_type::eval(thrust::tie(_0,_1,_2,_3,_4,_5,_6,_7,_8)); 180} // end basic_environment::operator() 181 182template<typename Eval> 183 template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> 184 __host__ __device__ 185 typename apply_actor< 186 typename actor<Eval>::eval_type, 187 typename thrust::tuple<T0&,T1&,T2&,T3&,T4&,T5&,T6&,T7&,T8&,T9&> 188 >::type 189 actor<Eval> 190 ::operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4, T5 &_5, T6 &_6, T7 &_7, T8 &_8, T9 &_9) const 191{ 192 return eval_type::eval(thrust::tie(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9)); 193} // end basic_environment::operator() 194 195template<typename Eval> 196 template<typename T> 197 __host__ __device__ 198 typename assign_result<Eval,T>::type 199 actor<Eval> 200 ::operator=(const T& _1) const 201{ 202 return do_assign(*this,_1); 203} // end actor::operator=() 204 205} // end functional 206} // end detail 207} // end thrust 208