/usr/include/TiledArray/expressions/unary_engine.h is in libtiledarray-dev 0.6.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | /*
* This file is a part of TiledArray.
* Copyright (C) 2014 Virginia Tech
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Justus Calvin
* Department of Chemistry, Virginia Tech
*
* unary_engine.h
* Apr 1, 2014
*
*/
#ifndef TILEDARRAY_EXPRESSIONS_UNARY_ENGINE_H__INCLUDED
#define TILEDARRAY_EXPRESSIONS_UNARY_ENGINE_H__INCLUDED
#include <TiledArray/expressions/expr_engine.h>
#include <TiledArray/dist_eval/unary_eval.h>
namespace TiledArray {
namespace expressions {
// Forward declarations
template <typename> class UnaryExpr;
template <typename Derived>
class UnaryEngine : ExprEngine<Derived> {
public:
// Class hierarchy typedefs
typedef UnaryEngine<Derived> UnaryEngine_; ///< This class type
typedef ExprEngine<Derived> ExprEngine_; ///< Base class type
// Argument typedefs
typedef typename EngineTrait<Derived>::argument_type argument_type; ///< The argument expression engine type
// Operational typedefs
typedef typename EngineTrait<Derived>::value_type value_type; ///< The result tile type
typedef typename EngineTrait<Derived>::op_type op_type; ///< The tile operation type
typedef typename EngineTrait<Derived>::policy policy; ///< The result policy type
typedef typename EngineTrait<Derived>::dist_eval_type dist_eval_type; ///< The distributed evaluator type
// Meta data typedefs
typedef typename EngineTrait<Derived>::size_type size_type; ///< Size type
typedef typename EngineTrait<Derived>::trange_type trange_type; ///< Tiled range type
typedef typename EngineTrait<Derived>::shape_type shape_type; ///< Shape type
typedef typename EngineTrait<Derived>::pmap_interface pmap_interface; ///< Process map interface type
static constexpr bool consumable = true;
static constexpr unsigned int leaves = argument_type::leaves;
protected:
// Import base class variables to this scope
using ExprEngine_::world_;
using ExprEngine_::vars_;
using ExprEngine_::perm_;
using ExprEngine_::trange_;
using ExprEngine_::shape_;
using ExprEngine_::pmap_;
using ExprEngine_::permute_tiles_;
argument_type arg_; ///< The argument
private:
// Not allowed
UnaryEngine(const UnaryEngine_&);
UnaryEngine_& operator=(const UnaryEngine_&);
public:
template <typename D>
UnaryEngine(const UnaryExpr<D>& expr) :
ExprEngine_(expr), arg_(expr.arg())
{ }
// Pull base class functions into this class.
using ExprEngine_::derived;
using ExprEngine_::vars;
/// Set the variable list for this expression
/// This function will set the variable list for this expression and its
/// children such that the number of permutations is minimized.
/// \param target_vars The target variable list for this expression
void perm_vars(const VariableList& target_vars) {
TA_ASSERT(permute_tiles_);
vars_ = target_vars;
if(arg_.vars() != target_vars)
arg_.perm_vars(target_vars);
}
/// Initialize the variable list of this expression
/// \param target_vars The target variable list for this expression
void init_vars(const VariableList& target_vars) {
arg_.init_vars(target_vars);
perm_vars(target_vars);
}
/// Initialize the variable list of this expression
void init_vars() {
arg_.init_vars();
vars_ = arg_.vars();
}
/// Initialize result tensor structure
/// This function will initialize the permutation, tiled range, and shape
/// for the left-hand, right-hand, and result tensor.
/// \param target_vars The target variable list for the result tensor
void init_struct(const VariableList& target_vars) {
arg_.init_struct(ExprEngine_::vars());
ExprEngine_::init_struct(target_vars);
}
/// Initialize result tensor distribution
/// This function will initialize the world and process map for the result
/// tensor.
/// \param world The world were the result will be distributed
/// \param pmap The process map for the result tensor tiles
void init_distribution(World* world,
const std::shared_ptr<pmap_interface>& pmap)
{
arg_.init_distribution(world, pmap);
ExprEngine_::init_distribution(world, arg_.pmap());
}
/// Non-permuting tiled range factory function
/// \return The result tiled range
trange_type make_trange() const { return arg_.trange(); }
/// Permuting tiled range factory function
/// \param perm The permutation to be applied to the tiled range
/// \return The result shape
trange_type make_trange(const Permutation& perm) const {
return perm ^ arg_.trange();
}
/// Construct the distributed evaluator for this expression
/// \return The distributed evaluator that will evaluate this expression
dist_eval_type make_dist_eval() const {
typedef TiledArray::detail::UnaryEvalImpl<typename argument_type::dist_eval_type,
typename Derived::op_type, typename dist_eval_type::policy> impl_type;
// Construct left and right distributed evaluators
const typename argument_type::dist_eval_type arg = arg_.make_dist_eval();
// Construct the distributed evaluator type
std::shared_ptr<impl_type> pimpl(
new impl_type(arg, *world_, trange_, shape_, pmap_, perm_,
ExprEngine_::make_op()));
return dist_eval_type(pimpl);
}
/// Expression print
/// \param os The output stream
/// \param target_vars The target variable list for this expression
void print(ExprOStream os, const VariableList& target_vars) const {
ExprEngine_::print(os, target_vars);
os.inc();
arg_.print(os, vars_);
os.dec();
}
}; // class UnaryEngine
} // namespace expressions
} // namespace TiledArray
#endif // TILEDARRAY_EXPRESSIONS_UNARY_ENGINE_H__INCLUDED
|