7 #include <boost/preprocessor/tuple/to_seq.hpp> 8 #include <boost/preprocessor/seq/for_each.hpp> 10 #include <alps/config.hpp> 14 #define ALPS_ACCUMULATOR_VALUE_TYPES_SEQ BOOST_PP_TUPLE_TO_SEQ(ALPS_ACCUMULATOR_VALUE_TYPES_SIZE, (ALPS_ACCUMULATOR_VALUE_TYPES)) 17 namespace accumulators {
24 template<
typename T,
typename B>
26 throw std::runtime_error(
"No values can be added to a result" +
ALPS_STACKTRACE);
29 template<
typename T,
typename B>
32 throw std::logic_error(
"Attempt to save an empty result" +
ALPS_STACKTRACE);
34 ar[
"count"] = m_count;
37 template<
typename T,
typename B>
42 throw std::runtime_error(
"Malformed archive containing an empty result" 48 template<
typename T,
typename B>
53 template<
typename T,
typename B>
58 #define ALPS_ACCUMULATOR_INST_COUNT_RESULT(r, data, T) \ 59 template class Result<T, count_tag, ResultBase<T>>; 66 template<typename T, typename B>
69 throw std::logic_error(
"Attempt to save an empty accumulator" +
ALPS_STACKTRACE);
71 ar[
"count"] = m_count;
74 template<
typename T,
typename B>
79 throw std::runtime_error(
"Malformed archive containing an empty accumulator" 85 template<
typename T,
typename B>
91 template<
typename T,
typename B>
96 if (comm.
rank() == root)
97 alps::alps_mpi::reduce(comm, m_count, m_count, std::plus<count_type>(), root);
102 template<
typename T,
typename B>
107 if (comm.
rank() == root)
108 throw std::runtime_error(
"A const object cannot be root" +
ALPS_STACKTRACE);
110 alps::alps_mpi::reduce(comm, m_count, std::plus<count_type>(), root);
114 #define ALPS_ACCUMULATOR_INST_COUNT_ACC(r, data, T) \ 115 template class Accumulator<T, count_tag, AccumulatorBase<T>>; void load(archive &ar, std::string const &path, T &value, std::vector< std::size_t > chunk=std::vector< std::size_t >(), std::vector< std::size_t >=std::vector< std::size_t >())
bool is_data(std::string path) const
count_type< T >::type count_type
#define ALPS_ACCUMULATOR_VALUE_TYPES_SEQ
Encapsulation of an MPI communicator and some communicator-related operations.
void reset(accumulator_wrapper &arg)
#define ALPS_ACCUMULATOR_INST_COUNT_ACC(r, data, T)
int rank() const
Returns process rank in this communicator.
count_type< T >::type count_type
#define ALPS_ACCUMULATOR_INST_COUNT_RESULT(r, data, T)
void save(archive &ar, std::string const &path, T const &value, std::vector< std::size_t >=std::vector< std::size_t >(), std::vector< std::size_t > chunk=std::vector< std::size_t >(), std::vector< std::size_t >=std::vector< std::size_t >())