-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
140 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,10 @@ | |
// This file is distributed under the University of Illinois/NCSA Open Source License. | ||
// See LICENSE file in top directory for details. | ||
// | ||
// Copyright (c) 2024 QMCPACK developers. | ||
// Copyright (c) 2025 QMCPACK developers. | ||
// | ||
// File developed by: Ye Luo, [email protected], Argonne National Laboratory | ||
// Peter W. Doak, [email protected], Oak Ridge National Laboratory | ||
// | ||
// File created by: Ye Luo, [email protected], Argonne National Laboratory | ||
////////////////////////////////////////////////////////////////////////////////////// | ||
|
@@ -15,6 +16,43 @@ | |
namespace qmcplusplus | ||
{ | ||
|
||
template<typename T> | ||
WalkerLogBuffer<T>::WalkerLogBuffer() | ||
: walker_log_buffer_timers_(getGlobalTimerManager(), create_names(my_name_), timer_level_medium) | ||
{ | ||
label = "?"; | ||
first_collect = true; | ||
walker_data_size = 0; | ||
quantity_index = 0; | ||
resetBuffer(); | ||
} | ||
|
||
/// collect data for a single walker quantity of scalar type into the current buffer row | ||
template<typename T> | ||
void WalkerLogBuffer<T>::collect(const std::string& name, const T& value) | ||
{ | ||
ScopedTimer timer(walker_log_buffer_timers_[Timer::COLLECT]); | ||
|
||
size_t irow = 0; | ||
if (first_collect) | ||
{ // cache walker quantity info on first collect | ||
WalkerQuantityInfo wqi_(name, 1, walker_data_size); | ||
quantity_info.push_back(wqi_); | ||
walker_data_size = wqi_.buffer_end; | ||
resetRowSize(walker_data_size); | ||
} | ||
else | ||
{ // make a new buffer row if needed | ||
if (quantity_index == 0) | ||
makeNewRow(); | ||
irow = buffer.size(0) - 1; | ||
} | ||
// place the scalar walker quantity into the current buffer row | ||
auto& wqi = quantity_info[quantity_index]; | ||
buffer(irow, wqi.buffer_start) = value; | ||
quantity_index++; | ||
} | ||
|
||
template class WalkerLogBuffer<WLog::Int>; | ||
template class WalkerLogBuffer<WLog::Real>; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// This file is distributed under the University of Illinois/NCSA Open Source License. | ||
// See LICENSE file in top directory for details. | ||
// | ||
// Copyright (c) 2024 QMCPACK developers. | ||
// Copyright (c) 2025 QMCPACK developers. | ||
// | ||
// File developed by: Jaron T. Krogel, [email protected], Oak Ridge National Laboratory | ||
// | ||
|
@@ -15,16 +15,14 @@ | |
|
||
|
||
#include <Configuration.h> | ||
#include <unordered_set> | ||
#include "OhmmsPETE/OhmmsArray.h" | ||
#include "hdf/hdf_archive.h" | ||
|
||
#include <unordered_set> | ||
|
||
#include "Utilities/TimerManager.h" | ||
|
||
namespace qmcplusplus | ||
{ | ||
|
||
|
||
/// Basic data types for walker log data | ||
struct WLog | ||
{ | ||
|
@@ -119,6 +117,27 @@ class WalkerLogBuffer | |
hsize_t hdf_file_pointer; | ||
|
||
private: | ||
static constexpr std::string_view my_name_{"WalkerLogBuffer"}; | ||
enum Timer | ||
{ | ||
COLLECT = 0, | ||
ADD_ROW, | ||
WRITE, | ||
RESET, | ||
MAKE_NEW_ROW | ||
}; | ||
static constexpr std::array<std::string_view, 5> suffixes_{"collect", "add_row", "write", "reset", "make_new_row"}; | ||
static TimerNameList_t<Timer> create_names(const std::string_view& my_name) | ||
{ | ||
TimerNameList_t<Timer> timer_names; | ||
using namespace std::string_literals; | ||
std::string prefix{"WalkerLog:"s + std::string{my_name} + "::"s}; | ||
for (std::size_t i = 0; i < suffixes_.size(); ++i) | ||
timer_names.push_back({static_cast<Timer>(i), prefix + std::string{suffixes_[i]}}); | ||
return timer_names; | ||
} | ||
TimerList_t walker_log_buffer_timers_; | ||
|
||
/// index of current quantity during WalkerLogCollector::collect() | ||
size_t quantity_index; | ||
/** buffer row location data for each walker quantity | ||
|
@@ -131,14 +150,7 @@ class WalkerLogBuffer | |
Array<T, 2> buffer; | ||
|
||
public: | ||
WalkerLogBuffer() | ||
{ | ||
label = "?"; | ||
first_collect = true; | ||
walker_data_size = 0; | ||
quantity_index = 0; | ||
resetBuffer(); | ||
} | ||
WalkerLogBuffer(); | ||
|
||
/// current number of rows in the data buffer | ||
inline size_t nrows() { return buffer.size(0); } | ||
|
@@ -163,33 +175,14 @@ class WalkerLogBuffer | |
inline bool sameAs(const WalkerLogBuffer<T>& ref) { return buffer.size(1) == ref.buffer.size(1); } | ||
|
||
/// collect data for a single walker quantity of scalar type into the current buffer row | ||
inline void collect(const std::string& name, const T& value) | ||
{ | ||
size_t irow = 0; | ||
if (first_collect) | ||
{ // cache walker quantity info on first collect | ||
WalkerQuantityInfo wqi_(name, 1, walker_data_size); | ||
quantity_info.push_back(wqi_); | ||
walker_data_size = wqi_.buffer_end; | ||
resetRowSize(walker_data_size); | ||
} | ||
else | ||
{ // make a new buffer row if needed | ||
if (quantity_index == 0) | ||
makeNewRow(); | ||
irow = buffer.size(0) - 1; | ||
} | ||
// place the scalar walker quantity into the current buffer row | ||
auto& wqi = quantity_info[quantity_index]; | ||
buffer(irow, wqi.buffer_start) = value; | ||
quantity_index++; | ||
} | ||
|
||
void collect(const std::string& name, const T& value); | ||
|
||
/// collect data for a single walker quantity of array type into the current buffer row | ||
template<unsigned D> | ||
inline void collect(const std::string& name, Array<T, D> arr) | ||
{ | ||
ScopedTimer timer(walker_log_buffer_timers_[Timer::COLLECT]); | ||
|
||
size_t n1 = arr.size(0); | ||
size_t n2, n3, n4; | ||
n2 = n3 = n4 = 0; | ||
|
@@ -228,6 +221,7 @@ class WalkerLogBuffer | |
template<unsigned D> | ||
inline void collect(const std::string& name, Array<std::complex<T>, D> arr) | ||
{ | ||
ScopedTimer timer(walker_log_buffer_timers_[Timer::COLLECT]); | ||
size_t n1 = arr.size(0); | ||
size_t n2, n3, n4; | ||
n2 = n3 = n4 = 0; | ||
|
@@ -271,6 +265,7 @@ class WalkerLogBuffer | |
/// add a data row from another buffer to this one | ||
inline void addRow(WalkerLogBuffer<T> other, size_t i) | ||
{ | ||
ScopedTimer timer(walker_log_buffer_timers_[Timer::ADD_ROW]); | ||
auto& other_buffer = other.buffer; | ||
if (first_collect) | ||
{ | ||
|
@@ -293,6 +288,8 @@ class WalkerLogBuffer | |
/// write a summary of quantities in the buffer | ||
inline void writeSummary(std::string pad = " ") | ||
{ | ||
ScopedTimer timer(walker_log_buffer_timers_[Timer::WRITE]); | ||
|
||
std::string pad2 = pad + " "; | ||
std::string pad3 = pad2 + " "; | ||
app_log() << std::endl; | ||
|
@@ -341,6 +338,7 @@ class WalkerLogBuffer | |
/// write the buffer data into the HDF file | ||
inline void writeHDF(hdf_archive& f, hsize_t& file_pointer) | ||
{ | ||
ScopedTimer timer(walker_log_buffer_timers_[Timer::WRITE]); | ||
auto& top = label; | ||
hsize_t dims[2]; | ||
dims[0] = buffer.size(0); | ||
|
@@ -358,6 +356,7 @@ class WalkerLogBuffer | |
/// make space as quantities are added to the buffer for the first time | ||
inline void resetRowSize(size_t row_size) | ||
{ | ||
ScopedTimer timer(walker_log_buffer_timers_[Timer::RESET]); | ||
auto nrows = buffer.size(0); | ||
if (nrows == 0) | ||
nrows++; | ||
|
@@ -378,6 +377,8 @@ class WalkerLogBuffer | |
/// allocate a full new row at the end of the buffer | ||
inline void makeNewRow() | ||
{ | ||
ScopedTimer timer(walker_log_buffer_timers_[Timer::MAKE_NEW_ROW]); | ||
|
||
size_t nrows = buffer.size(0); | ||
size_t row_size = buffer.size(1); | ||
if (row_size == 0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// This file is distributed under the University of Illinois/NCSA Open Source License. | ||
// See LICENSE file in top directory for details. | ||
// | ||
// Copyright (c) 2024 QMCPACK developers. | ||
// Copyright (c) 2025 QMCPACK developers. | ||
// | ||
// File developed by: Jaron T. Krogel, [email protected], Oak Ridge National Laboratory | ||
// | ||
|
@@ -23,7 +23,7 @@ namespace qmcplusplus | |
|
||
using MCPWalker = Walker<QMCTraits, PtclOnLatticeTraits>; | ||
|
||
WalkerLogCollector::WalkerLogCollector(const WalkerLogState& state) : state_(state) { init(); } | ||
WalkerLogCollector::WalkerLogCollector(const WalkerLogState& state) : walker_log_collector_timers_(getGlobalTimerManager(), create_names(my_name_), timer_level_medium), state_(state) { init(); } | ||
|
||
|
||
void WalkerLogCollector::init() | ||
|
@@ -43,6 +43,7 @@ void WalkerLogCollector::init() | |
|
||
void WalkerLogCollector::startBlock() | ||
{ | ||
ScopedTimer timer(walker_log_collector_timers_[Timer::START]); | ||
if (!state_.logs_active) | ||
return; // no-op for driver if logs are inactive | ||
if (state_.verbose) | ||
|
@@ -57,6 +58,8 @@ void WalkerLogCollector::collect(const MCPWalker& walker, | |
const QMCHamiltonian& ham, | ||
int step) | ||
{ | ||
ScopedTimer timer(walker_log_collector_timers_[Timer::COLLECT]); | ||
|
||
if (!state_.logs_active) | ||
return; // no-op for driver if logs are inactive | ||
|
||
|
@@ -175,6 +178,8 @@ void WalkerLogCollector::resetBuffers() | |
|
||
void WalkerLogCollector::checkBuffers() | ||
{ | ||
ScopedTimer timer(walker_log_collector_timers_[Timer::CHECK_BUFFERS]); | ||
|
||
if (state_.verbose) | ||
app_log() << "WalkerLogCollector::checkBuffers" << std::endl; | ||
size_t nrows = walker_property_int_buffer.nrows(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// This file is distributed under the University of Illinois/NCSA Open Source License. | ||
// See LICENSE file in top directory for details. | ||
// | ||
// Copyright (c) 2024 QMCPACK developers. | ||
// Copyright (c) 2025 QMCPACK developers. | ||
// | ||
// File developed by: Jaron T. Krogel, [email protected], Oak Ridge National Laboratory | ||
// | ||
|
@@ -14,7 +14,7 @@ | |
#define QMCPLUSPLUS_WALKERLOGCOLLECTOR_H | ||
|
||
#include "WalkerLogBuffer.h" | ||
|
||
#include "Utilities/TimerManager.h" | ||
|
||
namespace qmcplusplus | ||
{ | ||
|
@@ -68,6 +68,25 @@ class WalkerLogCollector | |
int energy_index; | ||
|
||
private: | ||
static constexpr std::string_view my_name_{"WalkerLogCollector"}; | ||
enum Timer | ||
{ | ||
START = 0, | ||
COLLECT, | ||
CHECK_BUFFERS | ||
}; | ||
static constexpr std::array<std::string_view, 3> suffixes_{"start", "collect", "check_buffers"}; | ||
static TimerNameList_t<Timer> create_names(const std::string_view& my_name) | ||
{ | ||
TimerNameList_t<Timer> timer_names; | ||
using namespace std::string_literals; | ||
std::string prefix{"WalkerLog:"s + std::string{my_name} + "::"s}; | ||
for (std::size_t i = 0; i < suffixes_.size(); ++i) | ||
timer_names.push_back({static_cast<Timer>(i), prefix + std::string{suffixes_[i]}}); | ||
return timer_names; | ||
} | ||
TimerList_t walker_log_collector_timers_; | ||
|
||
// temporary (contiguous) storage for awful ParticleAttrib<> quantities | ||
/// tmp storage for walker positions | ||
Array<WLog::Real, 2> Rtmp; | ||
|
Oops, something went wrong.