Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
01fe6d5
for rank==1 Range and other classes accessor(integers...) and accesso…
evaleev Mar 7, 2023
4d2c714
bump BTAS tag to pull in https://github.com/ValeevGroup/BTAS/pull/150
evaleev Mar 7, 2023
0efdb71
[unit] speed up tensor_view_suite
evaleev Mar 7, 2023
c6ea5d7
amended 8ec88b1baf6af2d05d219f0641216613c41e63fe
evaleev Mar 7, 2023
c5a7a45
[unit] CP use multiple tiles in rank mode + cleanup
evaleev Mar 7, 2023
6833b61
dox++
evaleev Mar 9, 2023
9f9f6a0
hush BOOST_TEST_CONTEXT-related warning
evaleev Mar 9, 2023
bddf447
bump Boost tag to get rid of all uses of std::rand in it via https://…
evaleev Mar 9, 2023
094db42
copied MPQC's thread_specific and TSPool into TA
evaleev Mar 9, 2023
ac2658a
introduced TiledArray::{rand,drand,srand}
evaleev Mar 9, 2023
241d1c6
[unit] tensor_view_suite uses TA::rand instead of std's random facili…
evaleev Mar 9, 2023
cfb60c0
can control (host) executor used by DistArray::{init_elements,init_ti…
evaleev Mar 9, 2023
9b63267
[unit] mixed_expressions_suite uses DistArray::fill_random instead of…
evaleev Mar 9, 2023
5c20496
[unit] cp_suite uses TA::compute_trange1 instead of hand-rolled equiv…
evaleev Mar 9, 2023
55a939a
[unit] cp_suite uses TA's random facilities
evaleev Mar 9, 2023
34c0064
CP_ALS cleanup: converged_num is integer and its values are sanity-ch…
evaleev Mar 9, 2023
dbf2d76
Tensor: operator<< is batch-aware + method {operator[],operator(),at_…
evaleev Mar 9, 2023
4dc0a33
SparseShapeFixture resets default_threshold to its value at the const…
evaleev Mar 9, 2023
cc16fa5
einsum tiny cleanup
evaleev Mar 9, 2023
75a97df
CP_ALS::check_fit cleanup
evaleev Mar 9, 2023
9c2a18d
Merge pull request #394 from ValeevGroup/evaleev/feature/reentrant-rand
evaleev Mar 9, 2023
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 INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Both methods are supported. However, for most users we _strongly_ recommend to b
- Boost.Container: header-only
- Boost.Test: header-only or (optionally) as a compiled library, *only used for unit testing*
- Boost.Range: header-only, *only used for unit testing*
- [BTAS](http://github.com/ValeevGroup/BTAS), tag 2917aa21465a93ae6f399874f247b5fe31d6b693 . If usable BTAS installation is not found, TiledArray will download and compile
- [BTAS](http://github.com/ValeevGroup/BTAS), tag 6fcb6451bc7ca46a00534a30c51dc5c230c39ac3 . If usable BTAS installation is not found, TiledArray will download and compile
BTAS from source. *This is the recommended way to compile BTAS for all users*.
- [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag 0b44ef319643cb9721fbe17d294987c146e6460e .
Only the MADworld runtime and BLAS/LAPACK C API component of MADNESS is used by TiledArray.
Expand Down
4 changes: 2 additions & 2 deletions external/versions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 29a2bf3d3c2670c608b7bfdf2299d76fbc20e041)
set(TA_TRACKED_MADNESS_VERSION 0.10.1)
set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1)

set(TA_TRACKED_BTAS_TAG 2917aa21465a93ae6f399874f247b5fe31d6b693)
set(TA_TRACKED_BTAS_PREVIOUS_TAG fba66ad9881ab29ea8df49ac6a6006cab3fb3ce5)
set(TA_TRACKED_BTAS_TAG 6fcb6451bc7ca46a00534a30c51dc5c230c39ac3)
set(TA_TRACKED_BTAS_PREVIOUS_TAG 474ddc095cbea12a1d28aca5435703dd9f69b166)

set(TA_TRACKED_LIBRETT_TAG 68abe31a9ec6fd2fd9ffbcd874daa80457f947da)
set(TA_TRACKED_LIBRETT_PREVIOUS_TAG 7e27ac766a9038df6aa05613784a54a036c4b796)
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ TiledArray/util/initializer_list.h
TiledArray/util/logger.h
TiledArray/util/ptr_registry.cpp
TiledArray/util/ptr_registry.h
TiledArray/util/random.cpp
TiledArray/util/random.h
TiledArray/util/singleton.h
TiledArray/util/threads.h
TiledArray/util/threads.cpp
TiledArray/util/thread_specific.h
TiledArray/util/time.h
TiledArray/util/vector.h
)
Expand Down
68 changes: 48 additions & 20 deletions src/TiledArray/block_range.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@

namespace TiledArray {

/// Range that references a subblock of another range
/// a Range that references a subblock of another Range
class BlockRange : public Range {
private:
/// datavec_ contains same data as if this were an ordinary Range, except:
/// - stride describes the host range
/// - offset_ corrects ordinals so that the first element in this (sub)Range
/// has ordinal of zero ...
/// - block_offset_ is the distance from the first element of this Range to
/// the first element of the host Range
using Range::datavec_;
using Range::offset_;
using Range::rank_;
Expand Down Expand Up @@ -300,37 +306,59 @@ class BlockRange : public Range {
init<std::initializer_list<std::initializer_list<Index>>>(range, bounds);
}

/// calculate the ordinal index of \c i
/// Converts coordinate index \c i to its ordinal index in the host Range

/// Convert a coordinate index to an ordinal index.
/// \tparam Index An integral range type
/// \param index The index to be converted to an ordinal index
/// \return The ordinal index of \c index
/// \param index The index to be converted to the ordinal index
/// \return The ordinal index of \c index in the host Range
/// \throw When \c index is not included in this range.
template <typename Index, typename std::enable_if_t<
detail::is_integral_range_v<Index>>* = nullptr>
template <typename Index,
typename std::enable_if_t<
detail::is_integral_sized_range_v<Index>>* = nullptr>
ordinal_type ordinal(const Index& index) const {
return Range::ordinal(index);
}

template <typename... Index,
typename std::enable_if<(sizeof...(Index) > 1ul)>::type* = nullptr>
/// Converts coordinate index \c i to its ordinal index in the host Range

/// \tparam Index An integral range type
/// \param index The index to be converted to the ordinal index
/// \return The ordinal index of \c index in the host Range
/// \throw When \c index is not included in this range.
template <typename Integer,
typename std::enable_if_t<std::is_integral_v<Integer>>* = nullptr>
ordinal_type ordinal(const std::initializer_list<Integer>& index) const {
return Range::ordinal(index);
}

/// Converts coordinate index \c i to its ordinal index in the host Range

/// \tparam Index An integral range type
/// \param index The index to be converted to the ordinal index
/// \return The ordinal index of \c index in the host Range
/// \throw When \c index is not included in this range.
template <
typename... Index,
typename std::enable_if_t<(sizeof...(Index) > 1ul) &&
(std::is_integral_v<Index> && ...)>* = nullptr>
ordinal_type ordinal(const Index&... index) const {
return Range::ordinal(index...);
}

/// calculate the coordinate index of the ordinal index, \c index.
/// Converts the ordinal index within this block range to the ordinal index of
/// the host range

/// Convert an ordinal index to a coordinate index.
/// \param index Ordinal index
/// \return The index of the ordinal index
/// \warning this overloads base method that did not perform any conversion
/// of \p ord
/// \param index the ordinal index for the host Range
/// \return The ordinal index in the
/// \throw TiledArray::Exception When \c index is not included in this range
ordinal_type ordinal(ordinal_type index) const {
// Check that index is contained by range.
TA_ASSERT(includes(index));
ordinal_type ordinal(ordinal_type ord) const {
// Check that ord is contained by this range.
TA_ASSERT(Range::includes_ordinal(ord));

// Construct result coordinate index object and allocate its memory.
ordinal_type result = 0ul;
ordinal_type host_ord = 0ul;

// Get pointers to the data
const auto* MADNESS_RESTRICT const size = extent_data();
Expand All @@ -342,11 +370,11 @@ class BlockRange : public Range {
const auto stride_i = stride[i];

// Compute result index element i
result += (index % size_i) * stride_i;
index /= size_i;
host_ord += (ord % size_i) * stride_i;
ord /= size_i;
}

return result + block_offset_ - offset_;
return host_ord + block_offset_ - offset_;
}

/// Resize of block range is not supported
Expand Down
8 changes: 3 additions & 5 deletions src/TiledArray/conversions/eigen.h
Original file line number Diff line number Diff line change
Expand Up @@ -963,10 +963,10 @@ DistArray_ eigen_tensor_to_array(
/// replicated TiledArray::DistArray. Usage:
/// \code
/// TiledArray::TArrayD
/// array(world, trange);
/// array(world, trange_3d);
/// // Set tiles of array ...
///
/// auto t = array_to_eigen_tensor(array);
/// auto t = array_to_eigen_tensor<Eigen::Tensor<double, 3>(array);
/// \endcode
/// \tparam Tile the tile type of \c src
/// \tparam Policy the policy type of \c src
Expand All @@ -980,13 +980,11 @@ DistArray_ eigen_tensor_to_array(
/// create the Eigen::Tensor on every rank (this requires
/// that \c src.is_replicated()==true )
/// \return Eigen::Tensor object containing the data of \c src , if my rank
/// equals
/// \c target_rank or \c target_rank==-1 ,
/// equals \c target_rank or \c target_rank==-1 ,
/// default-initialized Eigen::Tensor otherwise.
template <typename Tensor, typename Tile, typename Policy>
Tensor array_to_eigen_tensor(const TiledArray::DistArray<Tile, Policy>& src,
int target_rank = -1) {

TA_ASSERT(src.tiles_range().rank() == Tensor::NumDimensions);

// Test preconditions
Expand Down
35 changes: 18 additions & 17 deletions src/TiledArray/conversions/foreach.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,13 @@ inline std::
int task_count = 0;
auto op_shared_handle = make_op_shared_handle(std::forward<Op>(op));
const auto task = [op_shared_handle, &counter, &tile_norms](
const ordinal_type index,
const ordinal_type ord,
const_if_t<not inplace, arg_value_type>& arg_tile,
const ArgTiles&... arg_tiles) -> result_value_type {
op_helper<inplace, result_value_type> op_caller;
auto result_tile = op_caller(std::move(op_shared_handle), tile_norms[index],
arg_tile, arg_tiles...);
auto result_tile =
op_caller(std::move(op_shared_handle), tile_norms.at_ordinal(ord),
arg_tile, arg_tiles...);
++counter;
return result_tile;
};
Expand All @@ -304,32 +305,32 @@ inline std::
switch (shape_reduction) {
case ShapeReductionMethod::Intersect:
// Get local tile index iterator
for (auto index : *(arg.pmap())) {
if (is_zero_intersection({arg.is_zero(index), args.is_zero(index)...}))
for (auto ord : *(arg.pmap())) {
if (is_zero_intersection({arg.is_zero(ord), args.is_zero(ord)...}))
continue;
auto result_tile = world.taskq.add(task, index, arg.find_local(index),
args.find(index)...);
auto result_tile =
world.taskq.add(task, ord, arg.find_local(ord), args.find(ord)...);
++task_count;
tiles.emplace_back(index, std::move(result_tile));
tiles.emplace_back(ord, std::move(result_tile));
if (op_returns_void) // if Op does not evaluate norms, use the (scaled)
// norms of the first arg
tile_norms[index] = arg_shape_data[index];
tile_norms.at_ordinal(ord) = arg_shape_data.at_ordinal(ord);
}
break;
case ShapeReductionMethod::Union:
// Get local tile index iterator
for (auto index : *(arg.pmap())) {
if (is_zero_union({arg.is_zero(index), args.is_zero(index)...}))
continue;
for (auto ord : *(arg.pmap())) {
if (is_zero_union({arg.is_zero(ord), args.is_zero(ord)...})) continue;
auto result_tile =
world.taskq.add(task, index, detail::get_sparse_tile(index, arg),
detail::get_sparse_tile(index, args)...);
world.taskq.add(task, ord, detail::get_sparse_tile(ord, arg),
detail::get_sparse_tile(ord, args)...);
++task_count;
tiles.emplace_back(index, std::move(result_tile));
tiles.emplace_back(ord, std::move(result_tile));
if (op_returns_void) // if Op does not evaluate norms, find max
// (scaled) norms of all args
tile_norms[index] =
std::max({arg_shape_data[index], args.shape().data()[index]...});
tile_norms.at_ordinal(ord) =
std::max({arg_shape_data.at_ordinal(ord),
args.shape().data().at_ordinal(ord)...});
}
break;
default:
Expand Down
Loading