Go to the documentation of this file.
20 #ifndef TILEDARRAY_DIST_EVAL_DIST_EVAL_BASE_H__INCLUDED
21 #define TILEDARRAY_DIST_EVAL_DIST_EVAL_BASE_H__INCLUDED
23 #include <TiledArray/config.h>
28 #ifdef TILEDARRAY_HAS_CUDA
44 template <
typename Tile,
typename Policy>
46 public madness::CallbackInterface {
65 madness::uniqueidT id_;
77 volatile int task_count_;
78 madness::AtomicInt set_counter_;
87 return (source_to_target_ ? source_to_target_(index) : index);
96 return (target_to_source_ ? target_to_source_(index) : index);
110 const std::shared_ptr<pmap_interface>&
pmap,
113 id_(
world.unique_obj_id()),
123 source_to_target_ =
PermIndex(source_range, perm);
133 const madness::uniqueidT&
id()
const {
return id_; }
156 madness::DistributedID
id(id_, i);
171 madness::DistributedID
id(id_, i);
175 f.register_callback(
this);
179 virtual void notify() { set_counter_++; }
183 const int task_count = task_count_;
184 if (task_count > 0) {
185 auto report_and_abort = [&,
this](
const char* type,
186 const char* what =
nullptr) {
187 std::stringstream ss;
188 ss <<
"!! ERROR TiledArray: Aborting due to " << type <<
" exception.\n"
189 << (what !=
nullptr ?
"!! ERROR TiledArray: " :
"")
190 << (what !=
nullptr ? what :
"") << (what !=
nullptr ?
"\n" :
"")
192 <<
" id=" << id_ <<
" " << set_counter_ <<
" of " << task_count
193 <<
" tiles set" << std::endl;
194 std::cerr << ss.str().c_str();
199 [
this, task_count]() {
return this->set_counter_ == task_count; });
201 report_and_abort(
"TiledArray", e.what());
202 }
catch (madness::MadnessException& e) {
203 report_and_abort(
"MADNESS", e.what());
204 }
catch (SafeMPI::Exception& e) {
205 report_and_abort(
"SafeMPI", e.what());
206 }
catch (std::exception& e) {
207 report_and_abort(
"std", e.what());
209 report_and_abort(
"",
nullptr);
222 virtual int internal_eval() = 0;
233 task_count_ = this->internal_eval();
246 template <
typename Tile,
typename Policy>
265 std::shared_ptr<impl_type> pimpl_;
271 template <
typename Impl>
273 : pimpl_(std::static_pointer_cast<
impl_type>(pimpl)) {
289 pimpl_ = other.pimpl_;
332 const std::shared_ptr<pmap_interface>&
pmap()
const {
return pimpl_->
pmap(); }
371 madness::uniqueidT
id()
const {
return pimpl_->
id(); }
381 #endif // TILEDARRAY_DIST_EVAL_DIST_EVAL_BASE_H__INCLUDED
Tile value_type
Tile type.
impl_type::ordinal_type ordinal_type
Ordinal type.
World & world() const
World accessor.
const trange_type & trange() const
Tiled range accessor.
const shape_type & shape() const
Tensor shape accessor.
DistEvalImpl(World &world, const trange_type &trange, const shape_type &shape, const std::shared_ptr< pmap_interface > &pmap, const Permutation &perm)
Constructor.
ordinal_type size() const
Tensor tile volume accessor.
DistEvalImpl< Tile, Policy > DistEvalImpl_
This object type.
future get(ordinal_type i) const
Tile move.
Permutation of a sequence of objects indexed by base-0 indices.
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.
DistEvalImpl< Tile, Policy > impl_type
Implementation base class type.
void set_tile(ordinal_type i, Future< value_type > f)
Set tensor value with a future.
void set_tile(ordinal_type i, const value_type &value)
Set tensor value.
madness::uniqueidT id() const
Unique object id.
const range_type & tiles_range() const
Tiles range accessor.
void wait() const
Wait for all tiles to be assigned.
bool is_zero(ordinal_type i) const
Query for a zero tile.
Lazy tile for on-the-fly evaluation of array tiles.
eval_trait< value_type >::type eval_type
Tile evaluation type.
DistEval(const std::shared_ptr< Impl > &pimpl)
Constructor.
const std::shared_ptr< pmap_interface > & pmap() const
Tensor process map accessor.
virtual Future< value_type > get_tile(ordinal_type i) const =0
Get tile at index i.
impl_type::trange_type trange_type
Tiled range type for this object.
Distributed evaluator implementation object.
ProcessID owner(ordinal_type i) const
Query a tile owner.
World & world() const
World object accessor.
Tensor implementation and base for other tensor implementation objects.
DistEval< Tile, Policy > DistEval_
This class type.
#define TA_ASSERT(EXPR,...)
ProcessID owner(const Index &i) const
Query a tile owner.
Policy::ordinal_type ordinal_type
Ordinal type.
ordinal_type perm_index_to_source(ordinal_type index) const
Permute index from a target index to a source index.
TiledArray::detail::TensorImpl< Policy > TensorImpl_
Tensor implementation base class.
TensorImpl_::ordinal_type ordinal_type
Ordinal type.
A functor that permutes ordinal indices.
Policy::shape_type shape_type
Tensor shape type.
const std::shared_ptr< pmap_interface > & pmap() const
Tensor process map accessor.
Future< value_type > future
Future of tile type.
virtual void discard(ordinal_type i) const
Discard a tile that is not needed.
impl_type::pmap_interface pmap_interface
Process map interface type.
void eval()
Evaluate this tensor expression object.
TensorImpl_::range_type range_type
Range type this tensor.
impl_type::range_type range_type
Range type this tensor.
TensorImpl_::shape_type shape_type
Shape type.
virtual void notify()
Tile set notification.
ordinal_type size() const
Tensor tile volume accessor.
Policy::range_type range_type
Element/tile range type.
void eval()
Evaluate this object.
Policy::trange_type trange_type
Tiled range type.
impl_type::shape_type shape_type
Tensor shape type.
size_t volume(const DistArray< Tile, Policy > &a)
impl_type::eval_type eval_type
Tile evaluation type.
bool is_local(ordinal_type i) const
Query for a locally owned tile.
impl_type::value_type value_type
Tile type.
Policy::pmap_interface pmap_interface
Process map interface type.
TensorImpl_::pmap_interface pmap_interface
process map interface type
void wait() const
Wait for all local tiles to be evaluated.
const range_type & range() const
Tensor tile size array accessor.
bool is_dense() const
Query the density of the tensor.
Determine the object type used in the evaluation of tensor expressions.
const trange_type & trange() const
Tiled range accessor.
const shape_type & shape() const
Tensor shape accessor.
DistEval(const DistEval_ &other)
Copy constructor.
const madness::uniqueidT & id() const
Unique object id accessor.
Tensor expression object.
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.
virtual void discard_tile(ordinal_type i) const =0
Discard a tile that is not needed.
DistEval_ & operator=(const DistEval_ &other)
Assignment operator.