Go to the documentation of this file.
20 #ifndef TILEDARRAY_DIST_EVAL_BINARY_EVAL_H__INCLUDED
21 #define TILEDARRAY_DIST_EVAL_BINARY_EVAL_H__INCLUDED
39 template <
typename Left,
typename Right,
typename Op,
typename Policy>
41 public std::enable_shared_from_this<
42 BinaryEvalImpl<Left, Right, Op, Policy>> {
64 using std::enable_shared_from_this<BinaryEvalImpl_>::shared_from_this;
82 template <
typename Perm,
typename = std::enable_if_t<
83 TiledArray::detail::is_permutation_v<Perm>>>
86 const std::shared_ptr<pmap_interface>&
pmap,
const Perm& perm,
92 TA_ASSERT(left.trange() == right.trange());
108 const ProcessID source =
109 left_.owner(source_index);
126 #ifdef TILEDARRAY_HAS_CUDA
127 template <
typename L,
typename R,
typename U = value_type>
131 std::enable_if_t<!detail::is_cuda_tile_v<U>,
void> eval_tile(
139 template <
typename L,
typename R,
typename U = value_type>
140 std::enable_if_t<detail::is_cuda_tile_v<U>,
void> eval_tile(
148 template <
typename L,
typename R>
163 virtual int internal_eval() {
169 typedef typename std::conditional<
170 op_type::left_is_consumable,
typename left_type::value_type,
171 const typename left_type::value_type>::type& left_argument_type;
172 typedef typename std::conditional<
173 op_type::right_is_consumable,
typename right_type::value_type,
174 const typename right_type::value_type>::type& right_argument_type;
179 TA_ASSERT(left_.pmap() == right_.pmap());
180 std::shared_ptr<BinaryEvalImpl_>
self = shared_from_this();
181 typename pmap_interface::const_iterator it = left_.pmap()->begin();
182 const typename pmap_interface::const_iterator
end = left_.pmap()->end();
186 for (; it !=
end; ++it) {
188 const auto source_index = *it;
189 const auto target_index =
195 &BinaryEvalImpl_::template eval_tile<left_argument_type,
196 right_argument_type>,
197 target_index, left_.get(source_index), right_.get(source_index));
203 for (; it !=
end; ++it) {
205 const auto index = *it;
210 if (left_.is_zero(index)) {
213 &BinaryEvalImpl_::template eval_tile<
const ZeroTensor,
214 right_argument_type>,
215 target_index, ZeroTensor(), right_.get(index));
216 }
else if (right_.is_zero(index)) {
219 &BinaryEvalImpl_::template eval_tile<left_argument_type,
221 target_index, left_.get(index), ZeroTensor());
225 &BinaryEvalImpl_::template eval_tile<left_argument_type,
226 right_argument_type>,
227 target_index, left_.get(index), right_.get(index));
233 if (!left_.is_zero(index)) left_.discard(index);
234 if (!right_.is_zero(index)) right_.discard(index);
251 #endif // TILEDARRAY_DIST_EVAL_BINARY_EVAL_H__INCLUDED
BinaryEvalImpl(const left_type &left, const right_type &right, World &world, const trange_type &trange, const shape_type &shape, const std::shared_ptr< pmap_interface > &pmap, const Perm &perm, const op_type &op)
Construct a binary evaluator.
World & world() const
World accessor.
DistEvalImpl_::shape_type shape_type
Shape type.
BinaryEvalImpl< Left, Right, Op, Policy > BinaryEvalImpl_
This object type.
bool is_zero(const Index &i) const
Query for a zero tile.
ordinal_type perm_index_to_target(ordinal_type index) const
Permute index from a source index to a target index.
bool is_dense() const
Query the density of the tensor.
Left left_type
The left-hand argument type.
DistEvalImpl_::TensorImpl_ TensorImpl_
The base, base class type.
void set_tile(ordinal_type i, const value_type &value)
Set tensor value.
eval_trait< value_type >::type eval_type
Tile evaluation type.
const std::shared_ptr< pmap_interface > & pmap() const
Tensor process map accessor.
DistEvalImpl_::pmap_interface pmap_interface
Process map interface type.
Distributed evaluator implementation object.
constexpr auto end(Eigen::Matrix< _Scalar, _Rows, 1, _Options, _MaxRows, 1 > &m)
auto outer(const Permutation &p)
DistEvalImpl_::value_type value_type
Tile type.
DistEvalImpl_::range_type range_type
Range type.
DistEvalImpl< typename Op::result_type, Policy > DistEvalImpl_
The base class type.
DistEvalImpl_::ordinal_type ordinal_type
Ordinal type.
Op op_type
Tile evaluation operator type.
Tensor implementation and base for other tensor implementation objects.
#define TA_ASSERT(EXPR,...)
DistEvalImpl_::eval_type eval_type
Tile evaluation type.
ordinal_type perm_index_to_source(ordinal_type index) const
Permute index from a target index to a source index.
DistEvalImpl_::trange_type trange_type
Tiled range type.
virtual void discard_tile(ordinal_type i) const
Discard a tile that is not needed.
TensorImpl_::ordinal_type ordinal_type
Ordinal type.
TensorImpl_::range_type range_type
Range type this tensor.
TensorImpl_::shape_type shape_type
Shape type.
virtual ~BinaryEvalImpl()
TensorImpl_::pmap_interface pmap_interface
process map interface type
Binary, distributed tensor evaluator.
const trange_type & trange() const
Tiled range accessor.
Right right_type
The right-hand argument type.
const shape_type & shape() const
Tensor shape accessor.
const madness::uniqueidT & id() const
Unique object id accessor.
virtual Future< value_type > get_tile(ordinal_type i) const
Get tile at index i.
TensorImpl_::trange_type trange_type
Tiled range type for this object.
An N-dimensional shallow copy wrapper for tile objects.
bool is_local(const Index &i) const
Query for a locally owned tile.