3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-01 03:33:50 +01:00

API change in mpi: rename allreduce -> all_reduce

This commit is contained in:
Hartmut Hafermann 2014-10-21 16:15:44 +02:00
parent f4220efaea
commit 2705353f1d
8 changed files with 21 additions and 19 deletions

View File

@ -74,7 +74,7 @@ int main(int argc, char* argv[]) {
out <<" Reduce "<< std::endl; out <<" Reduce "<< std::endl;
out << " r1 = " << r1 << 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 <<" AllReduce "<< std::endl;
out << " r2 = " << r2 << std::endl; out << " r2 = " << r2 << std::endl;

View File

@ -57,7 +57,7 @@ int main(int argc, char* argv[]) {
{ {
out<< "all reduction "<< std::endl; 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.data()<<std::endl;
out << g2.singularity() << std::endl; out << g2.singularity() << std::endl;
} }

View File

@ -22,6 +22,7 @@
#include "./mpi/arrays.hpp" #include "./mpi/arrays.hpp"
#include "./mpi/vector.hpp" #include "./mpi/vector.hpp"
#include "./mpi/gf.hpp"
#ifndef TRIQS_C11 #ifndef TRIQS_C11
#include "./mpi/generic.hpp" #include "./mpi/generic.hpp"

View File

@ -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); check_is_contiguous(a);
// assume arrays have the same size on all nodes... // 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()); 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()); 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()); MPI_Allreduce((void *)laz.ref.data_start(), (void *)lhs.data_start(), laz.ref.domain().number_of_elements(), D(), MPI_SUM, laz.c.get());
} }

View File

@ -70,7 +70,7 @@ namespace mpi {
/// a tag for each operation /// a tag for each operation
namespace tag { namespace tag {
struct reduce {}; struct reduce {};
struct allreduce {}; struct all_reduce {};
struct scatter {}; struct scatter {};
struct gather {}; struct gather {};
struct allgather {}; struct allgather {};
@ -99,7 +99,7 @@ namespace mpi {
template <typename T> template <typename T>
AUTO_DECL gather(T const &x, communicator c = {}, int root = 0) RETURN(mpi_impl<T>::invoke(tag::gather(), c, x, root)); AUTO_DECL gather(T const &x, communicator c = {}, int root = 0) RETURN(mpi_impl<T>::invoke(tag::gather(), c, x, root));
template <typename T> 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> template <typename T>
AUTO_DECL allgather(T const &x, communicator c = {}, int root = 0) RETURN(mpi_impl<T>::invoke(tag::allgather(), c, x, root)); 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; 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; T b;
MPI_Allreduce(&a, &b, 1, D(), MPI_SUM, c.get()); MPI_Allreduce(&a, &b, 1, D(), MPI_SUM, c.get());
return b; 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()); 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()); MPI_Allreduce(MPI_IN_PLACE, &a, 1, D(), MPI_SUM, root, c.get());
} }

View File

@ -48,7 +48,7 @@ namespace mpi {
return b; 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; T b;
boost::mpi::all_reduce(c, a, b, std::c14::plus<>()); boost::mpi::all_reduce(c, a, b, std::c14::plus<>());
return b; return b;

View File

@ -20,6 +20,7 @@
******************************************************************************/ ******************************************************************************/
#pragma once #pragma once
#include "./base.hpp" #include "./base.hpp"
#include "./arrays.hpp"
namespace triqs { namespace triqs {
namespace mpi { namespace mpi {
@ -36,9 +37,9 @@ namespace mpi {
} }
//--------- //---------
/*static void allreduce_in_place(communicator c, G &g, int root) { /*static void all_reduce_in_place(communicator c, G &g, int root) {
triqs::mpi::allreduce_in_place(c, g.data(), root); triqs::mpi::all_reduce_in_place(c, g.data(), root);
triqs::mpi::allreduce_in_place(c, g.singularity(), root); triqs::mpi::all_reduce_in_place(c, g.singularity(), root);
} }
*/ */
@ -60,10 +61,10 @@ namespace mpi {
return target; return target;
} }
//---- allreduce ---- //---- all_reduce ----
static G &complete_operation(G &target, mpi_lazy<tag::allreduce, G> laz) { static G &complete_operation(G &target, mpi_lazy<tag::all_reduce, G> laz) {
target._data = mpi::allreduce(laz.ref.data(), laz.c, laz.root); target._data = mpi::all_reduce(laz.ref.data(), laz.c, laz.root);
target._singularity = mpi::allreduce(laz.ref.singularity(), laz.c, laz.root); target._singularity = mpi::all_reduce(laz.ref.singularity(), laz.c, laz.root);
return target; return target;
} }

View File

@ -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()); 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()); 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()); std::vector<T> b(a.size());
MPI_Allreduce(a.data(), b.data(), a.size(), D(), MPI_SUM, root, c.get()); MPI_Allreduce(a.data(), b.data(), a.size(), D(), MPI_SUM, root, c.get());
return b; return b;
@ -95,7 +95,7 @@ namespace mpi {
// ----------- // -----------
static std::vector<T> invoke(tag::allgather, communicator c, std::vector<T> const &a, int root) { 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); std::vector<T> b(size);
auto recvcounts = std::vector<int>(c.size()); auto recvcounts = std::vector<int>(c.size());