inline std::vector<int> _autorange_workers(const alps::mpi::communicator &comm, bool include_boss) {
    std::vector<int> out;
    size_t Nprocs(comm.size() - !include_boss);
    if (!Nprocs) throw (std::logic_error("No workers to evaluate"));
    for (size_t p = 0; p < comm.size(); p++) {
        if (include_boss || comm.rank() != p) {
            out.push_back(p);
        };
    };
    return out;
}
Exemplo n.º 2
0
 template<typename T, typename Op, typename C> void reduce_impl(const alps::mpi::communicator & comm, T const & in_values, Op op, int root, boost::true_type, C) {
     // using alps::mpi::reduce;
     // reduce(comm, in_values, op, root);
     using alps::mpi::get_mpi_datatype;                    
     if (comm.rank()==root) {
         throw std::runtime_error("reduce_impl(): 4-arg overload is called by root rank."+ALPS_STACKTRACE);
     }
     MPI_Reduce((void*)&in_values, NULL, 1, get_mpi_datatype(T()),
                alps::mpi::is_mpi_op<Op, T>::op(), root, comm);
     
 }
Exemplo n.º 3
0
 template<typename T, typename Op, typename C> void reduce_impl(const alps::mpi::communicator & comm, T const & in_values, T & out_values, Op op, int root, boost::true_type, C) {
     using alps::mpi::reduce;
     // using boost::mpi::reduce;
     // reduce(comm, (T)in_values, out_values, op, root); // TODO: WTF? - why does boost not define unsigned long long as native datatype
     using alps::mpi::get_mpi_datatype;
     if (comm.rank()!=root) {
         // // usleep((comm.rank()+1)*1000000); // DEBUG!
         // std::cerr << "DEBUG:WARNING: rank=" << comm.rank() << " is not root=" << root
         //           << " but called 5-argument reduce_impl()." + ALPS_STACKTRACE << std::endl;
     }
     void* sendbuf=const_cast<T*>(&in_values);
     if (sendbuf == &out_values) {
         sendbuf=MPI_IN_PLACE;
     }
     MPI_Reduce(sendbuf, &out_values, 1, get_mpi_datatype(T()),
                alps::mpi::is_mpi_op<Op, T>::op(), root, comm);
 }
Exemplo n.º 4
0
 void broadcast_tail(const alps::mpi::communicator& comm,
                     int& min_order, int& max_order,
                     std::vector<TAILT>& tails,
                     const TAILT& tail_init,
                     int root)
 {
     using alps::mpi::broadcast;
     broadcast(comm, min_order, root);
     broadcast(comm, max_order, root);
     
     if (min_order==TAIL_NOT_SET) return;
     if (comm.rank()!=root) {
         tails.resize(max_order+1, tail_init);
     }
     for (int i=min_order; i<=max_order; ++i) {
         tails[i].broadcast(comm,root);
     }
 }