Lines 93-98
Link Here
|
93 |
}; |
93 |
}; |
94 |
|
94 |
|
95 |
// Standard reduction functors |
95 |
// Standard reduction functors |
|
|
96 |
#if 0 |
96 |
template <typename T> struct SumReducer |
97 |
template <typename T> struct SumReducer |
97 |
{ |
98 |
{ |
98 |
static const bool PacketAccess = packet_traits<T>::HasAdd; |
99 |
static const bool PacketAccess = packet_traits<T>::HasAdd; |
Lines 136-142
Link Here
|
136 |
PacketAccess = PacketType<T, Device>::HasAdd |
137 |
PacketAccess = PacketType<T, Device>::HasAdd |
137 |
}; |
138 |
}; |
138 |
}; |
139 |
}; |
|
|
140 |
#else |
139 |
|
141 |
|
|
|
142 |
template <typename T> struct NeumaierSumReducer |
143 |
{ |
144 |
static const bool PacketAccess = false; //packet_traits<T>::HasAdd; |
145 |
static const bool IsStateful = true; |
146 |
|
147 |
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE |
148 |
NeumaierSumReducer() : compensation_(0) { } |
149 |
|
150 |
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void reduce(const T t, T* accum) { |
151 |
internal::scalar_sum_op<T> sum_op; |
152 |
internal::scalar_difference_op<T> diff_op; |
153 |
internal::scalar_abs_op<T> abs_op; |
154 |
T tempSum_ = sum_op(*accum, t); |
155 |
if (abs_op(*accum) >= abs_op(t)) { |
156 |
compensation_ += sum_op(diff_op(*accum, tempSum_), t); |
157 |
} else { |
158 |
compensation_ += sum_op(diff_op(t, tempSum_), *accum); |
159 |
} |
160 |
*accum = tempSum_; |
161 |
} |
162 |
//template <typename Packet> |
163 |
//EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void reducePacket(const Packet& p, Packet* accum) { |
164 |
//Packet tempSum_ = padd<Packet>(*accum, p); |
165 |
//if (pabs<Packet>(*accum) >= pabs<Packet>(p)) { |
166 |
//compensation_ += predux(padd<Packet>(psub<Packet>(*accum, tempSum_), p)); |
167 |
//} else { |
168 |
//compensation_ += predux(padd<Packet>(psub<Packet>(p, tempSum_), *accum)); |
169 |
//} |
170 |
//(*accum) = tempSum_; |
171 |
//} |
172 |
|
173 |
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T initialize() const { |
174 |
internal::scalar_cast_op<int, T> conv; |
175 |
return conv(0); |
176 |
} |
177 |
//template <typename Packet> |
178 |
//EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet initializePacket() const { |
179 |
//return pset1<Packet>(initialize()); |
180 |
//} |
181 |
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T finalize(const T accum) const { |
182 |
return accum + compensation_; |
183 |
} |
184 |
//template <typename Packet> |
185 |
//EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet finalizePacket(const Packet& vaccum) const { |
186 |
//return vaccum; |
187 |
//} |
188 |
//template <typename Packet> |
189 |
//EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T finalizeBoth(const T saccum, const Packet& vaccum) const { |
190 |
//internal::scalar_sum_op<T> sum_op; |
191 |
//return sum_op(sum_op(saccum, predux(vaccum)), compensation_); |
192 |
//} |
193 |
|
194 |
protected: |
195 |
T compensation_; |
196 |
}; |
197 |
|
198 |
#define SumReducer NeumaierSumReducer |
199 |
|
200 |
template <typename T, typename Device> |
201 |
struct reducer_traits<NeumaierSumReducer<T>, Device> { |
202 |
enum { |
203 |
Cost = 4 * NumTraits<T>::AddCost, |
204 |
PacketAccess = false//PacketType<T, Device>::HasAdd |
205 |
}; |
206 |
}; |
207 |
|
208 |
#endif |
140 |
|
209 |
|
141 |
template <typename T> struct MeanReducer |
210 |
template <typename T> struct MeanReducer |
142 |
{ |
211 |
{ |