mirror of
https://github.com/triqs/dft_tools
synced 2024-10-31 19:23:45 +01:00
API change in mpi: rename allreduce -> all_reduce
This commit is contained in:
parent
f4220efaea
commit
2705353f1d
@ -74,7 +74,7 @@ int main(int argc, char* argv[]) {
|
||||
out <<" Reduce "<< std::endl;
|
||||
out << " r1 = " << r1 << std::endl;
|
||||
|
||||
ARR r2 = mpi::allreduce(A, world);
|
||||
ARR r2 = mpi::all_reduce(A, world);
|
||||
out <<" AllReduce "<< std::endl;
|
||||
out << " r2 = " << r2 << std::endl;
|
||||
|
||||
|
@ -57,7 +57,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
{
|
||||
out<< "all reduction "<< std::endl;
|
||||
gf<imfreq> g2 = mpi::allreduce(g1, world);
|
||||
gf<imfreq> g2 = mpi::all_reduce(g1, world);
|
||||
out << g2.data()<<std::endl;
|
||||
out << g2.singularity() << std::endl;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "./mpi/arrays.hpp"
|
||||
#include "./mpi/vector.hpp"
|
||||
#include "./mpi/gf.hpp"
|
||||
|
||||
#ifndef TRIQS_C11
|
||||
#include "./mpi/generic.hpp"
|
||||
|
@ -88,7 +88,7 @@ namespace mpi {
|
||||
}
|
||||
|
||||
//---------
|
||||
static void allreduce_in_place(communicator c, A &a, int root) {
|
||||
static void all_reduce_in_place(communicator c, A &a, int root) {
|
||||
check_is_contiguous(a);
|
||||
// assume arrays have the same size on all nodes...
|
||||
MPI_Allreduce(MPI_IN_PLACE, a.data_start(), a.domain().number_of_elements(), D(), MPI_SUM, c.get());
|
||||
@ -148,7 +148,7 @@ namespace arrays {
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
void _invoke(triqs::mpi::tag::allreduce) {
|
||||
void _invoke(triqs::mpi::tag::all_reduce) {
|
||||
lhs.resize(laz.domain());
|
||||
MPI_Allreduce((void *)laz.ref.data_start(), (void *)lhs.data_start(), laz.ref.domain().number_of_elements(), D(), MPI_SUM, laz.c.get());
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace mpi {
|
||||
/// a tag for each operation
|
||||
namespace tag {
|
||||
struct reduce {};
|
||||
struct allreduce {};
|
||||
struct all_reduce {};
|
||||
struct scatter {};
|
||||
struct gather {};
|
||||
struct allgather {};
|
||||
@ -99,7 +99,7 @@ namespace mpi {
|
||||
template <typename T>
|
||||
AUTO_DECL gather(T const &x, communicator c = {}, int root = 0) RETURN(mpi_impl<T>::invoke(tag::gather(), c, x, root));
|
||||
template <typename T>
|
||||
AUTO_DECL allreduce(T const &x, communicator c = {}, int root = 0) RETURN(mpi_impl<T>::invoke(tag::allreduce(), c, x, root));
|
||||
AUTO_DECL all_reduce(T const &x, communicator c = {}, int root = 0) RETURN(mpi_impl<T>::invoke(tag::all_reduce(), c, x, root));
|
||||
template <typename T>
|
||||
AUTO_DECL allgather(T const &x, communicator c = {}, int root = 0) RETURN(mpi_impl<T>::invoke(tag::allgather(), c, x, root));
|
||||
|
||||
@ -132,7 +132,7 @@ namespace mpi {
|
||||
return b;
|
||||
}
|
||||
|
||||
static T invoke(tag::allreduce, communicator c, T a, int root) {
|
||||
static T invoke(tag::all_reduce, communicator c, T a, int root) {
|
||||
T b;
|
||||
MPI_Allreduce(&a, &b, 1, D(), MPI_SUM, c.get());
|
||||
return b;
|
||||
@ -142,7 +142,7 @@ namespace mpi {
|
||||
MPI_Reduce((c.rank() == root ? MPI_IN_PLACE : &a), &a, 1, D(), MPI_SUM, root, c.get());
|
||||
}
|
||||
|
||||
static void allreduce_in_place(communicator c, T &a, int root) {
|
||||
static void all_reduce_in_place(communicator c, T &a, int root) {
|
||||
MPI_Allreduce(MPI_IN_PLACE, &a, 1, D(), MPI_SUM, root, c.get());
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace mpi {
|
||||
return b;
|
||||
}
|
||||
|
||||
static T invoke(tag::allreduce, communicator c, T const &a, int root) {
|
||||
static T invoke(tag::all_reduce, communicator c, T const &a, int root) {
|
||||
T b;
|
||||
boost::mpi::all_reduce(c, a, b, std::c14::plus<>());
|
||||
return b;
|
||||
|
@ -20,6 +20,7 @@
|
||||
******************************************************************************/
|
||||
#pragma once
|
||||
#include "./base.hpp"
|
||||
#include "./arrays.hpp"
|
||||
|
||||
namespace triqs {
|
||||
namespace mpi {
|
||||
@ -36,9 +37,9 @@ namespace mpi {
|
||||
}
|
||||
|
||||
//---------
|
||||
/*static void allreduce_in_place(communicator c, G &g, int root) {
|
||||
triqs::mpi::allreduce_in_place(c, g.data(), root);
|
||||
triqs::mpi::allreduce_in_place(c, g.singularity(), root);
|
||||
/*static void all_reduce_in_place(communicator c, G &g, int root) {
|
||||
triqs::mpi::all_reduce_in_place(c, g.data(), root);
|
||||
triqs::mpi::all_reduce_in_place(c, g.singularity(), root);
|
||||
}
|
||||
*/
|
||||
|
||||
@ -60,10 +61,10 @@ namespace mpi {
|
||||
return target;
|
||||
}
|
||||
|
||||
//---- allreduce ----
|
||||
static G &complete_operation(G &target, mpi_lazy<tag::allreduce, G> laz) {
|
||||
target._data = mpi::allreduce(laz.ref.data(), laz.c, laz.root);
|
||||
target._singularity = mpi::allreduce(laz.ref.singularity(), laz.c, laz.root);
|
||||
//---- all_reduce ----
|
||||
static G &complete_operation(G &target, mpi_lazy<tag::all_reduce, G> laz) {
|
||||
target._data = mpi::all_reduce(laz.ref.data(), laz.c, laz.root);
|
||||
target._singularity = mpi::all_reduce(laz.ref.singularity(), laz.c, laz.root);
|
||||
return target;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace mpi {
|
||||
MPI_Reduce((c.rank() == root ? MPI_IN_PLACE : a.data()), a.data(), a.size(), D(), MPI_SUM, root, c.get());
|
||||
}
|
||||
|
||||
static void allreduce_in_place(communicator c, std::vector<T> &a, int root) {
|
||||
static void all_reduce_in_place(communicator c, std::vector<T> &a, int root) {
|
||||
MPI_Allreduce(MPI_IN_PLACE, a.data(), a.size(), D(), MPI_SUM, root, c.get());
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ namespace mpi {
|
||||
}
|
||||
|
||||
// -----------
|
||||
static std::vector<T> invoke(tag::allreduce, communicator c, std::vector<T> const &a, int root) {
|
||||
static std::vector<T> invoke(tag::all_reduce, communicator c, std::vector<T> const &a, int root) {
|
||||
std::vector<T> b(a.size());
|
||||
MPI_Allreduce(a.data(), b.data(), a.size(), D(), MPI_SUM, root, c.get());
|
||||
return b;
|
||||
@ -95,7 +95,7 @@ namespace mpi {
|
||||
// -----------
|
||||
|
||||
static std::vector<T> invoke(tag::allgather, communicator c, std::vector<T> const &a, int root) {
|
||||
long size = allreduce(a.size(), c, root);
|
||||
long size = all_reduce(a.size(), c, root);
|
||||
std::vector<T> b(size);
|
||||
|
||||
auto recvcounts = std::vector<int>(c.size());
|
||||
|
Loading…
Reference in New Issue
Block a user