20 #ifndef TILEDARRAY_DIST_EVAL_BINARY_EVAL_H__INCLUDED 21 #define TILEDARRAY_DIST_EVAL_BINARY_EVAL_H__INCLUDED 37 template <
typename Left,
typename Right,
typename Op,
typename Policy>
40 public std::enable_shared_from_this<BinaryEvalImpl<Left, Right, Op, Policy> >
57 using std::enable_shared_from_this<BinaryEvalImpl_>::shared_from_this;
82 left_(left), right_(right), op_(op)
84 TA_ASSERT(left.trange() == right.trange());
101 const ProcessID source = left_.owner(source_index);
122 template <
typename L,
typename R>
123 void eval_tile(
const size_type i, L left, R right) {
134 virtual int internal_eval() {
141 typedef typename std::conditional<op_type::left_is_consumable,
142 typename left_type::value_type,
143 const typename left_type::value_type>::type &
145 typedef typename std::conditional<op_type::right_is_consumable,
146 typename right_type::value_type,
147 const typename right_type::value_type>::type &
153 TA_ASSERT(left_.pmap() == right_.pmap());
154 std::shared_ptr<BinaryEvalImpl_>
self = shared_from_this();
155 typename pmap_interface::const_iterator it = left_.pmap()->begin();
156 const typename pmap_interface::const_iterator end = left_.pmap()->end();
160 for(; it != end; ++it) {
167 & BinaryEvalImpl_::template eval_tile<left_argument_type, right_argument_type>,
168 target_index, left_.get(source_index), right_.get(source_index));
174 for(; it != end; ++it) {
181 if(left_.is_zero(index)) {
183 & BinaryEvalImpl_::template eval_tile<const ZeroTensor, right_argument_type>,
184 target_index, ZeroTensor(), right_.get(index));
185 }
else if(right_.is_zero(index)) {
187 & BinaryEvalImpl_::template eval_tile<left_argument_type, const ZeroTensor>,
188 target_index, left_.get(index), ZeroTensor());
191 & BinaryEvalImpl_::template eval_tile<left_argument_type, right_argument_type>,
192 target_index, left_.get(index), right_.get(index));
198 if(! left_.is_zero(index))
199 left_.discard(index);
200 if(! right_.is_zero(index))
201 right_.discard(index);
218 #endif // TILEDARRAY_DIST_EVAL_BINARY_EVAL_H__INCLUDED DistEvalImpl_::size_type size_type
Size type.
TensorImpl_::size_type size_type
Size type.
DistEvalImpl_::shape_type shape_type
Shape type.
const shape_type & shape() const
Tensor shape accessor.
const trange_type & trange() const
Tiled range accessor.
bool is_dense() const
Query the density of the tensor.
Distributed evaluator implementation object.
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 Permutation &perm, const op_type &op)
Construct a binary evaluator.
TensorImpl_::pmap_interface pmap_interface
process map interface type
Tensor implementation and base for other tensor implementation objects.
DistEvalImpl_::TensorImpl_ TensorImpl_
The base, base class type.
void set_tile(size_type i, const value_type &value)
Set tensor value.
TensorImpl_::trange_type trange_type
Tiled range type for this object.
Right right_type
The right-hand argument type.
size_type perm_index_to_target(size_type index) const
Permute index from a source index to a target index.
virtual ~BinaryEvalImpl()
BinaryEvalImpl< Left, Right, Op, Policy > BinaryEvalImpl_
This object type.
TensorImpl_::shape_type shape_type
Shape type.
bool is_local(const Index &i) const
Query for a locally owned tile.
Op op_type
Tile evaluation operator type.
const madness::uniqueidT & id() const
Unique object id accessor.
bool is_zero(const Index &i) const
Query for a zero tile.
Left left_type
The left-hand argument type.
TensorImpl_::range_type range_type
Range type this tensor.
DistEvalImpl_::range_type range_type
Range type.
eval_trait< value_type >::type eval_type
Tile evaluation type.
Permutation of a sequence of objects indexed by base-0 indices.
DistEvalImpl_::pmap_interface pmap_interface
Process map interface type.
Binary, distributed tensor evaluator.
DistEvalImpl< typename Op::result_type, Policy > DistEvalImpl_
The base class type.
World & world() const
World accessor.
DistEvalImpl_::eval_type eval_type
Tile evaluation type.
virtual void discard_tile(size_type i) const
Discard a tile that is not needed.
DistEvalImpl_::value_type value_type
Tile type.
size_type perm_index_to_source(size_type index) const
Permute index from a target index to a source index.
const std::shared_ptr< pmap_interface > & pmap() const
Tensor process map accessor.
DistEvalImpl_::trange_type trange_type
Tiled range type.
An N-dimensional shallow copy wrapper for tile objects.
virtual Future< value_type > get_tile(size_type i) const
Get tile at index i.