• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

adc-connect / adcc / 5362537629

pending completion
5362537629

push

github

mfherbst
Bump version: 0.15.16 → 0.15.17

1487 of 2318 branches covered (64.15%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

7130 of 9470 relevant lines covered (75.29%)

191956.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.18
/libadcc/AdcMemory.cc
1
//
2
// Copyright (C) 2017 by the adcc authors
3
//
4
// This file is part of adcc.
5
//
6
// adcc is free software: you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published
8
// by the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
10
//
11
// adcc is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
//
16
// You should have received a copy of the GNU General Public License
17
// along with adcc. If not, see <http://www.gnu.org/licenses/>.
18
//
19

20
#include "AdcMemory.hh"
21
#include "exceptions.hh"
22
#include <algorithm>
23

24
// Change visibility of libtensor singletons to public
25
#pragma GCC visibility push(default)
26
#include <libtensor/core/allocator.h>
27
#include <libtensor/core/batching_policy_base.h>
28
#include <libtensor/expr/btensor/eval_btensor.h>
29
#include <libtensor/metadata.h>
30
#pragma GCC visibility pop
31

32
namespace libadcc {
33
namespace {
34
bool libtensor_has_libxm() {
2✔
35
  const std::vector<std::string>& libtensor_features = libtensor::metadata::features();
2✔
36
  const auto it =
37
        std::find(libtensor_features.begin(), libtensor_features.end(), "libxm");
2✔
38
  return it != libtensor_features.end();
4✔
39
}
2✔
40
}  // namespace
41

42
AdcMemory::AdcMemory()
153✔
43
      : m_max_block_size(0),
153✔
44
        m_allocator("none"),
153✔
45
        m_initialise_called(false),
153✔
46
        m_pagefile_directory{""} {
153✔
47
  initialise("", 16, "standard");
153✔
48

49
  // Make sure we can call initialise once more
50
  m_initialise_called = false;
153✔
51
}
153✔
52

53
void AdcMemory::initialise(std::string pagefile_directory, size_t max_block_size,
185✔
54
                           std::string allocator) {
55
  if (m_initialise_called) {
185✔
56
    throw invalid_argument("Cannot initialise AdcMemory object twice.");
×
57
  }
58

59
  m_initialise_called  = true;
185✔
60
  m_pagefile_directory = pagefile_directory;
185✔
61
  m_max_block_size     = max_block_size;
185✔
62

63
  if (allocator == "standard") {
185✔
64
  } else if (allocator == "libxm" && libtensor_has_libxm()) {
2✔
65
  } else {
66
    throw invalid_argument("A memory allocator named '" + allocator +
×
67
                           "' is not known to adcc. Perhaps it is not compiled in.");
×
68
  }
69

70
  shutdown();  // Shutdown previously initialised allocator (if any)
185✔
71
  libtensor::allocator<double>::init(allocator, pagefile_directory.c_str());
185✔
72
  m_allocator = allocator;
185✔
73

74
  // Set initial batch size ... value empirically determined to be reasonable
75
  set_contraction_batch_size(21870);
185✔
76

77
  // Enable libxm contraction backend if libxm allocator is used
78
  libtensor::expr::eval_btensor<double>::use_libxm(allocator == "libxm");
185✔
79
}
185✔
80

81
size_t AdcMemory::contraction_batch_size() const {
×
82
  return libtensor::batching_policy_base::get_batch_size();
×
83
}
84

85
void AdcMemory::set_contraction_batch_size(size_t bsize) {
185✔
86
  libtensor::batching_policy_base::set_batch_size(bsize);
185✔
87
}
185✔
88

89
void AdcMemory::shutdown() {
337✔
90
  if (m_allocator != "none") {
337✔
91
    libtensor::allocator<double>::shutdown();
184✔
92
    m_allocator = "none";
184✔
93
  }
94
}
337✔
95

96
}  // namespace libadcc
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc