QMCPACK
TraceManager Class Reference
+ Collaboration diagram for TraceManager:

Public Member Functions

 TraceManager (Communicate *comm=0)
 
TraceManagermakeClone ()
 
void transfer_state_from (const TraceManager &tm)
 
void distribute ()
 
void reset_permissions ()
 
void put (xmlNodePtr cur, bool allow_traces, std::string series_root)
 
void update_status ()
 
void screen_writes ()
 
void initialize_traces ()
 
void finalize_traces ()
 
template<int D>
Array< TraceInt, D > * checkout_int (const std::string &name, int n1=1, int n2=0, int n3=0, int n4=0)
 
template<int D>
Array< TraceInt, D > * checkout_int (const std::string &domain, const std::string &name, int n1=1, int n2=0, int n3=0, int n4=0)
 
template<int D>
Array< TraceInt, D > * checkout_int (const std::string &name, const ParticleSet &P, int n2=0, int n3=0, int n4=0)
 
template<int D>
Array< TraceReal, D > * checkout_real (const std::string &name, int n1=1, int n2=0, int n3=0, int n4=0)
 
template<int D>
Array< TraceReal, D > * checkout_real (const std::string &domain, const std::string &name, int n1=1, int n2=0, int n3=0, int n4=0)
 
template<int D>
Array< TraceReal, D > * checkout_real (const std::string &name, const ParticleSet &P, int n2=0, int n3=0, int n4=0)
 
template<int D>
Array< TraceComp, D > * checkout_complex (const std::string &name, int n1=1, int n2=0, int n3=0, int n4=0)
 
template<int D>
Array< TraceComp, D > * checkout_complex (const std::string &domain, const std::string &name, int n1=1, int n2=0, int n3=0, int n4=0)
 
template<int D>
Array< TraceComp, D > * checkout_complex (const std::string &name, const ParticleSet &P, int n2=0, int n3=0, int n4=0)
 
TraceSample< TraceInt > * get_int_trace (const std::string &name)
 
TraceSample< TraceInt > * get_int_trace (const std::string &domain, const std::string &name)
 
TraceSample< TraceInt > * get_int_trace (const ParticleSet &P, const std::string &name)
 
TraceSample< TraceReal > * get_real_trace (const std::string &name)
 
TraceSample< TraceReal > * get_real_trace (const std::string &domain, const std::string &name)
 
TraceSample< TraceReal > * get_real_trace (const ParticleSet &P, const std::string &name)
 
TraceSample< TraceComp > * get_complex_trace (const std::string &name)
 
TraceSample< TraceComp > * get_complex_trace (const std::string &domain, const std::string &name)
 
TraceSample< TraceComp > * get_complex_trace (const ParticleSet &P, const std::string &name)
 
CombinedTraceSample< TraceInt > * get_int_combined_trace (const std::string &name)
 
CombinedTraceSample< TraceInt > * get_int_combined_trace (const std::string &domain, const std::string &name)
 
CombinedTraceSample< TraceInt > * get_int_combined_trace (const ParticleSet &P, const std::string &name)
 
CombinedTraceSample< TraceReal > * get_real_combined_trace (const std::string &name)
 
CombinedTraceSample< TraceReal > * get_real_combined_trace (const std::string &domain, const std::string &name)
 
CombinedTraceSample< TraceReal > * get_real_combined_trace (const ParticleSet &P, const std::string &name)
 
CombinedTraceSample< TraceComp > * get_complex_combined_trace (const std::string &name)
 
CombinedTraceSample< TraceComp > * get_complex_combined_trace (const std::string &domain, const std::string &name)
 
CombinedTraceSample< TraceComp > * get_complex_combined_trace (const ParticleSet &P, const std::string &name)
 
void make_combined_trace (const std::string &name, std::vector< std::string > &names)
 
void make_combined_trace (const std::string &name, std::vector< std::string > &names, std::vector< TraceReal > &weights)
 
void check_clones (std::vector< TraceManager *> &clones)
 
void reset_buffers ()
 
void buffer_sample (int current_step)
 
void write_buffers (std::vector< TraceManager *> &clones, int block)
 
void open_file (std::vector< TraceManager *> &clones)
 
void close_file ()
 
void startRun (int blocks, std::vector< TraceManager *> &clones)
 
void stopRun ()
 
void startBlock (int nsteps)
 
void stopBlock ()
 
void write_summary (std::string pad=" ")
 
void user_report (std::string pad=" ")
 
void open_hdf_file (std::vector< TraceManager *> &clones)
 
void write_buffers_hdf (std::vector< TraceManager *> &clones)
 
void close_hdf_file ()
 

Public Attributes

TraceRequest request
 
bool master_copy
 
std::string default_domain
 
bool method_allows_traces
 
bool streaming_traces
 
bool writing_traces
 
int throttle
 
bool verbose
 
std::string format
 
bool hdf_format
 
std::string file_root
 
Communicatecommunicator
 
std::unique_ptr< hdf_archivehdf_file
 

Static Public Attributes

static double trace_tol = 1e-8
 

Private Attributes

TraceSamples< TraceIntint_samples
 
TraceSamples< TraceRealreal_samples
 
TraceSamples< TraceCompcomp_samples
 
TraceBuffer< TraceIntint_buffer
 
TraceBuffer< TraceRealreal_buffer
 

Detailed Description

Definition at line 1420 of file TraceManager.h.

Constructor & Destructor Documentation

◆ TraceManager()

TraceManager ( Communicate comm = 0)
inline

Definition at line 1453 of file TraceManager.h.

References qmcplusplus::comm, TraceManager::communicator, TraceManager::comp_samples, TraceManager::default_domain, TraceManager::format, TraceManager::int_buffer, TraceManager::int_samples, TraceManager::master_copy, TraceManager::real_buffer, TraceManager::real_samples, TraceManager::request, TraceManager::reset_permissions(), TraceBuffer< T >::set_samples(), TraceRequest::set_scalar_domain(), TraceBuffer< T >::set_type(), and TraceManager::throttle.

Referenced by TraceManager::makeClone().

1453  : verbose(false)
1454  {
1456  master_copy = true;
1457  communicator = comm;
1458  throttle = 1;
1459  format = "hdf";
1460  default_domain = "scalars";
1462  int_buffer.set_type("int");
1463  real_buffer.set_type("real");
1467  }
void set_samples(TraceSamples< T > &s)
TraceBuffer< TraceInt > int_buffer
TraceSamples< TraceReal > real_samples
void set_type(std::string stype)
TraceSamples< TraceInt > int_samples
TraceSamples< TraceComp > comp_samples
void set_scalar_domain(const std::string &domain)
Definition: TraceManager.h:162
TraceBuffer< TraceReal > real_buffer

Member Function Documentation

◆ buffer_sample()

void buffer_sample ( int  current_step)
inline

◆ check_clones()

void check_clones ( std::vector< TraceManager *> &  clones)
inline

Definition at line 1870 of file TraceManager.h.

References APP_ABORT, qmcplusplus::app_log(), TraceManager::int_buffer, TraceManager::real_buffer, TraceBuffer< T >::same_as(), TraceManager::verbose, TraceManager::write_summary(), and TraceManager::writing_traces.

Referenced by TraceManager::startRun().

1871  {
1872  if (writing_traces && clones.size() > 0)
1873  {
1874  if (verbose)
1875  app_log() << "TraceManager::check_clones" << std::endl;
1876  bool all_same = true;
1877  bool int_same;
1878  bool real_same;
1879  TraceManager& ref = *clones[0];
1880  for (int i = 0; i < clones.size(); ++i)
1881  {
1882  TraceManager& tm = *clones[i];
1883  int_same = tm.int_buffer.same_as(ref.int_buffer);
1884  real_same = tm.real_buffer.same_as(ref.real_buffer);
1885  all_same = all_same && int_same && real_same;
1886  }
1887  if (!all_same)
1888  {
1889  for (int i = 0; i < clones.size(); ++i)
1890  clones[i]->write_summary();
1891  APP_ABORT("TraceManager::check_clones trace buffer widths of clones do not match\n contiguous write is "
1892  "impossible\n this was first caused by clones contributing array traces from identical, but "
1893  "differently named, particlesets such as e, e2, e3 ... (fixed)\n please check the TraceManager "
1894  "summaries printed above");
1895  }
1896  }
1897  }
std::ostream & app_log()
Definition: OutputManager.h:65
TraceManager(Communicate *comm=0)
void write_summary(std::string pad=" ")
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ checkout_complex() [1/3]

Array<TraceComp, D>* checkout_complex ( const std::string &  name,
int  n1 = 1,
int  n2 = 0,
int  n3 = 0,
int  n4 = 0 
)
inline

Definition at line 1742 of file TraceManager.h.

References TraceManager::default_domain.

Referenced by BareKineticEnergy::checkoutParticleQuantities(), and qmcplusplus::TEST_CASE().

1743  {
1744  return checkout_complex<D>(default_domain, name, n1, n2, n3, n4);
1745  }

◆ checkout_complex() [2/3]

Array<TraceComp, D>* checkout_complex ( const std::string &  domain,
const std::string &  name,
int  n1 = 1,
int  n2 = 0,
int  n3 = 0,
int  n4 = 0 
)
inline

Definition at line 1747 of file TraceManager.h.

References TraceSamples< T >::checkout_array(), and TraceManager::comp_samples.

1753  {
1754  TinyVector<int, DMAX> shape(n1, n2, n3, n4);
1755  return comp_samples.checkout_array<D>(domain, name, shape);
1756  }
TraceSamples< TraceComp > comp_samples
Array< T, D > * checkout_array(const std::string &domain, const std::string &name, TinyVector< int, DMAX > shape)
Definition: TraceManager.h:784

◆ checkout_complex() [3/3]

Array<TraceComp, D>* checkout_complex ( const std::string &  name,
const ParticleSet P,
int  n2 = 0,
int  n3 = 0,
int  n4 = 0 
)
inline

Definition at line 1758 of file TraceManager.h.

References TraceSamples< T >::checkout_array(), TraceManager::comp_samples, and ParticleSet::getTotalNum().

1763  {
1764  TinyVector<int, DMAX> shape(P.getTotalNum(), n2, n3, n4);
1765  return comp_samples.checkout_array<D>(P, name, shape);
1766  }
TraceSamples< TraceComp > comp_samples
Array< T, D > * checkout_array(const std::string &domain, const std::string &name, TinyVector< int, DMAX > shape)
Definition: TraceManager.h:784

◆ checkout_int() [1/3]

Array<TraceInt, D>* checkout_int ( const std::string &  name,
int  n1 = 1,
int  n2 = 0,
int  n3 = 0,
int  n4 = 0 
)
inline

Definition at line 1684 of file TraceManager.h.

References TraceManager::default_domain.

Referenced by QMCHamiltonian::initialize_traces(), and qmcplusplus::TEST_CASE().

1685  {
1686  return checkout_int<D>(default_domain, name, n1, n2, n3, n4);
1687  }

◆ checkout_int() [2/3]

Array<TraceInt, D>* checkout_int ( const std::string &  domain,
const std::string &  name,
int  n1 = 1,
int  n2 = 0,
int  n3 = 0,
int  n4 = 0 
)
inline

Definition at line 1689 of file TraceManager.h.

References TraceSamples< T >::checkout_array(), and TraceManager::int_samples.

1695  {
1696  TinyVector<int, DMAX> shape(n1, n2, n3, n4);
1697  return int_samples.checkout_array<D>(domain, name, shape);
1698  }
TraceSamples< TraceInt > int_samples
Array< T, D > * checkout_array(const std::string &domain, const std::string &name, TinyVector< int, DMAX > shape)
Definition: TraceManager.h:784

◆ checkout_int() [3/3]

Array<TraceInt, D>* checkout_int ( const std::string &  name,
const ParticleSet P,
int  n2 = 0,
int  n3 = 0,
int  n4 = 0 
)
inline

Definition at line 1700 of file TraceManager.h.

References TraceSamples< T >::checkout_array(), ParticleSet::getTotalNum(), and TraceManager::int_samples.

1705  {
1706  TinyVector<int, DMAX> shape(P.getTotalNum(), n2, n3, n4);
1707  return int_samples.checkout_array<D>(P, name, shape);
1708  }
TraceSamples< TraceInt > int_samples
Array< T, D > * checkout_array(const std::string &domain, const std::string &name, TinyVector< int, DMAX > shape)
Definition: TraceManager.h:784

◆ checkout_real() [1/3]

◆ checkout_real() [2/3]

Array<TraceReal, D>* checkout_real ( const std::string &  domain,
const std::string &  name,
int  n1 = 1,
int  n2 = 0,
int  n3 = 0,
int  n4 = 0 
)
inline

Definition at line 1718 of file TraceManager.h.

References TraceSamples< T >::checkout_array(), and TraceManager::real_samples.

1724  {
1725  TinyVector<int, DMAX> shape(n1, n2, n3, n4);
1726  return real_samples.checkout_array<D>(domain, name, shape);
1727  }
TraceSamples< TraceReal > real_samples
Array< T, D > * checkout_array(const std::string &domain, const std::string &name, TinyVector< int, DMAX > shape)
Definition: TraceManager.h:784

◆ checkout_real() [3/3]

Array<TraceReal, D>* checkout_real ( const std::string &  name,
const ParticleSet P,
int  n2 = 0,
int  n3 = 0,
int  n4 = 0 
)
inline

Definition at line 1729 of file TraceManager.h.

References TraceSamples< T >::checkout_array(), ParticleSet::getTotalNum(), and TraceManager::real_samples.

1734  {
1735  TinyVector<int, DMAX> shape(P.getTotalNum(), n2, n3, n4);
1736  return real_samples.checkout_array<D>(P, name, shape);
1737  }
TraceSamples< TraceReal > real_samples
Array< T, D > * checkout_array(const std::string &domain, const std::string &name, TinyVector< int, DMAX > shape)
Definition: TraceManager.h:784

◆ close_file()

void close_file ( )
inline

Definition at line 1967 of file TraceManager.h.

References APP_ABORT, qmcplusplus::app_log(), TraceManager::close_hdf_file(), TraceManager::hdf_format, TraceManager::master_copy, TraceManager::verbose, and TraceManager::writing_traces.

Referenced by TraceManager::stopRun().

1968  {
1969  if (master_copy)
1970  {
1971  if (writing_traces)
1972  {
1973  if (verbose)
1974  app_log() << "TraceManager::close_file " << master_copy << std::endl;
1975  if (hdf_format)
1976  {
1977  close_hdf_file();
1978  }
1979  }
1980  }
1981  else
1982  APP_ABORT("TraceManager::close_file should not be called from non-master copy");
1983  }
std::ostream & app_log()
Definition: OutputManager.h:65
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ close_hdf_file()

void close_hdf_file ( )
inline

Definition at line 2113 of file TraceManager.h.

References TraceManager::hdf_file.

Referenced by TraceManager::close_file().

2113 { hdf_file.reset(); }
std::unique_ptr< hdf_archive > hdf_file

◆ distribute()

◆ finalize_traces()

void finalize_traces ( )
inline

Definition at line 1668 of file TraceManager.h.

References qmcplusplus::app_log(), TraceManager::comp_samples, TraceSamples< T >::finalize(), TraceManager::int_samples, TraceManager::master_copy, TraceManager::real_samples, and TraceManager::verbose.

Referenced by TraceManager::stopRun(), and QMCUpdateBase::stopRun2().

1669  {
1670  if (verbose)
1671  app_log() << "TraceManager::finalize_traces " << master_copy << std::endl;
1675  }
TraceSamples< TraceReal > real_samples
std::ostream & app_log()
Definition: OutputManager.h:65
TraceSamples< TraceInt > int_samples
TraceSamples< TraceComp > comp_samples

◆ get_complex_combined_trace() [1/3]

CombinedTraceSample<TraceComp>* get_complex_combined_trace ( const std::string &  name)
inline

Definition at line 1834 of file TraceManager.h.

References TraceManager::default_domain.

1835  {
1837  }
CombinedTraceSample< TraceComp > * get_complex_combined_trace(const std::string &name)

◆ get_complex_combined_trace() [2/3]

CombinedTraceSample<TraceComp>* get_complex_combined_trace ( const std::string &  domain,
const std::string &  name 
)
inline

Definition at line 1838 of file TraceManager.h.

References TraceManager::comp_samples, and TraceSamples< T >::get_combined_trace().

1839  {
1840  return comp_samples.get_combined_trace(domain, name);
1841  }
CombinedTraceSample< T > * get_combined_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:837
TraceSamples< TraceComp > comp_samples

◆ get_complex_combined_trace() [3/3]

CombinedTraceSample<TraceComp>* get_complex_combined_trace ( const ParticleSet P,
const std::string &  name 
)
inline

Definition at line 1842 of file TraceManager.h.

References TraceManager::comp_samples, TraceSamples< T >::get_combined_trace(), and ParticleSet::parentName().

1843  {
1844  return comp_samples.get_combined_trace(P.parentName(), name);
1845  }
CombinedTraceSample< T > * get_combined_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:837
TraceSamples< TraceComp > comp_samples

◆ get_complex_trace() [1/3]

TraceSample<TraceComp>* get_complex_trace ( const std::string &  name)
inline

Definition at line 1794 of file TraceManager.h.

References TraceManager::default_domain.

Referenced by DensityMatrices1B::getRequiredTraces().

1795  {
1796  return get_complex_trace(default_domain, name);
1797  }
TraceSample< TraceComp > * get_complex_trace(const std::string &name)

◆ get_complex_trace() [2/3]

TraceSample<TraceComp>* get_complex_trace ( const std::string &  domain,
const std::string &  name 
)
inline

Definition at line 1798 of file TraceManager.h.

References TraceManager::comp_samples, and TraceSamples< T >::get_trace().

1799  {
1800  return comp_samples.get_trace(domain, name);
1801  }
TraceSamples< TraceComp > comp_samples
TraceSample< T > * get_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:819

◆ get_complex_trace() [3/3]

TraceSample<TraceComp>* get_complex_trace ( const ParticleSet P,
const std::string &  name 
)
inline

Definition at line 1802 of file TraceManager.h.

References TraceManager::comp_samples, TraceSamples< T >::get_trace(), and ParticleSet::parentName().

1803  {
1804  return comp_samples.get_trace(P.parentName(), name);
1805  }
TraceSamples< TraceComp > comp_samples
TraceSample< T > * get_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:819

◆ get_int_combined_trace() [1/3]

CombinedTraceSample<TraceInt>* get_int_combined_trace ( const std::string &  name)
inline

Definition at line 1808 of file TraceManager.h.

References TraceManager::default_domain.

1809  {
1810  return get_int_combined_trace(default_domain, name);
1811  }
CombinedTraceSample< TraceInt > * get_int_combined_trace(const std::string &name)

◆ get_int_combined_trace() [2/3]

CombinedTraceSample<TraceInt>* get_int_combined_trace ( const std::string &  domain,
const std::string &  name 
)
inline

Definition at line 1812 of file TraceManager.h.

References TraceSamples< T >::get_combined_trace(), and TraceManager::int_samples.

1813  {
1814  return int_samples.get_combined_trace(domain, name);
1815  }
CombinedTraceSample< T > * get_combined_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:837
TraceSamples< TraceInt > int_samples

◆ get_int_combined_trace() [3/3]

CombinedTraceSample<TraceInt>* get_int_combined_trace ( const ParticleSet P,
const std::string &  name 
)
inline

Definition at line 1816 of file TraceManager.h.

References TraceSamples< T >::get_combined_trace(), TraceManager::int_samples, and ParticleSet::parentName().

1817  {
1818  return int_samples.get_combined_trace(P.parentName(), name);
1819  }
CombinedTraceSample< T > * get_combined_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:837
TraceSamples< TraceInt > int_samples

◆ get_int_trace() [1/3]

TraceSample<TraceInt>* get_int_trace ( const std::string &  name)
inline

Definition at line 1771 of file TraceManager.h.

References TraceManager::default_domain, and TraceManager::get_int_trace().

Referenced by TraceManager::get_int_trace().

1771 { return get_int_trace(default_domain, name); }
TraceSample< TraceInt > * get_int_trace(const std::string &name)

◆ get_int_trace() [2/3]

TraceSample<TraceInt>* get_int_trace ( const std::string &  domain,
const std::string &  name 
)
inline

Definition at line 1772 of file TraceManager.h.

References TraceSamples< T >::get_trace(), and TraceManager::int_samples.

1773  {
1774  return int_samples.get_trace(domain, name);
1775  }
TraceSamples< TraceInt > int_samples
TraceSample< T > * get_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:819

◆ get_int_trace() [3/3]

TraceSample<TraceInt>* get_int_trace ( const ParticleSet P,
const std::string &  name 
)
inline

Definition at line 1776 of file TraceManager.h.

References TraceSamples< T >::get_trace(), TraceManager::int_samples, and ParticleSet::parentName().

1777  {
1778  return int_samples.get_trace(P.parentName(), name);
1779  }
TraceSamples< TraceInt > int_samples
TraceSample< T > * get_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:819

◆ get_real_combined_trace() [1/3]

CombinedTraceSample<TraceReal>* get_real_combined_trace ( const std::string &  name)
inline

Definition at line 1821 of file TraceManager.h.

References TraceManager::default_domain.

Referenced by EnergyDensityEstimator::getRequiredTraces(), and DensityMatrices1B::getRequiredTraces().

1822  {
1824  }
CombinedTraceSample< TraceReal > * get_real_combined_trace(const std::string &name)

◆ get_real_combined_trace() [2/3]

CombinedTraceSample<TraceReal>* get_real_combined_trace ( const std::string &  domain,
const std::string &  name 
)
inline

Definition at line 1825 of file TraceManager.h.

References TraceSamples< T >::get_combined_trace(), and TraceManager::real_samples.

1826  {
1827  return real_samples.get_combined_trace(domain, name);
1828  }
CombinedTraceSample< T > * get_combined_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:837
TraceSamples< TraceReal > real_samples

◆ get_real_combined_trace() [3/3]

CombinedTraceSample<TraceReal>* get_real_combined_trace ( const ParticleSet P,
const std::string &  name 
)
inline

Definition at line 1829 of file TraceManager.h.

References TraceSamples< T >::get_combined_trace(), ParticleSet::parentName(), and TraceManager::real_samples.

1830  {
1831  return real_samples.get_combined_trace(P.parentName(), name);
1832  }
CombinedTraceSample< T > * get_combined_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:837
TraceSamples< TraceReal > real_samples

◆ get_real_trace() [1/3]

TraceSample<TraceReal>* get_real_trace ( const std::string &  name)
inline

Definition at line 1781 of file TraceManager.h.

References TraceManager::default_domain.

Referenced by EnergyDensityEstimator::getRequiredTraces(), and DensityMatrices1B::getRequiredTraces().

1782  {
1783  return get_real_trace(default_domain, name);
1784  }
TraceSample< TraceReal > * get_real_trace(const std::string &name)

◆ get_real_trace() [2/3]

TraceSample<TraceReal>* get_real_trace ( const std::string &  domain,
const std::string &  name 
)
inline

Definition at line 1785 of file TraceManager.h.

References TraceSamples< T >::get_trace(), and TraceManager::real_samples.

1786  {
1787  return real_samples.get_trace(domain, name);
1788  }
TraceSamples< TraceReal > real_samples
TraceSample< T > * get_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:819

◆ get_real_trace() [3/3]

TraceSample<TraceReal>* get_real_trace ( const ParticleSet P,
const std::string &  name 
)
inline

Definition at line 1789 of file TraceManager.h.

References TraceSamples< T >::get_trace(), ParticleSet::parentName(), and TraceManager::real_samples.

1790  {
1791  return real_samples.get_trace(P.parentName(), name);
1792  }
TraceSamples< TraceReal > real_samples
TraceSample< T > * get_trace(const std::string &domain, const std::string &name)
Definition: TraceManager.h:819

◆ initialize_traces()

void initialize_traces ( )
inline

Definition at line 1652 of file TraceManager.h.

References qmcplusplus::app_log(), TraceManager::int_buffer, TraceManager::master_copy, TraceBuffer< T >::order_and_resize(), TraceManager::real_buffer, TraceManager::streaming_traces, TraceManager::verbose, and TraceManager::writing_traces.

Referenced by QMCUpdateBase::startRun(), and TraceManager::startRun().

1653  {
1654  if (streaming_traces)
1655  {
1656  if (verbose)
1657  app_log() << "TraceManager::initialize_traces " << master_copy << std::endl;
1658  //organize trace samples and initialize buffers
1659  if (writing_traces)
1660  {
1663  }
1664  }
1665  }
TraceBuffer< TraceInt > int_buffer
std::ostream & app_log()
Definition: OutputManager.h:65
TraceBuffer< TraceReal > real_buffer

◆ make_combined_trace() [1/2]

void make_combined_trace ( const std::string &  name,
std::vector< std::string > &  names 
)
inline

Definition at line 1849 of file TraceManager.h.

Referenced by QMCHamiltonian::initialize_traces().

1850  {
1851  std::vector<TraceReal> weights;
1852  weights.resize(names.size());
1853  std::fill(weights.begin(), weights.end(), 1.0);
1854  make_combined_trace(name, names, weights);
1855  }
void make_combined_trace(const std::string &name, std::vector< std::string > &names)

◆ make_combined_trace() [2/2]

void make_combined_trace ( const std::string &  name,
std::vector< std::string > &  names,
std::vector< TraceReal > &  weights 
)
inline

Definition at line 1857 of file TraceManager.h.

References qmcplusplus::app_log(), TraceBuffer< T >::make_combined_trace(), TraceManager::master_copy, TraceManager::real_buffer, TraceManager::streaming_traces, and TraceManager::verbose.

1860  {
1861  if (streaming_traces)
1862  {
1863  if (verbose)
1864  app_log() << "TraceManager::make_combined_trace " << master_copy << " " << name << std::endl;
1865  real_buffer.make_combined_trace(name, names, weights);
1866  }
1867  }
std::ostream & app_log()
Definition: OutputManager.h:65
void make_combined_trace(const std::string &name, std::vector< std::string > &names, std::vector< TraceReal > &weights)
TraceBuffer< TraceReal > real_buffer

◆ makeClone()

TraceManager* makeClone ( )
inline

Definition at line 1470 of file TraceManager.h.

References APP_ABORT, qmcplusplus::app_log(), TraceManager::distribute(), TraceManager::master_copy, TraceManager::TraceManager(), TraceManager::transfer_state_from(), and TraceManager::verbose.

1471  {
1472  if (verbose)
1473  app_log() << "TraceManager::makeClone " << master_copy << std::endl;
1474  if (!master_copy)
1475  APP_ABORT("TraceManager::makeClone only the master copy should call this function");
1476  TraceManager* tm = new TraceManager();
1477  tm->master_copy = false;
1478  tm->transfer_state_from(*this);
1479  tm->distribute();
1480  return tm;
1481  }
std::ostream & app_log()
Definition: OutputManager.h:65
TraceManager(Communicate *comm=0)
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ open_file()

void open_file ( std::vector< TraceManager *> &  clones)
inline

Definition at line 1946 of file TraceManager.h.

References APP_ABORT, qmcplusplus::app_log(), TraceManager::hdf_format, TraceManager::master_copy, TraceManager::open_hdf_file(), TraceManager::verbose, and TraceManager::writing_traces.

Referenced by TraceManager::startRun().

1947  {
1948  if (master_copy)
1949  {
1950  if (writing_traces)
1951  {
1952  if (verbose)
1953  app_log() << "TraceManager::open_file " << master_copy << std::endl;
1954  if (verbose)
1955  clones[0]->write_summary();
1956  if (hdf_format)
1957  {
1958  open_hdf_file(clones);
1959  }
1960  }
1961  }
1962  else
1963  APP_ABORT("TraceManager::open_file should not be called from non-master copy");
1964  }
void open_hdf_file(std::vector< TraceManager *> &clones)
std::ostream & app_log()
Definition: OutputManager.h:65
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ open_hdf_file()

void open_hdf_file ( std::vector< TraceManager *> &  clones)
inline

Definition at line 2065 of file TraceManager.h.

References APP_ABORT, qmcplusplus::app_log(), TraceManager::communicator, TraceManager::file_root, TraceManager::hdf_file, TraceManager::int_buffer, qmcplusplus::rank, Communicate::rank(), TraceManager::real_buffer, TraceBuffer< T >::register_hdf_data(), Communicate::size(), and TraceManager::verbose.

Referenced by TraceManager::open_file().

2066  {
2067  if (clones.size() == 0)
2068  APP_ABORT("TraceManager::open_hdf_file no trace clones exist, cannot open file");
2069  int nprocs = communicator->size();
2070  int rank = communicator->rank();
2071  std::array<char, 32> ptoken;
2072  std::string file_name = file_root;
2073  if (nprocs > 1)
2074  {
2075  int length{0};
2076  if (nprocs > 10000)
2077  length = std::snprintf(ptoken.data(), ptoken.size(), ".p%05d", rank);
2078  else if (nprocs > 1000)
2079  length = std::snprintf(ptoken.data(), ptoken.size(), ".p%04d", rank);
2080  else
2081  length = std::snprintf(ptoken.data(), ptoken.size(), ".p%03d", rank);
2082  if (length < 0)
2083  throw std::runtime_error("Error generating filename");
2084  file_name.append(ptoken.data(), length);
2085  }
2086  file_name += ".traces.h5";
2087  if (verbose)
2088  app_log() << "TraceManager::open_hdf_file opening traces hdf file " << file_name << std::endl;
2089  hdf_file = std::make_unique<hdf_archive>();
2090  bool successful = hdf_file->create(file_name);
2091  if (!successful)
2092  APP_ABORT("TraceManager::open_hdf_file failed to open hdf file " + file_name);
2093  // only clones have active buffers and associated data
2094  TraceManager& tm = *clones[0];
2095  //tm.write_summary();
2096  tm.int_buffer.register_hdf_data(*hdf_file);
2097  tm.real_buffer.register_hdf_data(*hdf_file);
2098  }
int rank() const
return the rank
Definition: Communicate.h:116
std::ostream & app_log()
Definition: OutputManager.h:65
int size() const
return the number of tasks
Definition: Communicate.h:118
TraceManager(Communicate *comm=0)
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::unique_ptr< hdf_archive > hdf_file

◆ put()

void put ( xmlNodePtr  cur,
bool  allow_traces,
std::string  series_root 
)
inline

Definition at line 1519 of file TraceManager.h.

References OhmmsAttributeSet::add(), TraceRequest::allow_streams, TraceRequest::allow_writes, APP_ABORT, qmcplusplus::app_log(), TraceRequest::arrays_on, TraceManager::distribute(), TraceManager::file_root, TraceManager::format, TraceManager::hdf_format, qmcplusplus::lowerCase(), TraceManager::master_copy, TraceManager::method_allows_traces, omp_get_thread_num(), OhmmsAttributeSet::put(), putContent(), TraceManager::request, TraceRequest::request_array(), TraceRequest::request_scalar(), TraceManager::reset_permissions(), TraceRequest::scalars_on, TraceRequest::stream_all_arrays, TraceRequest::stream_all_scalars, TraceManager::streaming_traces, TraceManager::throttle, TraceManager::verbose, TraceRequest::write_all_arrays, TraceRequest::write_all_scalars, and TraceManager::writing_traces.

Referenced by qmcplusplus::TEST_CASE().

1520  {
1522  method_allows_traces = allow_traces;
1523  file_root = series_root;
1524  bool traces_requested = cur != NULL;
1525  streaming_traces = traces_requested && method_allows_traces;
1526  if (streaming_traces)
1527  {
1528  if (omp_get_thread_num() == 0)
1529  {
1530  app_log() << "\n TraceManager::put() " << master_copy << std::endl;
1531  app_log() << " traces requested : " << traces_requested << std::endl;
1532  app_log() << " method allows traces : " << method_allows_traces << std::endl;
1533  app_log() << " streaming traces : " << streaming_traces << std::endl;
1534  app_log() << std::endl;
1535  }
1536  //read trace attributes
1537  std::string writing = "yes";
1538  std::string scalar = "yes";
1539  std::string array = "yes";
1540  std::string scalar_defaults = "yes";
1541  std::string array_defaults = "yes";
1542  std::string verbose_write = "no";
1543  OhmmsAttributeSet attrib;
1544  attrib.add(writing, "write");
1545  attrib.add(scalar, "scalar");
1546  attrib.add(array, "array");
1547  attrib.add(scalar_defaults, "scalar_defaults");
1548  attrib.add(array_defaults, "array_defaults");
1549  attrib.add(format, "format");
1550  attrib.add(throttle, "throttle");
1551  attrib.add(verbose_write, "verbose");
1552  attrib.add(array, "particle"); //legacy
1553  attrib.add(array_defaults, "particle_defaults"); //legacy
1554  attrib.put(cur);
1555  writing_traces = writing == "yes";
1556  bool scalars_on = scalar == "yes";
1557  bool arrays_on = array == "yes";
1558  bool use_scalar_defaults = scalar_defaults == "yes";
1559  bool use_array_defaults = array_defaults == "yes";
1560  verbose = verbose_write == "yes";
1561  format = lowerCase(format);
1562  if (format == "hdf")
1563  {
1564  hdf_format = true;
1565  }
1566  else
1567  {
1568  APP_ABORT("TraceManager::put " + format + " is not a valid file format for traces\n valid options is: hdf");
1569  }
1570 
1571  //read scalar and array elements
1572  // each requests that certain traces be computed
1573  std::set<std::string> scalar_requests;
1574  std::set<std::string> array_requests;
1575  xmlNodePtr element = cur->children;
1576  while (element != NULL)
1577  {
1578  std::string name((const char*)element->name);
1579  if (name == "scalar_traces")
1580  {
1581  std::string defaults = "no";
1582  OhmmsAttributeSet eattrib;
1583  eattrib.add(defaults, "defaults");
1584  eattrib.put(element);
1585  use_scalar_defaults = use_scalar_defaults && defaults == "yes";
1586  if (!use_scalar_defaults)
1587  {
1588  std::vector<std::string> scalar_list;
1589  putContent(scalar_list, element);
1590  scalar_requests.insert(scalar_list.begin(), scalar_list.end());
1591  }
1592  }
1593  else if (name == "array_traces" || name == "particle_traces")
1594  {
1595  std::string defaults = "no";
1596  OhmmsAttributeSet eattrib;
1597  eattrib.add(defaults, "defaults");
1598  eattrib.put(element);
1599  use_array_defaults = use_array_defaults && defaults == "yes";
1600  if (!use_array_defaults)
1601  {
1602  std::vector<std::string> array_list;
1603  putContent(array_list, element);
1604  array_requests.insert(array_list.begin(), array_list.end());
1605  }
1606  }
1607  else if (name != "text")
1608  {
1609  APP_ABORT("TraceManager::put " + name +
1610  " is not a valid sub-element of <trace/>\n valid options are: scalar_traces, array_traces");
1611  }
1612  element = element->next;
1613  }
1614 
1616 
1617  //input user quantity requests into the traces request
1620  request.scalars_on = scalars_on;
1621  request.arrays_on = arrays_on;
1622  request.stream_all_scalars = use_scalar_defaults;
1623  request.stream_all_arrays = use_array_defaults;
1626  request.request_scalar(scalar_requests, writing_traces);
1627  request.request_array(array_requests, writing_traces);
1628 
1629  //distribute verbosity level to buffer and sample objects
1630  distribute();
1631  }
1632 
1633  //streaming_traces = false;
1634  //writing_traces = false;
1635  }
std::ostream & app_log()
Definition: OutputManager.h:65
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
std::string lowerCase(const std::string_view s)
++17
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void request_array(const std::string &name, bool write=false)
Definition: TraceManager.h:233
double scalar
Definition: Blitz.h:190
bool putContent(T &a, xmlNodePtr cur)
replaces a&#39;s value with the first "element" in the "string" returned by XMLNodeString{cur}.
Definition: libxmldefs.h:88
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42
void request_scalar(const std::string &name, bool write=false)
Definition: TraceManager.h:224

◆ reset_buffers()

void reset_buffers ( )
inline

Definition at line 1900 of file TraceManager.h.

References qmcplusplus::app_log(), TraceManager::int_buffer, TraceManager::master_copy, TraceManager::real_buffer, TraceBuffer< T >::reset(), TraceManager::verbose, and TraceManager::writing_traces.

Referenced by TraceManager::startBlock().

1901  {
1902  if (writing_traces)
1903  {
1904  if (verbose)
1905  app_log() << "TraceManager::reset_buffers " << master_copy << std::endl;
1906  int_buffer.reset();
1907  real_buffer.reset();
1908  }
1909  }
TraceBuffer< TraceInt > int_buffer
std::ostream & app_log()
Definition: OutputManager.h:65
TraceBuffer< TraceReal > real_buffer

◆ reset_permissions()

◆ screen_writes()

void screen_writes ( )
inline

◆ startBlock()

void startBlock ( int  nsteps)
inline

Definition at line 2015 of file TraceManager.h.

References qmcplusplus::app_log(), TraceManager::master_copy, TraceManager::reset_buffers(), and TraceManager::verbose.

Referenced by QMCUpdateBase::startBlock().

2016  {
2017  if (verbose)
2018  app_log() << "TraceManager::startBlock " << master_copy << std::endl;
2019  reset_buffers();
2020  }
std::ostream & app_log()
Definition: OutputManager.h:65

◆ startRun()

void startRun ( int  blocks,
std::vector< TraceManager *> &  clones 
)
inline

Definition at line 1986 of file TraceManager.h.

References APP_ABORT, qmcplusplus::app_log(), TraceManager::check_clones(), TraceManager::initialize_traces(), TraceManager::master_copy, TraceManager::open_file(), and TraceManager::verbose.

1987  {
1988  if (verbose)
1989  app_log() << "TraceManager::startRun " << master_copy << std::endl;
1990  if (master_copy)
1991  {
1993  check_clones(clones);
1994  open_file(clones);
1995  }
1996  else
1997  APP_ABORT("TraceManager::startRun should not be called from non-master copy");
1998  }
std::ostream & app_log()
Definition: OutputManager.h:65
void open_file(std::vector< TraceManager *> &clones)
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void check_clones(std::vector< TraceManager *> &clones)

◆ stopBlock()

void stopBlock ( )
inline

Definition at line 2023 of file TraceManager.h.

References qmcplusplus::app_log(), TraceManager::master_copy, and TraceManager::verbose.

Referenced by QMCUpdateBase::stopBlock().

2024  {
2025  if (verbose)
2026  app_log() << "TraceManager::stopBlock " << master_copy << std::endl;
2027  }
std::ostream & app_log()
Definition: OutputManager.h:65

◆ stopRun()

void stopRun ( )
inline

Definition at line 2001 of file TraceManager.h.

References APP_ABORT, qmcplusplus::app_log(), TraceManager::close_file(), TraceManager::finalize_traces(), TraceManager::master_copy, and TraceManager::verbose.

2002  {
2003  if (verbose)
2004  app_log() << "TraceManager::stopRun " << master_copy << std::endl;
2005  if (master_copy)
2006  {
2007  close_file();
2008  finalize_traces();
2009  }
2010  else
2011  APP_ABORT("TraceManager::stopRun should not be called from non-master copy");
2012  }
std::ostream & app_log()
Definition: OutputManager.h:65
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ transfer_state_from()

void transfer_state_from ( const TraceManager tm)
inline

Definition at line 1484 of file TraceManager.h.

References TraceManager::default_domain, TraceManager::format, TraceManager::hdf_format, TraceManager::method_allows_traces, TraceManager::request, TraceManager::streaming_traces, TraceManager::throttle, TraceManager::verbose, and TraceManager::writing_traces.

Referenced by TraceManager::makeClone().

1485  {
1486  method_allows_traces = tm.method_allows_traces;
1487  request = tm.request;
1488  streaming_traces = tm.streaming_traces;
1489  writing_traces = tm.writing_traces;
1490  throttle = tm.throttle;
1491  verbose = tm.verbose;
1492  format = tm.format;
1493  hdf_format = tm.hdf_format;
1494  default_domain = tm.default_domain;
1495  }

◆ update_status()

◆ user_report()

void user_report ( std::string  pad = "  ")
inline

Definition at line 2048 of file TraceManager.h.

References qmcplusplus::app_log(), TraceManager::int_buffer, TraceManager::real_buffer, TraceRequest::report(), TraceManager::request, and TraceBuffer< T >::user_report().

Referenced by QMCHamiltonian::initialize_traces().

2049  {
2050  std::string pad2 = pad + " ";
2051  std::string pad3 = pad2 + " ";
2052  app_log() << std::endl;
2053  app_log() << pad << "Traces report" << std::endl;
2054  request.report();
2055  app_log() << pad2 << "Type and domain breakdown of streaming quantities:" << std::endl;
2056  std::set<std::string>::iterator req;
2057  int_buffer.user_report(pad3);
2058  real_buffer.user_report(pad3);
2059  app_log() << std::endl;
2060  //if(verbose)
2061  // write_summary(pad);
2062  }
TraceBuffer< TraceInt > int_buffer
std::ostream & app_log()
Definition: OutputManager.h:65
void user_report(const std::string &pad=" ")
TraceBuffer< TraceReal > real_buffer

◆ write_buffers()

void write_buffers ( std::vector< TraceManager *> &  clones,
int  block 
)
inline

Definition at line 1926 of file TraceManager.h.

References APP_ABORT, qmcplusplus::app_log(), TraceManager::hdf_format, TraceManager::master_copy, TraceManager::verbose, TraceManager::write_buffers_hdf(), and TraceManager::writing_traces.

1927  {
1928  if (master_copy)
1929  {
1930  if (writing_traces)
1931  {
1932  //double tstart = MPI_Wtime();
1933  if (verbose)
1934  app_log() << "TraceManager::write_buffers " << master_copy << std::endl;
1935  if (hdf_format)
1936  {
1937  write_buffers_hdf(clones);
1938  }
1939  }
1940  }
1941  else
1942  APP_ABORT("TraceManager::write_buffers should not be called from non-master copy");
1943  }
std::ostream & app_log()
Definition: OutputManager.h:65
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void write_buffers_hdf(std::vector< TraceManager *> &clones)

◆ write_buffers_hdf()

void write_buffers_hdf ( std::vector< TraceManager *> &  clones)
inline

Definition at line 2101 of file TraceManager.h.

References qmcplusplus::app_log(), TraceManager::hdf_file, TraceBuffer< T >::hdf_file_pointer, TraceManager::int_buffer, TraceManager::master_copy, TraceManager::real_buffer, TraceManager::verbose, and TraceBuffer< T >::write_hdf().

Referenced by TraceManager::write_buffers().

2102  {
2103  if (verbose)
2104  app_log() << "TraceManager::write_buffers_hdf " << master_copy << std::endl;
2105  for (int ip = 0; ip < clones.size(); ++ip)
2106  {
2107  TraceManager& tm = *clones[ip];
2108  tm.int_buffer.write_hdf(*hdf_file, int_buffer.hdf_file_pointer);
2109  tm.real_buffer.write_hdf(*hdf_file, real_buffer.hdf_file_pointer);
2110  }
2111  }
TraceBuffer< TraceInt > int_buffer
std::ostream & app_log()
Definition: OutputManager.h:65
TraceManager(Communicate *comm=0)
std::unique_ptr< hdf_archive > hdf_file
TraceBuffer< TraceReal > real_buffer

◆ write_summary()

void write_summary ( std::string  pad = "  ")
inline

Definition at line 2030 of file TraceManager.h.

References qmcplusplus::app_log(), TraceManager::default_domain, TraceManager::format, TraceManager::hdf_format, TraceManager::int_buffer, TraceManager::master_copy, TraceManager::method_allows_traces, TraceManager::real_buffer, TraceManager::streaming_traces, TraceBuffer< T >::write_summary(), and TraceManager::writing_traces.

Referenced by TraceManager::check_clones().

2031  {
2032  std::string pad2 = pad + " ";
2033  app_log() << std::endl;
2034  app_log() << pad << "TraceManager (detailed summary)" << std::endl;
2035  app_log() << pad2 << "master_copy = " << master_copy << std::endl;
2036  app_log() << pad2 << "method_allows_traces = " << method_allows_traces << std::endl;
2037  app_log() << pad2 << "streaming_traces = " << streaming_traces << std::endl;
2038  app_log() << pad2 << "writing_traces = " << writing_traces << std::endl;
2039  app_log() << pad2 << "format = " << format << std::endl;
2040  app_log() << pad2 << "hdf format = " << hdf_format << std::endl;
2041  app_log() << pad2 << "default_domain = " << default_domain << std::endl;
2042  int_buffer.write_summary(pad2);
2043  real_buffer.write_summary(pad2);
2044  app_log() << pad << "end TraceManager" << std::endl;
2045  }
TraceBuffer< TraceInt > int_buffer
std::ostream & app_log()
Definition: OutputManager.h:65
void write_summary(std::string pad=" ")
TraceBuffer< TraceReal > real_buffer

Member Data Documentation

◆ communicator

Communicate* communicator

Definition at line 1450 of file TraceManager.h.

Referenced by TraceManager::open_hdf_file(), and TraceManager::TraceManager().

◆ comp_samples

◆ default_domain

◆ file_root

std::string file_root

Definition at line 1449 of file TraceManager.h.

Referenced by TraceManager::open_hdf_file(), and TraceManager::put().

◆ format

◆ hdf_file

std::unique_ptr<hdf_archive> hdf_file

◆ hdf_format

◆ int_buffer

◆ int_samples

◆ master_copy

◆ method_allows_traces

◆ real_buffer

◆ real_samples

◆ request

◆ streaming_traces

◆ throttle

◆ trace_tol

◆ verbose

◆ writing_traces


The documentation for this class was generated from the following files: