Commit a892b0d4 authored by gbalduzz's avatar gbalduzz
Browse files

Write configuration stamps to the same output file. (rank 0 only).

Updated parameters wiki.
parent 55c89616
Loading
Loading
Loading
Loading
+52 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@

#include <complex>
#include <memory>
#include <mutex>
#include <sstream>
#include <string>
#include <vector>
@@ -76,8 +77,11 @@ public:

  void execute(const std::string& name, const std::vector<std::string>& value);

  template <typename scalar_type>
  void execute(const std::string& name, const std::vector<std::vector<scalar_type>>& value);
  template <typename Scalar, std::size_t n>
  void execute(const std::string& name, const std::vector<std::array<Scalar, n>>& value);

  template <typename Scalar>
  void execute(const std::string& name, const std::vector<std::vector<Scalar>>& value);

  template <typename domain_type>
  void execute(const std::string& name, const func::dmn_0<domain_type>& dmn);
@@ -126,6 +130,18 @@ public:

  bool pathExists(const std::string& path) const;

  operator bool() const {
    return static_cast<bool>(file_);
  }

  void lock() {
    mutex_.lock();
  }

  void unlock() {
    mutex_.unlock();
  }

private:
  bool fexists(const char* filename);

@@ -137,6 +153,8 @@ private:
  std::vector<std::string> my_paths;

  bool verbose_;

  std::mutex mutex_;
};

template <typename arbitrary_struct_t>
@@ -350,6 +368,38 @@ void HDF5Writer::execute(const std::string& name, const std::vector<std::vector<
  }
}

template <typename Scalar, std::size_t n>
void HDF5Writer::execute(const std::string& name, const std::vector<std::array<Scalar, n>>& value) {
  if (value.size() == 0)
    return;

  std::array<hsize_t, 2> dims{value.size(), n};

  H5::DataSet* dataset = nullptr;
  H5::DataSpace* dataspace = nullptr;

  std::string full_name = get_path() + "/" + name;

  dataspace = new H5::DataSpace(2, dims.data());

  dataset = new H5::DataSet(
      file_->createDataSet(full_name.c_str(), HDF5_TYPE<Scalar>::get_PredType(), *dataspace));

  Scalar* tmp = new Scalar[dims[0] * dims[1]];

  // hdf5 has row-major ordering!
  //  for (hsize_t i = 0; i < dims[0]; i++)
  //    for (hsize_t j = 0; j < dims[1]; j++)
  //      tmp[i * dims[1] + j] = value[i][j];

  H5Dwrite(dataset->getId(), HDF5_TYPE<Scalar>::get(), dataspace->getId(), H5S_ALL, H5P_DEFAULT,
           value[0].data());

  delete[] tmp;
  delete dataset;
  delete dataspace;
}

template <typename domain_type>
void HDF5Writer::execute(const std::string& name, const func::dmn_0<domain_type>& dmn) {
  open_group(name);
+7 −0
Original line number Diff line number Diff line
@@ -61,6 +61,13 @@ struct MPITypeMap<int> {
  }
};

template <>
struct MPITypeMap<unsigned int> {
  static MPI_Datatype value() {
    return MPI_UNSIGNED;
  }
};

template <>
struct MPITypeMap<std::size_t> {
  static MPI_Datatype value() {
+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ DcaLoop<ParametersType, DcaDataType, MCIntegratorType>::DcaLoop(ParametersType&

      update_chemical_potential_obj(parameters, MOMS, cluster_mapping_obj),

      monte_carlo_integrator_(parameters_ref, MOMS_ref) {
      monte_carlo_integrator_(parameters_ref, MOMS_ref, &output_file_) {
  if (concurrency.id() == concurrency.first()) {
    file_name_ = parameters.get_directory() + parameters.get_filename_dca();
    output_file_.open_file(file_name_);
+4 −2
Original line number Diff line number Diff line
@@ -84,7 +84,8 @@ private:
  using NuNuRClusterWDmn = func::dmn_variadic<nu, nu, RClusterDmn, w>;

public:
  CtauxClusterSolver(Parameters& parameters_ref, Data& MOMS_ref);
  CtauxClusterSolver(Parameters& parameters_ref, Data& MOMS_ref,
                     io::HDF5Writer* /*writer*/ = nullptr);

  template <typename Writer>
  void write(Writer& writer);
@@ -166,7 +167,8 @@ private:

template <dca::linalg::DeviceType device_t, class Parameters, class Data>
CtauxClusterSolver<device_t, Parameters, Data>::CtauxClusterSolver(Parameters& parameters_ref,
                                                                   Data& data_ref)
                                                                   Data& data_ref,
                                                                   io::HDF5Writer* /*writer*/)
    : parameters_(parameters_ref),
      data_(data_ref),
      concurrency_(parameters_.get_concurrency()),
+2 −14
Original line number Diff line number Diff line
@@ -187,6 +187,8 @@ private:
  bool assert_exp_delta_V_value(HS_field_sign HS_field, int random_vertex_ind,
                                HS_spin_states_type new_HS_spin_value, Real exp_delta_V);



private:
  using WalkerBIT<Parameters, Data, Real>::check_G0_matrices;
  using WalkerBIT<Parameters, Data, Real>::check_N_matrices;
@@ -305,9 +307,6 @@ private:
  std::array<linalg::util::CudaEvent, 2> m_computed_events_;

  bool config_initialized_;

  std::size_t meas_id_ = 0;
  io::HDF5Writer config_file_;
};

template <dca::linalg::DeviceType device_t, class Parameters, class Data, typename Real>
@@ -364,10 +363,6 @@ CtauxWalker<device_t, Parameters, Data, Real>::CtauxWalker(Parameters& parameter
      num_delayed_spins_(),

      config_initialized_(false) {
  if (parameters.stamping_period()) {
    config_file_.open_file(parameters.get_configuration_stamps());
  }

  if (concurrency.id() == 0 and thread_id == 0) {
    std::cout << "\n\n"
              << "\t\t"
@@ -517,13 +512,6 @@ void CtauxWalker<device_t, Parameters, Data, Real>::doSweep() {

  if (!thermalized)
    ++warm_up_sweeps_done_;

  ++meas_id_;
  if (parameters.stamping_period()) {
    if ((meas_id_ % parameters.stamping_period()) == 0) {
      configuration.write(config_file_, std::to_string(meas_id_));
    }
  }
}

template <dca::linalg::DeviceType device_t, class Parameters, class Data, typename Real>
Loading