20 #ifndef TILEDARRAY_DIST_EVAL_DIST_EVAL_BASE_H__INCLUDED 21 #define TILEDARRAY_DIST_EVAL_DIST_EVAL_BASE_H__INCLUDED 39 template <
typename Tile,
typename Policy>
55 madness::uniqueidT id_;
65 volatile int task_count_;
66 madness::AtomicInt set_counter_;
77 return (source_to_target_ ? source_to_target_(index) : index);
86 return (target_to_source_ ? target_to_source_(index) : index);
103 id_(
world.unique_obj_id()),
114 source_to_target_ =
PermIndex(source_range, perm);
125 const madness::uniqueidT&
id()
const {
return id_; }
148 madness::DistributedID
id(id_, i);
163 madness::DistributedID
id(id_, i);
167 f.register_callback(
this);
171 virtual void notify() { set_counter_++; }
175 const int task_count = task_count_;
177 auto report_and_abort = [&,
this](
const char* type,
const char* what =
nullptr) {
178 std::stringstream ss;
179 ss <<
"!! ERROR TiledArray: Aborting due to " << type <<
" exception.\n" 180 << (what !=
nullptr ?
"!! ERROR TiledArray: " :
"")
181 << (what !=
nullptr ? what :
"")
182 << (what !=
nullptr ?
"\n" :
"")
184 <<
" id=" << id_ <<
" " << set_counter_ <<
" of " << task_count <<
" tiles set" << std::endl;
185 std::cerr << ss.str().c_str();
190 {
return this->set_counter_ == task_count; });
192 report_and_abort(
"TiledArray", e.
what());
193 }
catch(madness::MadnessException& e) {
194 report_and_abort(
"MADNESS", e.what());
195 }
catch(SafeMPI::Exception& e) {
196 report_and_abort(
"SafeMPI", e.what());
197 }
catch(std::exception& e) {
198 report_and_abort(
"std", e.what());
200 report_and_abort(
"",
nullptr);
214 virtual int internal_eval() = 0;
226 task_count_ = this->internal_eval();
240 template <
typename Tile,
typename Policy>
255 std::shared_ptr<impl_type> pimpl_;
261 template <
typename Impl>
280 pimpl_ = other.pimpl_;
288 void eval() {
return pimpl_->eval(); }
322 const std::shared_ptr<pmap_interface>&
pmap()
const {
return pimpl_->pmap(); }
327 bool is_dense()
const {
return pimpl_->is_dense(); }
356 World&
world()
const {
return pimpl_->world(); }
361 madness::uniqueidT
id()
const {
return pimpl_->id(); }
364 void wait()
const { pimpl_->wait(); }
371 #endif // TILEDARRAY_DIST_EVAL_DIST_EVAL_BASE_H__INCLUDED TensorImpl_::size_type size_type
Size type.
const std::shared_ptr< pmap_interface > & pmap() const
Tensor process map accessor.
bool is_zero(size_type i) const
Query for a zero tile.
void eval()
Evaluate this tensor expression object.
A functor that permutes ordinal indices.
DistEvalImpl< Tile, Policy > impl_type
Implementation base class type.
impl_type::value_type value_type
Tile type.
ProcessID owner(size_type i) const
Query a tile owner.
const shape_type & shape() const
Tensor shape accessor.
const trange_type & trange() const
Tiled range accessor.
Policy::range_type range_type
Element/tile range type.
World & world() const
World object accessor.
Policy::pmap_interface pmap_interface
Process map interface type.
DistEval< Tile, Policy > DistEval_
This class type.
void wait() const
Wait for all tiles to be assigned.
virtual Future< value_type > get_tile(size_type i) const =0
Get tile at index i.
DistEval(const DistEval_ &other)
Copy constructor.
Distributed evaluator implementation object.
DistEval_ & operator=(const DistEval_ &other)
Assignment operator.
TiledArray::detail::TensorImpl< Policy > TensorImpl_
Tensor implementation base class.
TensorImpl_::pmap_interface pmap_interface
process map interface type
void set_tile(size_type i, Future< value_type > f)
Set tensor value with a future.
Tensor implementation and base for other tensor implementation objects.
void eval()
Evaluate this tensor object with the given result variable list.
void set_tile(size_type i, const value_type &value)
Set tensor value.
madness::uniqueidT id() const
Unique object id.
impl_type::trange_type trange_type
Tiled range type for this object.
Tile value_type
Tile type.
const range_type & range() const
Tensor tile size array accessor.
TensorImpl_::trange_type trange_type
Tiled range type for this object.
Policy::trange_type trange_type
Tiled range type.
size_type perm_index_to_target(size_type index) const
Permute index from a source index to a target index.
bool is_local(size_type i) const
Query for a locally owned tile.
impl_type::range_type range_type
Range type this tensor.
impl_type::pmap_interface pmap_interface
Process map interface type.
virtual const char * what() const TILEDARRAY_NO_EXCEPTION
Lazy tile for on-the-fly evaluation of array tiles.
TensorImpl_::shape_type shape_type
Shape type.
Tensor expression object.
ProcessID owner(const Index &i) const
Query a tile owner.
const madness::uniqueidT & id() const
Unique object id accessor.
size_type size() const
Tensor tile volume accessor.
impl_type::eval_type eval_type
Tile evaluation type.
const shape_type & shape() const
Tensor shape accessor.
Policy::size_type size_type
Size type.
bool is_dense() const
Query the density of the tensor.
impl_type::size_type size_type
Size type.
TensorImpl_::range_type range_type
Range type this tensor.
void wait() const
Wait for all local tiles to be evaluated.
eval_trait< value_type >::type eval_type
Tile evaluation type.
virtual void discard_tile(size_type i) const =0
Discard a tile that is not needed.
Permutation of a sequence of objects indexed by base-0 indices.
DistEval(const std::shared_ptr< Impl > &pimpl)
Constructor.
DistEvalImpl(World &world, const trange_type &trange, const shape_type &shape, const std::shared_ptr< pmap_interface > &pmap, const Permutation &perm)
Constructor.
const trange_type & trange() const
Tiled range accessor.
World & world() const
World accessor.
virtual void discard(size_type i) const
Discard a tile that is not needed.
impl_type::shape_type shape_type
Tensor shape type.
const range_type & tiles_range() const
Tiles range accessor.
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.
Future< value_type > future
Future of tile type.
An N-dimensional shallow copy wrapper for tile objects.
virtual void notify()
Tile set notification.
DistEvalImpl< Tile, Policy > DistEvalImpl_
This object type.
Policy::shape_type shape_type
Tensor shape type.