Commit ce481e59 authored by Doak, Peter W.'s avatar Doak, Peter W.
Browse files

Merge remote-tracking branch 'origin/single_measurement_G_k_w' into single_measurement_G_k_w

parents 40b17c65 f950d9e1
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -11,9 +11,11 @@ module load cuda/11.1.1 # ldd shows magma is built with this cuda
module load magma/2.6.1
module load hdf5
module load fftw
module load cmake/3.20.2 # at least 3.20 is required
module load cmake/3.21.3
module load netlib-lapack
module load essl
module load adios2
module load ninja

export CC=mpicc
export CXX=mpic++
+21 −15
Original line number Diff line number Diff line
@@ -31,31 +31,40 @@ class Reader {
public:
  // In: format. output format, HDF5 or JSON.
  // In: verbose. If true, the reader outputs a short log whenever it is executed.
  Reader(
#ifdef DCA_HAVE_ADIOS2
      const adios2::ADIOS& adios,
#endif
      const Concurrency& concurrency, const std::string& format, bool verbose = true)
      :
#ifdef DCA_HAVE_ADIOS2
        adios_(adios),
#endif
        concurrency_(concurrency) {
  Reader(const Concurrency& concurrency, const std::string& format, bool verbose = true)
      : concurrency_(concurrency) {
    if (format == "HDF5") {
      reader_.template emplace<io::HDF5Reader>(verbose);
    }
    else if (format == "JSON") {
      reader_.template emplace<io::JSONReader>(verbose);
    }
    else if (format == "ADIOS2") {
      throw(std::logic_error("ADIOS2 reader requires an adios reference"));
    }
    else {
      throw(std::logic_error("Invalid input format"));
    }
  }

#ifdef DCA_HAVE_ADIOS2
  Reader(adios2::ADIOS& adios, const Concurrency& concurrency, const std::string& format,
         bool verbose = true)
      : concurrency_(concurrency) {
    if (format == "HDF5") {
      throw(std::logic_error("ADIOS2 reference not an argument for hdf5 reader"));
    }
    else if (format == "JSON") {
      throw(std::logic_error("ADIOS2 reference not an argument for json reader"));
    }
    else if (format == "ADIOS2") {
      reader_.template emplace<io::ADIOS2Reader<Concurrency>>(&concurrency, verbose);
      reader_.template emplace<io::ADIOS2Reader<Concurrency>>(adios, &concurrency, verbose);
    }
#endif
    else {
      throw(std::logic_error("Invalid input format"));
    }
  }
#endif

  constexpr static bool is_reader = true;
  constexpr static bool is_writer = false;
@@ -92,9 +101,6 @@ private:
#endif
               >
      reader_;
#ifdef DCA_HAVE_ADIOS2
  const adios2::ADIOS& adios_;
#endif
  const Concurrency& concurrency_;
};

+2 −3
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ public:

  void read(const std::string& filename);
#ifdef DCA_HAVE_ADIOS2
  void read(const adios2::ADIOS& adios, std::string filename);
  void read(adios2::ADIOS& adios, std::string filename);
#endif

  /** prefer this as it allows for more sensible handling of appendable files like bp4.
@@ -361,7 +361,7 @@ void DcaData<Parameters, DT>::read(const std::string& filename) {

#ifdef DCA_HAVE_ADIOS2
template <class Parameters, DistType DT>
void DcaData<Parameters, DT>::read(const adios2::ADIOS& adios, std::string filename) {
void DcaData<Parameters, DT>::read(adios2::ADIOS& adios, std::string filename) {
  if (concurrency_.id() == concurrency_.first())
    std::cout << "\n\n\t starts reading \n\n";

@@ -413,7 +413,6 @@ void DcaData<Parameters, DT>::read(dca::io::Reader<typename Parameters::concurre
}

#ifdef DCA_WITH_ADIOS2

template <class Parameters, DistType DIST>
void DcaData<Parameters, DIST>::writeAdios(adios2::ADIOS& adios) {
  if constexpr (DIST == DistType::BLOCKED || DIST == DistType::LINEAR) {
+17 −7
Original line number Diff line number Diff line
// Copyright (C) 2018 ETH Zurich
// Copyright (C) 2018 UT-Battelle, LLC
// Copyright (C) 2022 ETH Zurich
// Copyright (C) 2022 UT-Battelle, LLC
// All rights reserved.
//
// See LICENSE for terms of usage.
@@ -7,6 +7,7 @@
//
// Author: Peter Staar (taa@zurich.ibm.com)
//         Andrei Plamada (plamada@itp.phys.ethz.ch)
//         Peter Doak (doakpw@ornl.gov)
//
// This class executes the DCA(+) loop.

@@ -23,6 +24,7 @@
#include "dca/function/domains.hpp"
#include "dca/io/filesystem.hpp"
#include "dca/io/writer.hpp"
#include "dca/io/io_types.hpp"
#include "dca/phys/dca_algorithms/compute_greens_function.hpp"
#include "dca/phys/dca_data/dca_data.hpp"
#include "dca/phys/dca_loop/dca_loop_data.hpp"
@@ -141,9 +143,6 @@ DcaLoop<ParametersType, DcaDataType, MCIntegratorType, DIST>::DcaLoop(
      concurrency(concurrency_ref),
#ifdef DCA_HAVE_ADIOS2
      adios_("", concurrency_ref.get()),
      DCA_info_struct(adios_),
#else
      DCA_info_struct(),
#endif
      cluster_exclusion_obj(parameters, MOMS),
      double_counting_correction_obj(parameters, MOMS),
@@ -208,8 +207,19 @@ void DcaLoop<ParametersType, DDT, MCIntegratorType, DIST>::initialize() {
  int last_completed = -1;

  if (parameters.autoresume()) {  // Try to read state of previous run.
    auto& dca_filename = parameters.get_filename_dca();
    std::size_t extension_start = dca_filename.rfind('.');
    std::string extension{dca_filename.substr(extension_start, dca_filename.size())};
    std::cout << extension << '\n';
    // This is not complete, how do we want to decide what format we are reading?  Just from output format?
#ifdef DCA_HAVE_ADIOS2
    if (io::stringToIOType(parameters.get_output_format()) == io::IOType::ADIOS2)
      last_completed =
          DCA_info_struct.readData(file_name_, parameters.get_output_format(), concurrency, adios_);
    else
#endif
      last_completed =
        DCA_info_struct.tryToRead(file_name_ + ".tmp", parameters.get_output_format(), concurrency);
          DCA_info_struct.readData(file_name_ + ".tmp", parameters.get_output_format(), concurrency);
  }
  if (last_completed >= 0) {
    if (concurrency.id() == concurrency.first())
+51 −40
Original line number Diff line number Diff line
@@ -44,24 +44,21 @@ public:
  using k_DCA =
      func::dmn_0<domains::cluster_domain<double, ParametersType::lattice_type::DIMENSION, domains::CLUSTER,
                                          domains::MOMENTUM_SPACE, domains::BRILLOUIN_ZONE>>;

#ifdef DCA_HAVE_ADIOS2
  DcaLoopData(adios2::ADIOS& adios);
#else
  DcaLoopData();
#endif
  template <typename Writer>
  void write(Writer& writer);

  template <typename WRITER>
  void write(WRITER& writer);

  // Attempts to read the loop functions from 'filename'. If successful returns
  // the last completed iteration from the input file, otherwise it returns -1.
  int tryToRead(const std::string& filename, const std::string& format,
  int readData(const std::string& filename, const std::string& format,
                const Concurrency& concurrency);

#ifdef DCA_HAVE_ADIOS2
  const adios2::ADIOS& adios_;
  int readData(const std::string& filename, const std::string& format,
	       const Concurrency& concurrency, adios2::ADIOS& adios);
#endif

  template<class READER>
  void readLoopDataCommon(READER& reader, const std::string& filename, const std::string& format);
  func::function<double, DCA_iteration_domain_type> Gflop_per_mpi_task;
  func::function<double, DCA_iteration_domain_type> times_per_mpi_task;

@@ -99,9 +96,6 @@ DcaLoopData<ParametersType>::DcaLoopData(adios2::ADIOS& adios)
DcaLoopData<ParametersType>::DcaLoopData()
#endif
    :
#ifdef DCA_HAVE_ADIOS2
      adios_(adios),
#endif
      Gflop_per_mpi_task("Gflop_per_mpi_task"),
      times_per_mpi_task("times_per_mpi_task"),

@@ -160,14 +154,35 @@ void DcaLoopData<ParametersType>::write(Writer& writer) {
}

template <typename ParametersType>
int DcaLoopData<ParametersType>::tryToRead(const std::string& filename, const std::string& format,
int DcaLoopData<ParametersType>::readData(const std::string& filename, const std::string& format,
                                              const Concurrency& concurrency) {
  if (concurrency.id() == concurrency.first() && filesystem::exists(filename)) {
#ifdef DCA_HAVE_ADIOS2
    io::Reader reader(adios_, concurrency, format, false);
#else
    io::Reader reader(concurrency, format, false);
    readLoopDataCommon(reader, filename, format);
  }  
  concurrency.broadcast(last_completed_iteration);
  return last_completed_iteration;
}

#ifdef DCA_HAVE_ADIOS2
template <typename ParametersType>
int DcaLoopData<ParametersType>::readData(const std::string& filename, const std::string& format,
                                              const Concurrency& concurrency,
                                              adios2::ADIOS& adios) {
  if (concurrency.id() == concurrency.first() && filesystem::exists(filename)) {
    io::Reader reader(adios, concurrency, format, false);
    readLoopDataCommon(reader, filename, format);
  }
  concurrency.broadcast(last_completed_iteration);
  return last_completed_iteration;
}
#endif

template <typename ParametersType>
template <class READER>
void DcaLoopData<ParametersType>::readLoopDataCommon(READER& reader,
						     const std::string& filename,
						     const std::string& format) {
  reader.open_file(filename);
  reader.open_group("DCA-loop-functions");

@@ -196,10 +211,6 @@ int DcaLoopData<ParametersType>::tryToRead(const std::string& filename, const st
  reader.close_file();
}

  concurrency.broadcast(last_completed_iteration);
  return last_completed_iteration;
}

}  // namespace phys
}  // namespace dca

Loading