TiledArray  0.7.0
tsr_engine.h
Go to the documentation of this file.
1 /*
2  * This file is a part of TiledArray.
3  * Copyright (C) 2014 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  * Justus Calvin
19  * Department of Chemistry, Virginia Tech
20  *
21  * tsr_engine.h
22  * Mar 31, 2014
23  *
24  */
25 
26 #ifndef TILEDARRAY_EXPRESSIONS_TSR_ENGINE_H__INCLUDED
27 #define TILEDARRAY_EXPRESSIONS_TSR_ENGINE_H__INCLUDED
28 
32 
33 namespace TiledArray {
34 
35  // Forward declaration
36  template <typename, typename> class DistArray;
37 
38  namespace expressions {
39 
40  // Forward declaration
41  template <typename, bool> class TsrExpr;
42  template <typename, typename, bool> class TsrEngine;
43 
44  template <typename Tile, typename Policy, typename Result, bool Alias>
45  struct EngineTrait<TsrEngine<DistArray<Tile, Policy>, Result, Alias> > {
46  // Argument typedefs
48 
49  // Operational typedefs
50  // Note: the consumable flag is true for noop to avoid unnecessary copies.
51  // This is OK because the result consumable flag is set to false.
52  typedef TiledArray::detail::Noop<Result, typename array_type::eval_type,
53  true> op_base_type;
57  typedef typename eval_trait<value_type>::type
60  Policy> >::type scalar_type;
61  typedef Policy policy;
64 
65  // Meta data typedefs
66  typedef typename policy::size_type size_type;
67  typedef typename policy::trange_type trange_type;
68  typedef typename policy::shape_type shape_type;
69  typedef typename policy::pmap_interface
71 
72  static constexpr bool consumable = (! Alias) ||
74  static constexpr unsigned int leaves = 1;
75  };
76 
78 
83  template <typename Array, typename Result, bool Alias>
84  class TsrEngine : public LeafEngine<TsrEngine<Array, Result, Alias> > {
85  public:
86  // Class hierarchy typedefs
89  typedef typename LeafEngine_::ExprEngine_
91 
92  // Argument typedefs
95 
96  // Operational typedefs
101  typedef typename EngineTrait<TsrEngine_>::op_type
103  typedef typename EngineTrait<TsrEngine_>::policy
107 
108  // Meta data typedefs
109  typedef typename EngineTrait<TsrEngine_>::size_type
111  typedef typename EngineTrait<TsrEngine_>::trange_type
113  typedef typename EngineTrait<TsrEngine_>::shape_type
117 
118  template <typename A>
119  TsrEngine(const TsrExpr<A, Alias>& expr) : LeafEngine_(expr) { }
120 
122 
125  return op_type(op_base_type());
126  }
127 
129 
133  return op_type(op_base_type(), perm);
134  }
135 
136  }; // class TsrEngine
137 
138  } // namespace expressions
139 } // namespace TiledArray
140 
141 #endif // TILEDARRAY_EXPRESSIONS_TSR_ENGINE_H__INCLUDED
EngineTrait< TsrEngine_ >::pmap_interface pmap_interface
Process map interface type.
Definition: tsr_engine.h:116
EngineTrait< TsrEngine_ >::policy policy
The result policy type.
Definition: tsr_engine.h:104
const Permutation & perm() const
Permutation accessor.
Definition: expr_engine.h:204
EngineTrait< TsrEngine_ >::op_type op_type
Tile operation type.
Definition: tsr_engine.h:102
Determine the object type used in the evaluation of tensor expressions.
Definition: type_traits.h:296
Unary tile operation wrapper.
Definition: unary_wrapper.h:82
Type trait for extracting the scalar type of tensors and arrays.
Definition: type_traits.h:539
TiledArray::detail::scalar_type< DistArray< Tile, Policy > >::type scalar_type
Scalar type of tile.
Definition: tsr_engine.h:60
Expression wrapper for array objects.
Definition: dist_array.h:39
Lazy tile for on-the-fly evaluation of array tiles.
Definition: array_eval.h:42
EngineTrait< TsrEngine_ >::array_type array_type
The left-hand expression type.
Definition: tsr_engine.h:94
static op_type make_tile_op(const Permutation &perm)
Permuting tile operation factory function.
Definition: tsr_engine.h:132
Tile no operation (noop)
Definition: noop.h:44
Tensor expression object.
Definition: dist_eval.h:241
LeafEngine< TsrEngine_ > LeafEngine_
Leaf base class type.
Definition: tsr_engine.h:88
Forward declarations.
Definition: clone.h:32
TsrEngine(const TsrExpr< A, Alias > &expr)
Definition: tsr_engine.h:119
TiledArray::detail::Noop< Result, typename array_type::eval_type, true > op_base_type
The tile operation.
Definition: tsr_engine.h:53
static op_type make_tile_op()
Non-permuting tile operation factory function.
Definition: tsr_engine.h:124
TsrEngine< Array, Result, Alias > TsrEngine_
This class type.
Definition: tsr_engine.h:87
EngineTrait< TsrEngine_ >::size_type size_type
Size type.
Definition: tsr_engine.h:110
EngineTrait< TsrEngine_ >::shape_type shape_type
Tensor shape type.
Definition: tsr_engine.h:114
TiledArray::detail::LazyArrayTile< typename array_type::value_type, op_type > value_type
Tile type.
Definition: tsr_engine.h:56
EngineTrait< TsrEngine_ >::value_type value_type
Tensor value type.
Definition: tsr_engine.h:98
LeafEngine_::ExprEngine_ ExprEngine_
Expression engine base class.
Definition: tsr_engine.h:90
EngineTrait< TsrEngine_ >::dist_eval_type dist_eval_type
This expression&#39;s distributed evaluator type.
Definition: tsr_engine.h:106
Permutation of a sequence of objects indexed by base-0 indices.
Definition: permutation.h:119
EngineTrait< TsrEngine_ >::op_base_type op_base_type
Tile base operation type.
Definition: tsr_engine.h:100
EngineTrait< TsrEngine_ >::trange_type trange_type
Tiled range type type.
Definition: tsr_engine.h:112
TiledArray::detail::DistEval< value_type, policy > dist_eval_type
The distributed evaluator type.
Definition: tsr_engine.h:63
impl_type::eval_type eval_type
The tile evaluation type.
Definition: dist_array.h:65
Tensor expression engine.
Definition: tsr_engine.h:42
An N-dimensional shallow copy wrapper for tile objects.
Definition: tile.h:80
Leaf expression engine.
Definition: leaf_engine.h:39