Loading include/dca/io/hdf5/hdf5_reader.hpp +13 −6 Original line number Diff line number Diff line // Copyright (C) 2018 ETH Zurich // Copyright (C) 2018 UT-Battelle, LLC // Copyright (C) 2023 ETH Zurich // Copyright (C) 2023 UT-Battelle, LLC // All rights reserved. // // See LICENSE for terms of usage. // See CITATION.md for citation guidelines, if DCA++ is used for scientific publications. // // Author: Peter Staar (taa@zurich.ibm.com) // Peter W. Doak (doakpw@ornl.gov) // // HDF5 reader. Loading @@ -18,6 +19,9 @@ #include "H5Cpp.h" #include "dca/config/haves_defines.hpp" #include "dca/platform/dca_gpu.h" #include "dca/io/buffer.hpp" #include "dca/function/domains.hpp" #include "dca/function/function.hpp" Loading Loading @@ -62,7 +66,7 @@ public: void begin_step(); void end_step(); std::string get_path(); std::string get_path() const; std::size_t getStepCount(); Loading Loading @@ -113,6 +117,7 @@ public: } private: bool buildCheckedFullName(const std::string& name, std::string& full_name) const; bool exists(const std::string& name) const; void read(const std::string& name, H5::DataType type, void* data) const; Loading @@ -123,6 +128,9 @@ private: bool verbose_; /// work around for Legacy hdf5 bool is_legacy_ = false; int step_ = 0; bool in_step_ = false; }; Loading @@ -138,9 +146,8 @@ void HDF5Reader::from_file(arbitrary_struct_t& arbitrary_struct, std::string fil template <typename Scalar> bool HDF5Reader::execute(const std::string& name, Scalar& value) { std::string full_name = get_path() + "/" + name; if (!exists(full_name)) { std::string full_name; if (!buildCheckedFullName(name, full_name)) { return false; } Loading include/dca/io/hdf5/hdf5_writer.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <H5Cpp.h> #include "dca/platform/dca_gpu.h" #include "dca/function/domains.hpp" #include "dca/io/buffer.hpp" #include "dca/function/function.hpp" Loading include/dca/io/reader.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,9 @@ #include <string> #include <variant> #include "dca/config/haves_defines.hpp" #include "dca/platform/dca_gpu.h" #include "dca/io/io_types.hpp" #include "dca/io/hdf5/hdf5_reader.hpp" #include "dca/io/json/json_reader.hpp" Loading include/dca/io/writer.hpp +6 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,10 @@ public: } #endif bool isHDF5() { return std::holds_alternative<io::HDF5Writer>(writer_); } bool isOpen() { return is_open_; } void begin_step() { Loading Loading @@ -172,6 +176,8 @@ public: std::visit([&](auto& var) { var.set_verbose(verbose); }, writer_); } Concurrency& get_concurrency() { return concurrency_; } dca::parallel::thread_traits::mutex_type& get_mutex() { return mutex_; } private: dca::parallel::thread_traits::mutex_type mutex_; Loading include/dca/phys/dca_data/dca_data.hpp +29 −8 Original line number Diff line number Diff line Loading @@ -615,25 +615,45 @@ void DcaData<Parameters, DT>::initializeSigma(adios2::ADIOS& adios [[maybe_unuse reader.end_step(); } readSigmaFile(reader); reader.close_file(); } concurrency_.broadcast(parameters_.get_chemical_potential()); concurrency_.broadcast(Sigma); } #endif // Strong assumption here that this only gets called for HDF5 input. template <class Parameters, DistType DT> void DcaData<Parameters, DT>::initializeSigma(const std::string& filename) { if (concurrency_.id() == concurrency_.first()) { std::cout << "reading Sigma File\n"; io::IOType sigma_file_io = io::extensionToIOType(filename); io::Reader reader(concurrency_, sigma_file_io); int hdf5_last_iteration = -1; reader.open_file(filename); std::size_t step_count = reader.getStepCount(); // Work around odd way hdf5 steps get written int completed_iteration = 0; find_step: for (std::size_t i = 0; i < step_count; ++i) { reader.begin_step(); std::cerr << "current step " << i << '\n'; bool has_iteration = reader.execute("DCA-loop-functions/completed-iteration", completed_iteration); std::cerr << "completed_iteration " << completed_iteration << '\n'; if (has_iteration && (i >= completed_iteration)) { std::cerr << "past complete iterations " << completed_iteration << "at step " << i << '\n'; hdf5_last_iteration = completed_iteration; reader.close_file(); reader.open_file(filename); step_count = hdf5_last_iteration; goto find_step; } reader.end_step(); } reader.begin_step(); readSigmaFile(reader); reader.close_file(); } concurrency_.broadcast(parameters_.get_chemical_potential()); concurrency_.broadcast(Sigma); Loading @@ -648,7 +668,8 @@ void DcaData<Parameters, DT>::readSigmaFile(io::Reader<Concurrency>& reader) { bool has_iteration = reader.execute("completed-iteration", completed_iteration); if (chemical_potential_present && has_iteration) { std::cout << "chemical-potential from Sigma file: " << chemical_potentials[completed_iteration] << '\n'; std::cout << "chemical-potential from Sigma file: " << chemical_potentials[completed_iteration] << '\n'; parameters_.get_chemical_potential() = chemical_potentials[completed_iteration]; } else { Loading Loading
include/dca/io/hdf5/hdf5_reader.hpp +13 −6 Original line number Diff line number Diff line // Copyright (C) 2018 ETH Zurich // Copyright (C) 2018 UT-Battelle, LLC // Copyright (C) 2023 ETH Zurich // Copyright (C) 2023 UT-Battelle, LLC // All rights reserved. // // See LICENSE for terms of usage. // See CITATION.md for citation guidelines, if DCA++ is used for scientific publications. // // Author: Peter Staar (taa@zurich.ibm.com) // Peter W. Doak (doakpw@ornl.gov) // // HDF5 reader. Loading @@ -18,6 +19,9 @@ #include "H5Cpp.h" #include "dca/config/haves_defines.hpp" #include "dca/platform/dca_gpu.h" #include "dca/io/buffer.hpp" #include "dca/function/domains.hpp" #include "dca/function/function.hpp" Loading Loading @@ -62,7 +66,7 @@ public: void begin_step(); void end_step(); std::string get_path(); std::string get_path() const; std::size_t getStepCount(); Loading Loading @@ -113,6 +117,7 @@ public: } private: bool buildCheckedFullName(const std::string& name, std::string& full_name) const; bool exists(const std::string& name) const; void read(const std::string& name, H5::DataType type, void* data) const; Loading @@ -123,6 +128,9 @@ private: bool verbose_; /// work around for Legacy hdf5 bool is_legacy_ = false; int step_ = 0; bool in_step_ = false; }; Loading @@ -138,9 +146,8 @@ void HDF5Reader::from_file(arbitrary_struct_t& arbitrary_struct, std::string fil template <typename Scalar> bool HDF5Reader::execute(const std::string& name, Scalar& value) { std::string full_name = get_path() + "/" + name; if (!exists(full_name)) { std::string full_name; if (!buildCheckedFullName(name, full_name)) { return false; } Loading
include/dca/io/hdf5/hdf5_writer.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <H5Cpp.h> #include "dca/platform/dca_gpu.h" #include "dca/function/domains.hpp" #include "dca/io/buffer.hpp" #include "dca/function/function.hpp" Loading
include/dca/io/reader.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,9 @@ #include <string> #include <variant> #include "dca/config/haves_defines.hpp" #include "dca/platform/dca_gpu.h" #include "dca/io/io_types.hpp" #include "dca/io/hdf5/hdf5_reader.hpp" #include "dca/io/json/json_reader.hpp" Loading
include/dca/io/writer.hpp +6 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,10 @@ public: } #endif bool isHDF5() { return std::holds_alternative<io::HDF5Writer>(writer_); } bool isOpen() { return is_open_; } void begin_step() { Loading Loading @@ -172,6 +176,8 @@ public: std::visit([&](auto& var) { var.set_verbose(verbose); }, writer_); } Concurrency& get_concurrency() { return concurrency_; } dca::parallel::thread_traits::mutex_type& get_mutex() { return mutex_; } private: dca::parallel::thread_traits::mutex_type mutex_; Loading
include/dca/phys/dca_data/dca_data.hpp +29 −8 Original line number Diff line number Diff line Loading @@ -615,25 +615,45 @@ void DcaData<Parameters, DT>::initializeSigma(adios2::ADIOS& adios [[maybe_unuse reader.end_step(); } readSigmaFile(reader); reader.close_file(); } concurrency_.broadcast(parameters_.get_chemical_potential()); concurrency_.broadcast(Sigma); } #endif // Strong assumption here that this only gets called for HDF5 input. template <class Parameters, DistType DT> void DcaData<Parameters, DT>::initializeSigma(const std::string& filename) { if (concurrency_.id() == concurrency_.first()) { std::cout << "reading Sigma File\n"; io::IOType sigma_file_io = io::extensionToIOType(filename); io::Reader reader(concurrency_, sigma_file_io); int hdf5_last_iteration = -1; reader.open_file(filename); std::size_t step_count = reader.getStepCount(); // Work around odd way hdf5 steps get written int completed_iteration = 0; find_step: for (std::size_t i = 0; i < step_count; ++i) { reader.begin_step(); std::cerr << "current step " << i << '\n'; bool has_iteration = reader.execute("DCA-loop-functions/completed-iteration", completed_iteration); std::cerr << "completed_iteration " << completed_iteration << '\n'; if (has_iteration && (i >= completed_iteration)) { std::cerr << "past complete iterations " << completed_iteration << "at step " << i << '\n'; hdf5_last_iteration = completed_iteration; reader.close_file(); reader.open_file(filename); step_count = hdf5_last_iteration; goto find_step; } reader.end_step(); } reader.begin_step(); readSigmaFile(reader); reader.close_file(); } concurrency_.broadcast(parameters_.get_chemical_potential()); concurrency_.broadcast(Sigma); Loading @@ -648,7 +668,8 @@ void DcaData<Parameters, DT>::readSigmaFile(io::Reader<Concurrency>& reader) { bool has_iteration = reader.execute("completed-iteration", completed_iteration); if (chemical_potential_present && has_iteration) { std::cout << "chemical-potential from Sigma file: " << chemical_potentials[completed_iteration] << '\n'; std::cout << "chemical-potential from Sigma file: " << chemical_potentials[completed_iteration] << '\n'; parameters_.get_chemical_potential() = chemical_potentials[completed_iteration]; } else { Loading