13 #ifndef QMCPLUSPLUS_WALKERLOGBUFFER_H 14 #define QMCPLUSPLUS_WALKERLOGBUFFER_H 21 #include <unordered_set> 32 using Real = OHMMS_PRECISION_FULL;
33 using Comp = std::complex<Real>;
90 for (
size_t d = 0; d <
DMAX; ++d)
156 throw std::runtime_error(
157 "WalkerLogBuffer quantity_index has not been moved through all quantities prior during collect() call.");
166 inline void collect(
const std::string& name,
const T& value)
184 buffer(irow, wqi.buffer_start) = value;
193 size_t n1 = arr.
size(0);
197 throw std::runtime_error(
"WalkerLogBuffer::collect Only arrays up to dimension 4 are currently supported.");
221 for (
size_t n = 0;
n < arr1d.size(); ++
n)
222 buffer(irow, wqi.buffer_start +
n) = arr1d[
n];
229 inline void collect(
const std::string& name,
Array<std::complex<T>, D> arr)
231 size_t n1 = arr.size(0);
235 throw std::runtime_error(
"WalkerLogBuffer::collect Only arrays up to dimension 4 are currently supported.");
258 auto& arr1d = arr.storage();
260 for (
size_t i = 0; i < arr1d.size(); ++i)
274 auto& other_buffer = other.
buffer;
284 throw std::runtime_error(
"WalkerLogBuffer::add_row Row sizes must match.");
289 buffer(ib, j) = other_buffer(i, j);
296 std::string pad2 = pad +
" ";
297 std::string pad3 = pad2 +
" ";
299 app_log() << pad <<
"WalkerLogBuffer(" <<
label <<
")" << std::endl;
305 app_log() << pad2 <<
"quantity " <<
n <<
": " << wqi.dimension <<
" " << wqi.size <<
" " << wqi.unit_size
306 <<
" " << wqi.buffer_start <<
" " << wqi.buffer_end <<
" (" << wqi.name <<
")" << std::endl;
308 app_log() << pad <<
"end WalkerLogBuffer(" <<
label <<
")" << std::endl;
316 f.
push(
"data_layout");
320 f.
write(wqi.dimension,
"dimension");
321 f.
write(wqi.shape,
"shape");
322 f.
write(wqi.size,
"size");
323 f.
write(wqi.unit_size,
"unit_size");
324 f.
write(wqi.buffer_start,
"index_start");
325 f.
write(wqi.buffer_end,
"index_end");
331 throw std::runtime_error(
"WalkerLogBuffer(" +
label +
332 ")::register_hdf_data() some hdf groups are still open at the end of registration");
365 throw std::runtime_error(
"WalkerLogBuffer::reset_rowsize row_size (number of columns) should only be changed " 366 "during growth of the first row.");
371 throw std::runtime_error(
372 "WalkerLogBuffer::reset_rowsize buffer should contain only a single row upon completion.");
374 throw std::runtime_error(
"WalkerLogBuffer::reset_rowsize length of buffer row should match the requested " 375 "row_size following the reset/udpate.");
384 throw std::runtime_error(
"WalkerLogBuffer::makeNewRow Cannot make a new row of size zero.");
393 extern template class WalkerLogBuffer<WLog::Int>;
394 extern template class WalkerLogBuffer<WLog::Real>;
void collect(const std::string &name, Array< T, D > arr)
collect data for a single walker quantity of array type into the current buffer row ...
void writeSummary(std::string pad=" ")
write a summary of quantities in the buffer
bool first_collect
marks first WalkerLogCollector::collect() call
Array< T, 2 > buffer
the walker data buffer itself
size_t quantity_index
index of current quantity during WalkerLogCollector::collect()
void addRow(WalkerLogBuffer< T > other, size_t i)
add a data row from another buffer to this one
WalkerQuantityInfo(const std::string &name_, size_t unit_size_, size_t buffer_start_, size_t n1=1, size_t n2=0, size_t n3=0, size_t n4=0)
void write(T &data, const std::string &aname)
write the data to the group aname and check status runtime error is issued on I/O error ...
bool h5d_append(hid_t grp, const std::string &aname, hsize_t ¤t, hsize_t ndims, const hsize_t *const dims, const T *const first, hsize_t chunk_size=1, hid_t xfer_plist=H5P_DEFAULT)
helper functions for EinsplineSetBuilder
hid_t top() const
return the top of the group stack
bool open_groups()
check if any groups are open group stack will have entries if so
Data buffer for walker log quantities.
void collect(const std::string &name, const T &value)
collect data for a single walker quantity of scalar type into the current buffer row ...
TinyVector< size_t, DMAX > shape
array shape
size_t unit_size
size of 1 unit of data
void collect(const std::string &name, Array< std::complex< T >, D > arr)
collect data for a single walker quantity of complex array type into the current buffer row ...
OHMMS_PRECISION_FULL Real
Record for an individual walker quantity being logd.
std::string name
quantity name
void writeHDF(hdf_archive &f, hsize_t &file_pointer)
write the buffer data into the HDF file
void resize(const std::array< SIZET, D > &dims)
Resize the container.
std::string label
label for this data in HDF file
std::vector< WalkerQuantityInfo > quantity_info
buffer row location data for each walker quantity used to populate "data_layout" field in HDF file ...
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
size_t buffer_end
end range in buffer row
bool sameAs(const WalkerLogBuffer< T > &ref)
compare row size of this buffer to another one
size_t nrows()
current number of rows in the data buffer
std::complex< Real > Comp
void push(const std::string &gname, bool createit=true)
push a group to the group stack
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
void resetCollect()
reset member variables at end of each WalkerLogCollector::collect() call
void registerHDFData(hdf_archive &f)
write the data_layout for all walker quantities in the HDF file
void resetBuffer()
resize the buffer to zero
Basic data types for walker log data.
void writeHDF(hdf_archive &f)
write the buffer data into the HDF file
size_t walker_data_size
total size of walker data stored in a buffer row
void resetRowSize(size_t row_size)
make space as quantities are added to the buffer for the first time
size_t dimension
array dimension
void makeNewRow()
allocate a full new row at the end of the buffer
size_t ncols()
current number of columns in the data buffer (row size)
hsize_t hdf_file_pointer
HDF file pointer.
size_t buffer_start
starting row index in buffer