Skip to content

Instantly share code, notes, and snippets.

@aeantipov
Last active August 29, 2015 14:07
Show Gist options
  • Save aeantipov/f0e0a2af5a47c6b24171 to your computer and use it in GitHub Desktop.
Save aeantipov/f0e0a2af5a47c6b24171 to your computer and use it in GitHub Desktop.
Crashes of RealVectorObservable on mpi reduce
#include <alps/mc/mcbase.hpp>
#include <alps/mc/mcmpiadapter.hpp>
#include <alps/mc/api.hpp>
#include <alps/accumulator.hpp>
#include <alps/params.hpp>
#include <alps/utility/stop_callback.hpp>
class sim1 : public alps::mcbase {
public:
sim1(parameters_type const & p, std::size_t seed_offset = 0):
alps::mcbase(p, seed_offset),
nsweeps(p["nsweeps"]),
count(0)
{
measurements << alps::accumulator::RealVectorObservable("e1");
//measurements << alps::accumulator::RealVectorObservable("e2"); // doesn't play a role
}
void update() { count++; }
void measure() {
measurements["e1"] << std::vector<double>(5, 1.0);
//measurements["e2"] << std::valarray<double>(4, 1.0);
//measurements["e2"] << std::vector<double>(5, 1.0); // doesn't play a role
}
double fraction_completed() const { return double (count/nsweeps); }
private:
int nsweeps;
int count;
};
int main(int argc, char* argv[])
{
boost::mpi::environment env(argc, argv);
boost::mpi::communicator comm;
alps::params p;
p["nsweeps"] = 10000;
alps::mcmpiadapter<sim1> sim (p,comm, alps::check_schedule(0.001, 60));
sim.run(alps::stop_callback(1));
alps::results_type<sim1>::type res = alps::collect_results(sim);
std::cout << res << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment