TiledArray  0.7.0
dist_array.h
Go to the documentation of this file.
1 /*
2  * This file is a part of TiledArray.
3  * Copyright (C) 2013 Virginia Tech
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef TILEDARRAY_ARRAY_H__INCLUDED
21 #define TILEDARRAY_ARRAY_H__INCLUDED
22 
23 #include <cstdlib>
24 
25 #include <TiledArray/replicator.h>
27 //#include <TiledArray/tensor.h>
29 #include <TiledArray/array_impl.h>
33 
34 namespace TiledArray {
35 
36  // Forward declarations
37  template <typename, typename> class Tensor;
38  namespace expressions {
39  template <typename, bool> class TsrExpr;
40  } // namespace expressions
41 
42 
44 
50  template <typename Tile = Tensor<double, Eigen::aligned_allocator<double> >,
51  typename Policy = DensePolicy>
52  class DistArray {
53  public:
60  typedef typename impl_type::range_type range_type;
61  typedef typename impl_type::shape_type shape_type;
62  typedef typename impl_type::range_type::index index;
63  typedef typename impl_type::size_type size_type;
64  typedef typename impl_type::value_type value_type;
65  typedef typename impl_type::eval_type eval_type;
66  typedef typename impl_type::reference future;
67  typedef typename impl_type::reference reference;
69  typedef typename impl_type::iterator iterator;
72 
73  private:
74 
75  std::shared_ptr<impl_type> pimpl_;
76 
77  static madness::AtomicInt cleanup_counter_;
78 
80 
84  static void lazy_deleter(const impl_type* const pimpl) {
85  if(pimpl) {
86  if(madness::initialized()) {
87  World& world = pimpl->world();
88  const madness::uniqueidT id = pimpl->id();
89  cleanup_counter_++;
90 
91  try {
92  world.gop.lazy_sync(id, [pimpl]() {
93  delete pimpl;
94  DistArray_::cleanup_counter_--;
95  });
96  }
97  catch(madness::MadnessException& e) {
98  fprintf(stderr, "!! ERROR TiledArray: madness::MadnessException thrown in Array::lazy_deleter().\n"
99  "%s\n"
100  "!! ERROR TiledArray: The exception has been absorbed.\n"
101  "!! ERROR TiledArray: rank=%i\n", e.what(), world.rank());
102 
103  cleanup_counter_--;
104  delete pimpl;
105  }
106  catch(std::exception& e) {
107  fprintf(stderr, "!! ERROR TiledArray: std::exception thrown in Array::lazy_deleter().\n"
108  "%s\n"
109  "!! ERROR TiledArray: The exception has been absorbed.\n"
110  "!! ERROR TiledArray: rank=%i\n", e.what(), world.rank());
111 
112  cleanup_counter_--;
113  delete pimpl;
114  }
115  catch(...) {
116  fprintf(stderr, "!! ERROR TiledArray: An unknown exception was thrown in Array::lazy_deleter().\n"
117  "!! ERROR TiledArray: The exception has been absorbed.\n"
118  "!! ERROR TiledArray: rank=%i\n", world.rank());
119 
120  cleanup_counter_--;
121  delete pimpl;
122  }
123  } else {
124  delete pimpl;
125  }
126  }
127  }
128 
130 
135  static std::shared_ptr<impl_type>
136  init(World& world, const trange_type& trange, const shape_type& shape,
137  std::shared_ptr<pmap_interface> pmap)
138  {
139  // User level validation of input
140 
141  if(! pmap) {
142  // Construct a default process map
143  pmap = Policy::default_pmap(world, trange.tiles_range().volume());
144  } else {
145  // Validate the process map
146  TA_USER_ASSERT(pmap->size() == trange.tiles_range().volume(),
147  "Array::Array() -- The size of the process map is not equal to the number of tiles in the TiledRange object.");
148  TA_USER_ASSERT(pmap->rank() == typename pmap_interface::size_type(world.rank()),
149  "Array::Array() -- The rank of the process map is not equal to that of the world object.");
150  TA_USER_ASSERT(pmap->procs() == typename pmap_interface::size_type(world.size()),
151  "Array::Array() -- The number of processes in the process map is not equal to that of the world object.");
152  }
153 
154  // Validate the shape
155  TA_USER_ASSERT(! shape.empty(),
156  "Array::Array() -- The shape is not initialized.");
157  TA_USER_ASSERT(shape.validate(trange.tiles_range()),
158  "Array::Array() -- The range of the shape is not equal to the tiles range.");
159 
160  return std::shared_ptr<impl_type>(new impl_type(world, trange, shape, pmap), lazy_deleter);
161  }
162 
163  public:
165 
170 
171  DistArray() : pimpl_() { }
172 
174 
177  DistArray(const DistArray_& other) : pimpl_(other.pimpl_) { }
178 
180 
188  const std::shared_ptr<pmap_interface>& pmap = std::shared_ptr<pmap_interface>()) :
189  pimpl_(init(world, trange, shape_type(), pmap))
190  { }
191 
193 
202  const std::shared_ptr<pmap_interface>& pmap = std::shared_ptr<pmap_interface>()) :
203  pimpl_(init(world, trange, shape, pmap))
204  { }
205 
207 
212  template <typename OtherTile, typename = std::enable_if_t<not std::is_same<DistArray_,DistArray<OtherTile,Policy>>::value>>
213  explicit DistArray(const DistArray<OtherTile,Policy>& other) :
214  pimpl_()
215  {
216  *this = foreach<Tile,OtherTile>(other, [](Tile& result, const OtherTile& source) { result = TiledArray::Cast<Tile,OtherTile>{}(source); });
217  }
218 
220 
226  template <typename OtherTile, typename Op>
227  DistArray(const DistArray<OtherTile,Policy>& other, Op&& op) :
228  pimpl_()
229  {
230  *this = foreach<Tile,OtherTile,Op>(other, std::forward<Op>(op));
231  }
232 
234 
239 
241 
243  DistArray_ clone() const {
244  return TiledArray::clone(*this);
245  }
246 
248 
256  static void wait_for_lazy_cleanup(World& world,
257  const double = 60.0)
258  {
259  try {
260  world.await([&]() { return (cleanup_counter_ == 0); }, true);
261  } catch(...) {
262  printf("%i: Array lazy cleanup timeout with %i pending cleanup(s)\n",
263  world.rank(), int(cleanup_counter_));
264  throw;
265  }
266  }
267 
269 
272  DistArray_& operator=(const DistArray_& other) {
273  pimpl_ = other.pimpl_;
274 
275  return *this;
276  }
277 
279 
283  madness::uniqueidT id() const { return pimpl_->id(); }
284 
286 
289  check_pimpl();
290  return pimpl_->begin();
291  }
292 
294 
297  check_pimpl();
298  return pimpl_->cbegin();
299  }
300 
302 
305  check_pimpl();
306  return pimpl_->end();
307  }
308 
310 
312  const_iterator end() const {
313  check_pimpl();
314  return pimpl_->cend();
315  }
316 
318 
323  template <typename Index>
324  Future<value_type> find(const Index& i) const {
325  check_index(i);
326  return pimpl_->get(i);
327  }
328 
330 
335  template <typename Integer>
336  Future<value_type> find(const std::initializer_list<Integer>& i) const {
337  return find<std::initializer_list<Integer>>(i);
338  }
339 
341 
346  template <typename Index, typename InIter>
347  typename std::enable_if<detail::is_input_iterator<InIter>::value>::type
348  set(const Index& i, InIter first) {
349  check_index(i);
350  pimpl_->set(i, value_type(pimpl_->trange().make_tile_range(i), first));
351  }
352 
354 
359  template <typename Integer, typename InIter>
360  typename std::enable_if<detail::is_input_iterator<InIter>::value>::type
361  set(const std::initializer_list<Integer>& i, InIter first) {
362  set<std::initializer_list<Integer>>(i, first);
363  }
364 
366 
371  template <typename Index>
372  void set(const Index& i, const element_type& value = element_type()) {
373  check_index(i);
374  pimpl_->set(i, value_type(pimpl_->trange().make_tile_range(i), value));
375  }
376 
378 
383  template <typename Integer>
384  void set(const std::initializer_list<Integer>& i,
385  const element_type& value = element_type()) {
386  set<std::initializer_list<Integer>>(i, value);
387  }
388 
390 
394  template <typename Index>
395  void set(const Index& i, const Future<value_type>& f) {
396  check_index(i);
397  pimpl_->set(i, f);
398  }
399 
401 
405  template <typename Integer>
406  void set(const std::initializer_list<Integer>& i,
407  const Future<value_type>& f) {
408  set<std::initializer_list<Integer>>(i, f);
409  }
410 
412 
416  template <typename Index>
417  void set(const Index& i, const value_type& v) {
418  check_index(i);
419  pimpl_->set(i, v);
420  }
421 
423 
427  template <typename Integer>
428  void set(const std::initializer_list<Integer>& i, const value_type& v) {
429  set<std::initializer_list<Integer>>(i, v);
430  }
431 
433 
436  void fill_local(const element_type& value = element_type(), bool skip_set = false) {
437  init_tiles([=] (const range_type& range)
438  { return value_type(range, value); }, skip_set);
439  }
440 
442 
445  void fill(const element_type& value = element_type(), bool skip_set = false) {
446  fill_local(value, skip_set);
447  }
448 
451  void fill_random(bool skip_set = false) {
452  init_elements([](const auto &) {
453  return (element_type)std::rand() / RAND_MAX;
454  });
455  }
456 
458 
487  template <typename Op>
488  void init_tiles(Op&& op, bool skip_set = false) {
489  check_pimpl();
490 
491  auto it = pimpl_->pmap()->begin();
492  const auto end = pimpl_->pmap()->end();
493  for(; it != end; ++it) {
494  const auto index = *it;
495  if(! pimpl_->is_zero(index)) {
496  if (skip_set) {
497  auto fut = find(index);
498  if (fut.probe())
499  continue;
500  }
501  Future<value_type> tile = pimpl_->world().taskq.add(
502  [] (DistArray_* array, const size_type index, const Op& op) -> value_type
503  { return op(array->trange().make_tile_range(index)); },
504  this, index, op);
505  set(index, tile);
506  }
507  }
508  }
509 
511 
529  template <typename Op>
530  void init_elements(Op&& op, bool skip_set = false) {
532  {
533  // Initialize the tile with the given range object
535 
536  // Initialize tile elements
537  for(auto& idx: range)
538  tile[idx] = op(idx);
539 
540  return tile;
541  });
542  }
543 
545 
547  const trange_type& trange() const {
548  check_pimpl();
549  return pimpl_->trange();
550  }
551 
553 
555  const range_type& range() const {
556  check_pimpl();
557  return pimpl_->tiles_range();
558  }
559 
561  DEPRECATED const typename trange_type::range_type& elements() const {
562  return elements_range();
563  }
564 
566 
568  const typename trange_type::range_type& elements_range() const {
569  check_pimpl();
570  return pimpl_->trange().elements_range();
571  }
572 
573  size_type size() const {
574  check_pimpl();
575  return pimpl_->size();
576  }
577 
579 
583  operator ()(const std::string& vars) const {
584 #ifndef NDEBUG
585  const unsigned int n = 1u + std::count_if(vars.begin(), vars.end(),
586  [](const char c) { return c == ','; });
587  if(bool(pimpl_) && n != pimpl_->trange().tiles_range().rank()) {
588  if(TiledArray::get_default_world().rank() == 0) {
590  "The number of array annotation variables is not equal to the array dimension:" \
591  << "\n number of variables = " << n \
592  << "\n array dimension = " << pimpl_->trange().tiles_range().rank() );
593  }
594 
595  TA_EXCEPTION("The number of array annotation variables is not equal to the array dimension.");
596  }
597 #endif // NDEBUG
599  }
600 
602 
606  operator ()(const std::string& vars) {
607 #ifndef NDEBUG
608  const unsigned int n = 1u + std::count_if(vars.begin(), vars.end(),
609  [](const char c) { return c == ','; });
610  if(bool(pimpl_) && n != pimpl_->trange().tiles_range().rank()) {
611  if(TiledArray::get_default_world().rank() == 0) {
613  "The number of array annotation variables is not equal to the array dimension:" \
614  << "\n number of variables = " << n \
615  << "\n array dimension = " << pimpl_->trange().tiles_range().rank() );
616  }
617 
618  TA_EXCEPTION("The number of array annotation variables is not equal to the array dimension.");
619  }
620 #endif // NDEBUG
622  }
623 
625  DEPRECATED World& get_world() const {
626  check_pimpl();
627  return pimpl_->world();
628  }
629 
631 
633  World& world() const {
634  check_pimpl();
635  return pimpl_->world();
636  }
637 
639  DEPRECATED const std::shared_ptr<pmap_interface>& get_pmap() const {
640  check_pimpl();
641  return pimpl_->pmap();
642  }
643 
645 
647  const std::shared_ptr<pmap_interface>& pmap() const {
648  check_pimpl();
649  return pimpl_->pmap();
650  }
651 
653 
655  bool is_dense() const {
656  check_pimpl();
657  return pimpl_->is_dense();
658  }
659 
661  DEPRECATED const shape_type& get_shape() const { return pimpl_->shape(); }
662 
664 
668  inline const shape_type& shape() const { return pimpl_->shape(); }
669 
671 
677  template <typename Index>
678  ProcessID owner(const Index& i) const {
679  check_index(i);
680  return pimpl_->owner(i);
681  }
682 
684 
690  template <typename Index1>
691  ProcessID owner(const std::initializer_list<Index1>& i) const {
692  return owner<std::initializer_list<Index1>>(i);
693  }
694 
696 
701  template <typename Index>
702  bool is_local(const Index& i) const {
703  check_index(i);
704  return pimpl_->is_local(i);
705  }
706 
708 
713  template <typename Index1>
714  bool is_local(const std::initializer_list<Index1>& i) const {
715  return is_local<std::initializer_list<Index1>>(i);
716  }
717 
719 
722  template <typename Index>
723  bool is_zero(const Index& i) const {
724  check_index(i);
725  return pimpl_->is_zero(i);
726  }
727 
729 
732  template <typename Index1>
733  bool is_zero(const std::initializer_list<Index1>& i) const {
734  return is_zero<std::initializer_list<Index1>>(i);
735  }
736 
738 
740  void swap(DistArray_& other) { std::swap(pimpl_, other.pimpl_); }
741 
744  check_pimpl();
745  if((! pimpl_->pmap()->is_replicated()) && (world().size() > 1)) {
746  // Construct a replicated array
747  auto pmap = std::make_shared<detail::ReplicatedPmap>(world(), size());
748  DistArray_ result = DistArray_(world(), trange(), shape(), pmap);
749 
750  // Create the replicator object that will do an all-to-all broadcast of
751  // the local tile data.
752  auto replicator =
753  std::make_shared<detail::Replicator<DistArray_>>(*this, result);
754 
755  // Put the replicator pointer in the deferred cleanup object so it will
756  // be deleted at the end of the next fence.
757  TA_ASSERT(replicator.unique()); // Required for deferred_cleanup
758  madness::detail::deferred_cleanup(world(), replicator);
759 
760  DistArray_::operator=(result);
761  }
762  }
763 
765 
767  void truncate() { TiledArray::truncate(*this); }
768 
770 
773  bool is_initialized() const { return static_cast<bool>(pimpl_); }
774 
775  private:
776 
777  template <typename Index>
778  typename std::enable_if<std::is_integral<Index>::value>::type
779  check_index(const Index i) const {
780  check_pimpl();
781  TA_USER_ASSERT(pimpl_->tiles_range().includes(i),
782  "The ordinal index used to access an array tile is out of range.");
783  }
784 
785  template <typename Index>
786  typename std::enable_if<! std::is_integral<Index>::value>::type
787  check_index(const Index& i) const {
788  check_pimpl();
789  TA_USER_ASSERT(pimpl_->tiles_range().includes(i),
790  "The coordinate index used to access an array tile is out of range.");
791  TA_USER_ASSERT(i.size() == pimpl_->trange().tiles_range().rank(),
792  "The number of elements in the coordinate index does not match the dimension of the array.");
793  }
794 
795  template <typename Index1>
796  void check_index(const std::initializer_list<Index1>& i) const {
797  check_index<std::initializer_list<Index1>>(i);
798  }
799 
801  void check_pimpl() const {
802  TA_USER_ASSERT(pimpl_,
803  "The Array has not been initialized, likely reason: it was default constructed and used.");
804  }
805 
806  }; // class Array
807 
808 
809  template <typename Tile, typename Policy>
810  madness::AtomicInt DistArray<Tile, Policy>::cleanup_counter_;
811 
812 #ifndef TILEDARRAY_HEADER_ONLY
813 
814  extern template
815  class DistArray<Tensor<double, Eigen::aligned_allocator<double> >, DensePolicy>;
816  extern template
817  class DistArray<Tensor<float, Eigen::aligned_allocator<float> >, DensePolicy>;
818  extern template
819  class DistArray<Tensor<int, Eigen::aligned_allocator<int> >, DensePolicy>;
820  extern template
821  class DistArray<Tensor<long, Eigen::aligned_allocator<long> >, DensePolicy>;
822 // extern template
823 // class DistArray<Tensor<std::complex<double>, Eigen::aligned_allocator<std::complex<double> > >, DensePolicy>;
824 // extern template
825 // class DistArray<Tensor<std::complex<float>, Eigen::aligned_allocator<std::complex<float> > >, DensePolicy>
826 
827  extern template
828  class DistArray<Tensor<double, Eigen::aligned_allocator<double> >, SparsePolicy>;
829  extern template
830  class DistArray<Tensor<float, Eigen::aligned_allocator<float> >, SparsePolicy>;
831  extern template
832  class DistArray<Tensor<int, Eigen::aligned_allocator<int> >, SparsePolicy>;
833  extern template
834  class DistArray<Tensor<long, Eigen::aligned_allocator<long> >, SparsePolicy>;
835 // extern template
836 // class DistArray<Tensor<std::complex<double>, Eigen::aligned_allocator<std::complex<double> > >, SparsePolicy>;
837 // extern template
838 // class DistArray<Tensor<std::complex<float>, Eigen::aligned_allocator<std::complex<float> > >, SparsePolicy>;
839 
840 #endif // TILEDARRAY_HEADER_ONLY
841 
843 
852  template <typename Tile, typename Policy>
853  inline std::ostream& operator<<(std::ostream& os, const DistArray<Tile, Policy>& a) {
854  if(a.world().rank() == 0) {
855  for(std::size_t i = 0; i < a.size(); ++i)
856  if(! a.is_zero(i)) {
857  const typename DistArray<Tile, Policy>::value_type tile = a.find(i).get();
858  os << i << ": " << tile << "\n";
859  }
860  }
861  a.world().gop.fence();
862  return os;
863  }
864 
865 } // namespace TiledArray
866 
867 #endif // TILEDARRAY_ARRAY_H__INCLUDED
DEPRECATED const trange_type::range_type & elements() const
Definition: dist_array.h:561
TensorImpl_::range_type range_type
Elements/tiles range type.
Definition: array_impl.h:430
TensorImpl_::shape_type shape_type
Shape type.
Definition: array_impl.h:431
Distributed tensor iterator.
Definition: array_impl.h:40
Tile cast operation.
Definition: cast.h:34
A (hyperrectangular) interval on , space of integer n-indices.
Definition: range.h:39
#define DEPRECATED
Definition: error.h:148
static void wait_for_lazy_cleanup(World &world, const double=60.0)
Wait for lazy tile cleanup.
Definition: dist_array.h:256
Future< value_type > find(const Index &i) const
Find local or remote tile.
Definition: dist_array.h:324
impl_type::shape_type shape_type
Shape type for array tiling.
Definition: dist_array.h:61
void swap(DistArray_ &other)
Swap this array with other.
Definition: dist_array.h:740
An N-dimensional tensor object.
Definition: foreach.h:40
const_iterator begin() const
Begin const iterator factory function.
Definition: dist_array.h:296
void truncate(DistArray< Tile, DensePolicy > &array)
Truncate a dense Array.
Definition: truncate.h:44
void swap(Bitset< B > &b0, Bitset< B > &b1)
Definition: bitset.h:593
eval_trait< Tile >::type eval_type
The tile evaluation type.
Definition: array_impl.h:434
const shape_type & shape() const
Shape accessor.
Definition: dist_array.h:668
const trange_type & trange() const
Tiled range accessor.
Definition: dist_array.h:547
TiledArray::expressions::TsrExpr< const DistArray_, true > operator()(const std::string &vars) const
Create a tensor expression.
Definition: dist_array.h:583
impl_type::range_type range_type
Elements/tiles range type.
Definition: dist_array.h:60
Type trait for extracting the numeric type of tensors and arrays.
Definition: type_traits.h:479
ProcessID owner(const Index &i) const
Tile ownership.
Definition: dist_array.h:678
TensorImpl_::size_type size_type
Size type.
Definition: array_impl.h:427
DistArray(const DistArray< OtherTile, Policy > &other, Op &&op)
Unary transform constructor.
Definition: dist_array.h:227
void make_replicated()
Convert a distributed array into a replicated array.
Definition: dist_array.h:743
impl_type::const_iterator const_iterator
Local tile const iterator.
Definition: dist_array.h:70
bool is_local(const std::initializer_list< Index1 > &i) const
Check if the tile at index i is stored locally.
Definition: dist_array.h:714
bool is_initialized() const
Check if the array is initialized.
Definition: dist_array.h:773
Type trait for extracting the scalar type of tensors and arrays.
Definition: type_traits.h:539
DistArray()
Default constructor.
Definition: dist_array.h:171
DistArray< Tile, Policy > DistArray_
This object&#39;s type.
Definition: dist_array.h:54
impl_type::pmap_interface pmap_interface
Process map interface type.
Definition: dist_array.h:71
Expression wrapper for array objects.
Definition: dist_array.h:39
impl_type::value_type value_type
Tile type.
Definition: dist_array.h:64
DistArray< Tile, Policy > clone(const DistArray< Tile, Policy > &arg)
Create a deep copy of an array.
Definition: clone.h:43
DistArray(World &world, const trange_type &trange, const shape_type &shape, const std::shared_ptr< pmap_interface > &pmap=std::shared_ptr< pmap_interface >())
Sparse array constructor.
Definition: dist_array.h:201
const trange_type::range_type & elements_range() const
Element range accessor.
Definition: dist_array.h:568
TensorImpl_::trange_type trange_type
Tiled range type for this object.
Definition: array_impl.h:429
impl_type::range_type::index index
Array coordinate index type.
Definition: dist_array.h:62
bool is_zero(const Index &i) const
Check for zero tiles.
Definition: dist_array.h:723
void fill_local(const element_type &value=element_type(), bool skip_set=false)
Fill all local tiles.
Definition: dist_array.h:436
DistArray(World &world, const trange_type &trange, const std::shared_ptr< pmap_interface > &pmap=std::shared_ptr< pmap_interface >())
Dense array constructor.
Definition: dist_array.h:187
DEPRECATED const std::shared_ptr< pmap_interface > & get_pmap() const
Definition: dist_array.h:639
DEPRECATED const shape_type & get_shape() const
Definition: dist_array.h:661
Forward declarations.
Definition: clone.h:32
#define TA_ASSERT(a)
Definition: error.h:107
Tensor implementation and base for other tensor implementation objects.
Definition: array_impl.h:423
void fill_random(bool skip_set=false)
Definition: dist_array.h:451
impl_type::iterator iterator
Local tile iterator.
Definition: dist_array.h:69
detail::scalar_type< Tile >::type scalar_type
The tile scalar type.
Definition: dist_array.h:58
World & world() const
World accessor.
Definition: dist_array.h:633
const_iterator end() const
End const iterator factory function.
Definition: dist_array.h:312
TensorImpl_::policy_type policy_type
Policy type for this object.
Definition: array_impl.h:428
TensorImpl_::pmap_interface pmap_interface
process map interface type
Definition: array_impl.h:432
const madness::uniqueidT & id() const
Unique object id accessor.
Definition: array_impl.h:553
impl_type::reference future
Future of value_type.
Definition: dist_array.h:66
impl_type::policy_type policy_type
Policy type.
Definition: dist_array.h:56
bool is_local(const Index &i) const
Check if the tile at index i is stored locally.
Definition: dist_array.h:702
DistArray(const DistArray_ &other)
Copy constructor.
Definition: dist_array.h:177
impl_type::trange_type trange_type
Tile range type.
Definition: dist_array.h:59
TiledArray::detail::ArrayImpl< Tile, Policy > impl_type
Definition: dist_array.h:55
DistArray(const DistArray< OtherTile, Policy > &other)
converting copy constructor
Definition: dist_array.h:213
impl_type::size_type size_type
Size type.
Definition: dist_array.h:63
iterator begin()
Begin iterator factory function.
Definition: dist_array.h:288
DEPRECATED World & get_world() const
Definition: dist_array.h:625
Future< value_type > find(const std::initializer_list< Integer > &i) const
Find local or remote tile.
Definition: dist_array.h:336
DistArray_ clone() const
Create a deep copy of this array.
Definition: dist_array.h:243
#define TA_EXCEPTION(m)
Definition: error.h:72
void init_tiles(Op &&op, bool skip_set=false)
Initialize (local) tiles with a user provided functor.
Definition: dist_array.h:488
DistArray_ & operator=(const DistArray_ &other)
Copy constructor.
Definition: dist_array.h:272
~DistArray()
Destructor.
Definition: dist_array.h:238
ProcessID owner(const std::initializer_list< Index1 > &i) const
Tile ownership.
Definition: dist_array.h:691
iterator end()
End iterator factory function.
Definition: dist_array.h:304
#define TA_USER_ASSERT(a, m)
Definition: error.h:123
World & world() const
World accessor.
Definition: tensor_impl.h:169
bool is_zero(const std::initializer_list< Index1 > &i) const
Check for zero tiles.
Definition: dist_array.h:733
const range_type & range() const
Tile range accessor.
Definition: dist_array.h:555
Tensor tile reference.
Definition: array_impl.h:46
detail::numeric_type< Tile >::type element_type
The tile element type.
Definition: dist_array.h:57
impl_type::eval_type eval_type
The tile evaluation type.
Definition: dist_array.h:65
size_type size() const
Definition: dist_array.h:573
void truncate()
Update shape data and remove tiles that are below the zero threshold.
Definition: dist_array.h:767
impl_type::const_reference const_reference
future type
Definition: dist_array.h:68
void init_elements(Op &&op, bool skip_set=false)
Initialize (local) elements with a user provided functor.
Definition: dist_array.h:530
void fill(const element_type &value=element_type(), bool skip_set=false)
Fill all local tiles.
Definition: dist_array.h:445
An N-dimensional shallow copy wrapper for tile objects.
Definition: tile.h:80
madness::uniqueidT id() const
Global object id.
Definition: dist_array.h:283
#define TA_USER_ERROR_MESSAGE(m)
Definition: error.h:118
impl_type::reference reference
future type
Definition: dist_array.h:67
bool is_dense() const
Check dense/sparse.
Definition: dist_array.h:655
const std::shared_ptr< pmap_interface > & pmap() const
Process map accessor.
Definition: dist_array.h:647