Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/TiledArray/conversions/eigen.h
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ void counted_eigen_subtensor_to_tensor(const Eigen_Tensor_* src,

/// Task function for assigning a tensor to an Eigen subtensor

/// \tparam Tensor_ a TiledArray::Tensor type
/// \tparam TA_Tensor_ a TiledArray::Tensor type
/// \tparam Eigen_Tensor_ an Eigen::Tensor type
/// \param src The source tensor
/// \param dst The destination tensor
Expand Down
8 changes: 5 additions & 3 deletions src/TiledArray/dist_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,10 @@ class DistArray : public madness::archive::ParallelSerializableObject {
/// \throw TiledArray::Exception if the PIMPL is not initialized. Strong throw
/// guarantee.
/// \deprecated use DistArray::tiles_range()
// TODO: uncomment [[deprecated("use DistArray::tiles_range()")]]
const range_type& range() const { return impl_ref().tiles_range(); }
[[deprecated("use DistArray::tiles_range()")]] const range_type& range()
const {
return impl_ref().tiles_range();
}

/// Tile range accessor

Expand Down Expand Up @@ -1546,7 +1548,7 @@ class DistArray : public madness::archive::ParallelSerializableObject {
if (!is_initialized()) return;

constexpr bool is_tot = detail::is_tensor_of_tensor_v<value_type>;
const auto rank = range().rank();
const auto rank = tiles_range().rank();
// TODO: Make constexpr and use structured bindings when CUDA supports C++17
if (is_tot) {
// Make sure the index is capable of being interpreted as a ToT index
Expand Down
3 changes: 2 additions & 1 deletion src/TiledArray/expressions/add_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ class ScalAddExpr : public BinaryExpr<ScalAddExpr<Left, Right, Scalar> > {

/// Expression constructor

/// \param arg The argument expression
/// \param left The left argument expression
/// \param right The right argument expression
/// \param factor The scaling factor
ScalAddExpr(const left_type& left, const right_type& right,
const scalar_type factor)
Expand Down
6 changes: 4 additions & 2 deletions src/TiledArray/expressions/blk_tsr_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,8 @@ inline ScalConjBlkTsrExpr<Array, Scalar> operator*(
/// Scaled block tensor expression factor

/// \tparam Array A `DistArray` type
/// \tparam Scalar A scalar type
/// \tparam Scalar1 A scalar type
/// \tparam Scalar2 A scalar type
/// \param expr The scaled block tensor expression object
/// \param factor The scaling factor
/// \return A scaled-tensor expression object
Expand All @@ -776,7 +777,8 @@ inline ScalConjBlkTsrExpr<Array, mult_t<Scalar1, Scalar2>> operator*(
/// Scaled-tensor expression factor

/// \tparam Array A `DistArray` type
/// \tparam Scalar A scalar type
/// \tparam Scalar1 A scalar type
/// \tparam Scalar2 A scalar type
/// \param factor The scaling factor
/// \param expr The scaled block tensor expression object
/// \return A scaled-tensor expression object
Expand Down
3 changes: 1 addition & 2 deletions src/TiledArray/expressions/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ class Expr {
return (*op)(cast_tile);
}

/// Task function used to mutate result tiles
/// Task function used to mutate evaluated lazy tiles

/// \tparam R The result type
/// \tparam T The lazy tile type
/// \tparam Op Tile operation type
/// \param tile A forwarding reference to a lazy tile
Expand Down
3 changes: 2 additions & 1 deletion src/TiledArray/expressions/mult_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ class ScalMultExpr : public BinaryExpr<ScalMultExpr<Left, Right, Scalar> > {

/// Expression constructor

/// \param arg The argument expression
/// \param left The left-hand argument expression
/// \param right The right-hand argument expression
/// \param factor The scaling factor
ScalMultExpr(const left_type& left, const right_type& right,
const scalar_type factor)
Expand Down
3 changes: 2 additions & 1 deletion src/TiledArray/expressions/scal_tsr_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ struct EngineTrait<ScalTsrEngine<DistArray<Tile, Policy>, Scalar, Result>> {

/// Scaled tensor expression engine

/// \tparam A The \c Array type
/// \tparam Array an DistArray type
/// \tparam Scalar a numeric scalar type
template <typename Array, typename Scalar, typename Result>
class ScalTsrEngine : public LeafEngine<ScalTsrEngine<Array, Scalar, Result>> {
public:
Expand Down
6 changes: 4 additions & 2 deletions src/TiledArray/expressions/scal_tsr_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ inline ScalConjTsrExpr<Array, Scalar> operator*(
/// Scaled-tensor expression factor

/// \tparam Array A `DistArray` type
/// \tparam Scalar A scalar type
/// \tparam Scalar1 A scalar type
/// \tparam Scalar2 A scalar type
/// \param expr The scaled-tensor expression object
/// \param factor The scaling factor
/// \return A scaled-tensor expression object
Expand All @@ -312,7 +313,8 @@ inline ScalConjTsrExpr<Array, mult_t<Scalar1, Scalar2> > operator*(
/// Scaled-tensor expression factor

/// \tparam Array A `DistArray` type
/// \tparam Scalar A scalar type
/// \tparam Scalar1 A scalar type
/// \tparam Scalar2 A scalar type
/// \param factor The scaling factor
/// \param expr The scaled-tensor expression object
/// \return A scaled-tensor expression object
Expand Down
1 change: 0 additions & 1 deletion src/TiledArray/expressions/tsr_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ class TsrExpr<const Array, true> : public Expr<TsrExpr<const Array, true>> {

/// \tparam Index1 An integral type
/// \tparam Index2 An integral type
/// \tparam Index The bound index types
/// \param lower_bound The lower_bound of the block
/// \param upper_bound The upper_bound of the block
template <typename Index1, typename Index2,
Expand Down
2 changes: 1 addition & 1 deletion src/TiledArray/math/linalg/conjgrad.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct ConjugateGradientSolver {
/// \param a object of type F
/// \param b RHS
/// \param x unknown
/// \param preconditioner
/// \param preconditioner the preconditioner
/// \param convergence_target The convergence target [default = -1.0]
/// \return The 2-norm of the residual, a(x) - b, divided by the number of
/// elements in the residual.
Expand Down
7 changes: 4 additions & 3 deletions src/TiledArray/math/linalg/non-distributed/cholesky.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ auto cholesky(const ContiguousTensor& A) {
* Example Usage:
*
* auto Linv = cholesky_Linv(A, ...)
* auto [L,Linv] = cholesky_Linv<decltype(A),true>(A, ...)
* auto [L,Linv] = cholesky_Linv<true>(A, ...)
*
* @tparam Array a DistArray type (i.e., @c is_array_v<Array> is true)
* @tparam RetL Whether or not to return the cholesky factor
* @tparam Both Whether or not to return the Cholesky factor
* @tparam Array the type of `A`, a DistArray type
* (i.e., @c is_array_v<Array> is true)
*
* @param[in] A Input array to be diagonalized. Must be rank-2
* @param[in] l_trange TiledRange for resulting inverse Cholesky factor.
Expand Down
24 changes: 11 additions & 13 deletions src/TiledArray/math/linalg/non-distributed/heig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

#include <TiledArray/config.h>

#include <TiledArray/math/linalg/util.h>
#include <TiledArray/math/linalg/rank-local.h>
#include <TiledArray/conversions/eigen.h>
#include <TiledArray/math/linalg/rank-local.h>
#include <TiledArray/math/linalg/util.h>

namespace TiledArray::math::linalg::non_distributed {

Expand Down Expand Up @@ -62,10 +62,7 @@ auto heig(const Array& A, TiledRange evec_trange = TiledRange()) {
world.gop.broadcast_serializable(A_eig, 0);
world.gop.broadcast_serializable(evals, 0);
if (evec_trange.rank() == 0) evec_trange = A.trange();
return std::tuple(
evals,
eigen_to_array<Array>(world, evec_trange, A_eig)
);
return std::tuple(evals, eigen_to_array<Array>(world, evec_trange, A_eig));
}

/**
Expand All @@ -81,7 +78,9 @@ auto heig(const Array& A, TiledRange evec_trange = TiledRange()) {
*
* auto [E, X] = heig(A, B, ...)
*
* @tparam Array Input array type
* @tparam ArrayA the type of @p A, i.e., an array type
* @tparam ArrayB the type of @p B, i.e., an array type
* @tparam EVecType an array type to use for returning the eigenvectors
*
* @param[in] A Input array to be diagonalized. Must be rank-2
* @param[in] B Positive-definite matrix
Expand All @@ -92,7 +91,8 @@ auto heig(const Array& A, TiledRange evec_trange = TiledRange()) {
* as std::vector and in TA format, respectively.
*/
template <typename ArrayA, typename ArrayB, typename EVecType = ArrayA>
auto heig(const ArrayA& A, const ArrayB& B, TiledRange evec_trange = TiledRange()) {
auto heig(const ArrayA& A, const ArrayB& B,
TiledRange evec_trange = TiledRange()) {
using numeric_type = typename detail::array_traits<ArrayA>::numeric_type;
(void)detail::array_traits<ArrayB>{};
World& world = A.world();
Expand All @@ -105,12 +105,10 @@ auto heig(const ArrayA& A, const ArrayB& B, TiledRange evec_trange = TiledRange(
world.gop.broadcast_serializable(A_eig, 0);
world.gop.broadcast_serializable(evals, 0);
if (evec_trange.rank() == 0) evec_trange = A.trange();
return std::tuple(
evals,
eigen_to_array<ArrayA>(A.world(), evec_trange, A_eig)
);
return std::tuple(evals,
eigen_to_array<ArrayA>(A.world(), evec_trange, A_eig));
}

} // namespace TiledArray::math::linalg
} // namespace TiledArray::math::linalg::non_distributed

#endif // TILEDARRAY_MATH_LINALG_NON_DISTRIBUTED_HEIG_H__INCLUDED
25 changes: 12 additions & 13 deletions src/TiledArray/permutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,30 @@ inline void permute_array(const Perm& perm, const Arg& arg, Result& result) {
}
}

template<typename P, typename In, typename Out, bool Inverse>
template <typename P, typename In, typename Out, bool Inverse>
void permute_n(size_t N, P p, In in, Out out, std::bool_constant<Inverse>) {
for (size_t k = 0; k < N; ++k) {
if constexpr (Inverse) {
out[*p++] = *in++;
}
else {
} else {
*out++ = in[*p++];
}
}
}

template<typename P, typename S, bool Inverse>
auto permute(const P &p, const S &s, std::bool_constant<Inverse>) {
template <typename P, typename S, bool Inverse>
auto permute(const P& p, const S& s, std::bool_constant<Inverse>) {
// using std::size;
// using std::begin;
// size_t K = size(p);
// S r(K);
// detail::permute_n(K, begin(p), begin(s), begin(r), args...);
// return r;
if (!p) return s;
if constexpr (Inverse) return p.inv()*s;
else return p*s;
if constexpr (Inverse)
return p.inv() * s;
else
return p * s;
}

} // namespace detail
Expand All @@ -124,8 +125,6 @@ auto permute(const P &p, const S &s, std::bool_constant<Inverse>) {
p1_inv = p1.inv(); // computes inverse of p1
\endcode

\note

\par
Permutation is internally represented in one-line (image) form, e.g.
\f$
Expand Down Expand Up @@ -631,14 +630,14 @@ inline std::vector<T> operator*(const Permutation& perm,
return result;
}

template<typename S>
S apply(const Permutation &p, const S &s) {
template <typename S>
S apply(const Permutation& p, const S& s) {
using detail::permute;
return permute(p, s, std::false_type{});
}

template<typename S>
S apply_inverse(const Permutation &p, const S &s) {
template <typename S>
S apply_inverse(const Permutation& p, const S& s) {
using detail::permute;
return permute(p, s, std::true_type{});
}
Expand Down
4 changes: 2 additions & 2 deletions src/TiledArray/pmap/pmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Pmap {

/// \param world The world where the tiles will be mapped
/// \param size The number of tiles to be mapped
/// \param size The number of tiles that maps to this rank
/// \param local_size The number of tiles that maps to this rank
Pmap(World& world, const size_type size, const size_type local_size = 0)
: rank_(world.rank()),
procs_(world.size()),
Expand Down Expand Up @@ -156,7 +156,7 @@ class Pmap {
/// overload this and construct Iterator with `use_pmap_advance=true`
/// if need to implement custom iteration over local indices
/// \param[in,out] value current index value on input, next value on output
/// \param[in[ increment if true, increase \p value, else decrease
/// \param[in] increment if true, increase \p value, else decrease
virtual void advance(size_type& value, bool increment) const {
if (increment)
++value;
Expand Down
38 changes: 23 additions & 15 deletions src/TiledArray/size_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,19 @@ class SizeArray {

/// Perform an element-wise binary reduction of the data of \c this and \c arg
/// by executing <tt>join_op(result, reduce_op(*this[i], arg[i]))</tt> for
/// each \c i in the index range of \c this . \c result is initialized to \c
/// identity . If HAVE_INTEL_TBB is defined the reduction will be executed in
/// an undefined order, otherwise will execute in the order of increasing \c i
/// . \tparam Arg The right-hand argument type \tparam Result The reduction
/// result type \tparam ReduceOp The binary reduction operation type \tparam
/// JoinOp The join operation type \param arg The right-hand argument \param
/// result The initial value of the reduction \param op The binary reduction
/// operation \return The reduced value
/// each \c i in the index range of \c this . \c result is initialized to
/// \c identity . If `HAVE_INTEL_TBB` is defined the reduction will be
/// executed in an undefined order, otherwise will execute in the order
/// of increasing \c i .
/// \tparam Arg The right-hand argument type
/// \tparam Result The reduction result type
/// \tparam ReduceOp The binary reduction operation type
/// \tparam JoinOp The join operation type
/// \param arg The right-hand argument
/// \param result The initial value of the reduction
/// \param op The binary reduction
/// operation
/// \return The reduced value
template <typename Arg, typename Result, typename ReduceOp, typename JoinOp>
Result reduce(const Arg* const arg, Result result, const ReduceOp& reduce_op,
const JoinOp& join_op) const {
Expand All @@ -290,13 +295,16 @@ class SizeArray {

/// Perform an element-wise unary reduction of the data by
/// executing <tt>join_op(result, reduce_op(*this[i]))</tt> for each
/// \c i in the index range of \c this . \c result is initialized to \c
/// identity . If HAVE_INTEL_TBB is defined the reduction will be executed in
/// an undefined order, otherwise will execute in the order of increasing \c i
/// . \tparam Result The reduction result type \tparam ReduceOp The binary
/// reduction operation type \tparam JoinOp The join operation type \param
/// result The initial value of the reduction \param op The unary reduction
/// operation \return The reduced value
/// \c i in the index range of \c this . \c result is initialized to
/// \c identity . If `HAVE_INTEL_TBB` is defined the reduction will be
/// executed in an undefined order, otherwise will execute in the order
/// of increasing \c i .
/// \tparam Result The reduction result type
/// \tparam ReduceOp The binary reduction operation type
/// \tparam JoinOp The join operation type
/// \param result The initial value of the reduction
/// \param op The unary reduction operation
/// \return The reduced value
template <typename Result, typename ReduceOp, typename JoinOp>
Result reduce(Result result, const ReduceOp& reduce_op,
const JoinOp& join_op) const {
Expand Down
2 changes: 1 addition & 1 deletion src/TiledArray/sparse_shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ class SparseShape {

/// Compute union of two shapes

/// \param mask The input shape, hard zeros are used to mask the output.
/// \param mask_shape The input shape, hard zeros are used to mask the output.
/// \return A shape that is masked by the mask.
SparseShape_ mask(const SparseShape_& mask_shape) const {
TA_ASSERT(!tile_norms_.empty());
Expand Down
17 changes: 8 additions & 9 deletions src/TiledArray/tensor/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ class Tensor {

/// Contract this tensor with another tensor

/// \tparam As... Template parameter pack of a tensor type
/// \tparam As Template parameter pack of a tensor type
/// \tparam V The type of \c alpha scalar
/// \param A The tensor that will be contracted with this tensor
/// \param alpha Multiply the result by this constant
Expand Down Expand Up @@ -1651,15 +1651,14 @@ class Tensor {
/// contractions. Tensor contractions that do not fit this pattern require
/// one or more tensor permutation so that the tensors fit the required
/// pattern.
/// \tparam U The left-hand tensor element type
/// \tparam AU The left-hand tensor allocator type
/// \tparam V The right-hand tensor element type
/// \tparam AV The right-hand tensor allocator type
/// \tparam As Template parameter pack of the left-hand tensor type
/// \tparam Bs Template parameter pack of the right-hand tensor type
/// \tparam W The type of the scaling factor
/// \param left The left-hand tensor that will be contracted
/// \param right The right-hand tensor that will be contracted
/// \param factor The contraction result will be scaling by this value, then
/// accumulated into \c this \param gemm_helper The *GEMM operation meta data
/// \param A The left-hand tensor that will be contracted
/// \param B The right-hand tensor that will be contracted
/// \param alpha The contraction result will be scaled by this value, then
/// accumulated into \c this
/// \param gemm_helper The *GEMM operation meta data
/// \return A reference to \c this
/// \note if this is uninitialized, i.e., if \c this->empty()==true will
/// this is equivalent to
Expand Down
Loading