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>
37 class DistArray;
38 
39 namespace expressions {
40 
41 // Forward declaration
42 template <typename, bool>
43 class TsrExpr;
44 template <typename, typename, bool>
45 class TsrEngine;
46 
47 template <typename Tile, typename Policy, typename Result, bool Alias>
48 struct EngineTrait<TsrEngine<DistArray<Tile, Policy>, Result, Alias>> {
49  // Argument typedefs
51 
52  // Operational typedefs
53  // Note: the consumable flag is true for noop to avoid unnecessary copies.
54  // This is OK because the result consumable flag is set to false.
55  typedef TiledArray::detail::Noop<Result, typename array_type::eval_type,
56  true>
60  op_type>
62  typedef typename eval_trait<value_type>::type
65  Policy>>::type
67  typedef Policy policy;
70 
71  // Meta data typedefs
72  typedef typename policy::ordinal_type size_type;
73  typedef typename policy::trange_type trange_type;
74  typedef typename policy::shape_type shape_type;
75  typedef typename policy::pmap_interface
77 
78  static constexpr bool consumable =
80  static constexpr unsigned int leaves = 1;
81 };
82 
84 
89 template <typename Array, typename Result, bool Alias>
90 class TsrEngine : public LeafEngine<TsrEngine<Array, Result, Alias>> {
91  public:
92  // Class hierarchy typedefs
95  typedef typename LeafEngine_::ExprEngine_
97 
98  // Argument typedefs
101 
102  // Operational typedefs
103  typedef typename EngineTrait<TsrEngine_>::value_type
107  typedef typename EngineTrait<TsrEngine_>::op_type
109  typedef typename EngineTrait<TsrEngine_>::policy
113 
114  // Meta data typedefs
116  typedef typename EngineTrait<TsrEngine_>::trange_type
118  typedef typename EngineTrait<TsrEngine_>::shape_type
122 
123  template <typename A>
124  TsrEngine(const TsrExpr<A, Alias>& expr) : LeafEngine_(expr) {}
125 
127 
129  static op_type make_tile_op() { return op_type(op_base_type()); }
130 
132 
135  template <typename Perm, typename = std::enable_if_t<
136  TiledArray::detail::is_permutation_v<Perm>>>
137  static op_type make_tile_op(const Perm& perm) {
138  return op_type(op_base_type(), perm);
139  }
140 
141 }; // class TsrEngine
142 
143 } // namespace expressions
144 } // namespace TiledArray
145 
146 #endif // TILEDARRAY_EXPRESSIONS_TSR_ENGINE_H__INCLUDED
EngineTrait< TsrEngine_ >::size_type size_type
Size type.
Definition: tsr_engine.h:115
static op_type make_tile_op(const Perm &perm)
Permuting tile operation factory function.
Definition: tsr_engine.h:137
LeafEngine< TsrEngine_ > LeafEngine_
Leaf base class type.
Definition: tsr_engine.h:94
TiledArray::detail::Noop< Result, typename array_type::eval_type, true > op_base_type
The tile operation.
Definition: tsr_engine.h:57
EngineTrait< TsrEngine_ >::pmap_interface pmap_interface
Process map interface type.
Definition: tsr_engine.h:121
Expression wrapper for array objects.
Definition: tsr_expr.h:83
Type trait for extracting the scalar type of tensors and arrays.
Definition: type_traits.h:744
EngineTrait< TsrEngine_ >::array_type array_type
The left-hand expression type.
Definition: tsr_engine.h:100
Lazy tile for on-the-fly evaluation of array tiles.
Definition: array_eval.h:42
EngineTrait< TsrEngine_ >::policy policy
The result policy type.
Definition: tsr_engine.h:110
Leaf expression engine.
Definition: leaf_engine.h:39
TiledArray::detail::LazyArrayTile< typename array_type::value_type, op_type > value_type
Tile type.
Definition: tsr_engine.h:61
impl_type::eval_type eval_type
The tile evaluation type.
Definition: dist_array.h:88
static op_type make_tile_op()
Non-permuting tile operation factory function.
Definition: tsr_engine.h:129
LeafEngine_::ExprEngine_ ExprEngine_
Expression engine base class.
Definition: tsr_engine.h:96
EngineTrait< TsrEngine_ >::op_type op_type
Tile operation type.
Definition: tsr_engine.h:108
Tensor expression engine.
Definition: tsr_engine.h:90
EngineTrait< TsrEngine_ >::trange_type trange_type
Tiled range type type.
Definition: tsr_engine.h:117
EngineTrait< TsrEngine_ >::dist_eval_type dist_eval_type
This expression's distributed evaluator type.
Definition: tsr_engine.h:112
EngineTrait< TsrEngine_ >::op_base_type op_base_type
Tile base operation type.
Definition: tsr_engine.h:106
Forward declarations.
Definition: dist_array.h:57
TiledArray::detail::DistEval< value_type, policy > dist_eval_type
The distributed evaluator type.
Definition: tsr_engine.h:69
EngineTrait< TsrEngine_ >::value_type value_type
Tensor value type.
Definition: tsr_engine.h:104
EngineTrait< TsrEngine_ >::shape_type shape_type
Tensor shape type.
Definition: tsr_engine.h:119
Unary tile operation wrapper.
Definition: unary_wrapper.h:83
TiledArray::detail::scalar_type< DistArray< Tile, Policy > >::type scalar_type
Scalar type of tile.
Definition: tsr_engine.h:66
TsrEngine(const TsrExpr< A, Alias > &expr)
Definition: tsr_engine.h:124
Determine the object type used in the evaluation of tensor expressions.
Definition: type_traits.h:580
Tensor expression object.
Definition: dist_eval.h:247
TsrEngine< Array, Result, Alias > TsrEngine_
This class type.
Definition: tsr_engine.h:93
An N-dimensional shallow copy wrapper for tile objects.
Definition: tile.h:82
Tile no operation (noop)
Definition: noop.h:44