Unverified Commit 040e5e9a authored by Peter Doak's avatar Peter Doak Committed by GitHub
Browse files

Merge pull request #134 from gbalduzz/optional_config_read

Configuration storage between iterations is optional. Default: off.
parents 63654be6 6f1db064
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -281,7 +281,10 @@ void StdThreadQmciClusterSolver<QmciSolver>::startWalker(int id) {
    walker.printSummary();
  }

  if (parameters_.store_configuration() || (parameters_.get_directory_config_write() != "" &&
                                            dca_iteration_ == parameters_.get_dca_iterations() - 1))
    config_dump_[walker_index] = walker.dumpConfig();

  walker_fingerprints_[walker_index] = walker.deviceFingerprint();

  Profiler::stop_threading(id);
@@ -296,8 +299,10 @@ void StdThreadQmciClusterSolver<QmciSolver>::initializeAndWarmUp(Walker& walker,
  Profiler profiler("thermalization", "stdthread-MC-walker", __LINE__, id);

  // Read previous configuration.
  if (config_dump_[walker_id].size())
  if (config_dump_[walker_id].size()) {
    walker.readConfig(config_dump_[walker_id]);
    config_dump_[walker_id].setg(0); // Ready to read again if it is not overwritten.
  }

  walker.initialize();

@@ -439,7 +444,11 @@ void StdThreadQmciClusterSolver<QmciSolver>::startWalkerAndAccumulator(int id) {
    std::lock_guard<std::mutex> lock(mutex_merge_);
    accumulator_obj.sumTo(QmciSolver::accumulator_);
  }

  if (parameters_.store_configuration() || (parameters_.get_directory_config_write() != "" &&
                                            dca_iteration_ == parameters_.get_dca_iterations() - 1))
    config_dump_[id] = walker.dumpConfig();

  walker_fingerprints_[id] = walker.deviceFingerprint();
  accum_fingerprints_[id] = accumulator_obj.deviceFingerprint();

+21 −4
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ public:
        // TODO: consider setting default do true.
        fix_meas_per_walker_(false),
        adjust_self_energy_for_double_counting_(false),
        error_computation_type_(ErrorComputationType::NONE) {}
        error_computation_type_(ErrorComputationType::NONE),
        store_configuration_(false) {}

  template <typename Concurrency>
  int getBufferSize(const Concurrency& concurrency) const;
@@ -89,6 +90,12 @@ public:
    return error_computation_type_;
  }

  // If true, the MC configuration is stored between DCA iterations, and used to initialize the
  // walker.
  bool store_configuration() const {
    return store_configuration_;
  }

private:
  void generateRandomSeed() {
    std::random_device rd;
@@ -108,6 +115,7 @@ private:
  bool fix_meas_per_walker_;
  bool adjust_self_energy_for_double_counting_;
  ErrorComputationType error_computation_type_;
  bool store_configuration_;
};

template <typename Concurrency>
@@ -124,6 +132,7 @@ int MciParameters::getBufferSize(const Concurrency& concurrency) const {
  buffer_size += concurrency.get_buffer_size(fix_meas_per_walker_);
  buffer_size += concurrency.get_buffer_size(adjust_self_energy_for_double_counting_);
  buffer_size += concurrency.get_buffer_size(error_computation_type_);
  buffer_size += concurrency.get_buffer_size(store_configuration_);

  return buffer_size;
}
@@ -141,6 +150,7 @@ void MciParameters::pack(const Concurrency& concurrency, char* buffer, int buffe
  concurrency.pack(buffer, buffer_size, position, fix_meas_per_walker_);
  concurrency.pack(buffer, buffer_size, position, adjust_self_energy_for_double_counting_);
  concurrency.pack(buffer, buffer_size, position, error_computation_type_);
  concurrency.pack(buffer, buffer_size, position, store_configuration_);
}

template <typename Concurrency>
@@ -156,6 +166,7 @@ void MciParameters::unpack(const Concurrency& concurrency, char* buffer, int buf
  concurrency.unpack(buffer, buffer_size, position, fix_meas_per_walker_);
  concurrency.unpack(buffer, buffer_size, position, adjust_self_energy_for_double_counting_);
  concurrency.unpack(buffer, buffer_size, position, error_computation_type_);
  concurrency.unpack(buffer, buffer_size, position, store_configuration_);
}

template <typename ReaderOrWriter>
@@ -223,6 +234,12 @@ void MciParameters::readWrite(ReaderOrWriter& reader_or_writer) {
    catch (const std::exception& r_e) {
    }

    try {
      reader_or_writer.execute("store-configuration", store_configuration_);
    }
    catch (const std::exception& r_e) {
    }

    // Read arguments for threaded solver.
    try {
      reader_or_writer.open_group("threaded-solver");
@@ -267,8 +284,8 @@ void MciParameters::readWrite(ReaderOrWriter& reader_or_writer) {
  }
}

}  // params
}  // phys
}  // dca
}  // namespace params
}  // namespace phys
}  // namespace dca

#endif  // DCA_PHYS_PARAMETERS_MCI_PARAMETERS_HPP
+3 −3
Original line number Diff line number Diff line
@@ -427,8 +427,8 @@ std::string Parameters<Concurrency, Threading, Profiler, Model, RandomNumberGene
  return str;
}

}  // params
}  // phys
}  // dca
}  // namespace params
}  // namespace phys
}  // namespace dca

#endif  // DCA_PHYS_PARAMETERS_PARAMETERS_HPP
+2 −1
Original line number Diff line number Diff line
@@ -58,7 +58,8 @@
        "seed": 985456376,
        "warm-up-sweeps": 20,
        "sweeps-per-measurement": 1,
        "measurements": 800
        "measurements": 800,
        "store-configuration" : true
    },

    "CT-AUX": {
+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@
        "warm-up-sweeps": 20,
        "sweeps-per-measurement": 1,
        "measurements": 800,
        "store-configuration" : true,

        "threaded-solver": {
            "walkers": 1,
Loading