-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
In the standard library lambdas can be used for reduction operations in std::accumulate.
Is there any reason why boost::mpi::all_reduce does not accept lambda functions as custom reduction operation?
Example:
#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#include <boost/mpi/collectives.hpp>
namespace mpi = boost::mpi;
#include <iostream>
#include <algorithm>
int main()
{
mpi::environment env;
mpi::communicator world;
{
int a=1;
int s = mpi::all_reduce(world,a,std::plus<int>()); // ok
std::vector<int> v{1,2,3};
int s2 = std::accumulate(v.begin(),v.end(),0,std::plus<int>()); // ok
}
{
int a=1;
//int s = mpi::all_reduce(world,a,[](int x,int y){return x+y;}); // error: deleted default constructor for lambdas
std::vector<int> v{1,2,3};
int s2 = std::accumulate(v.begin(),v.end(),0,[](int x,int y){return x+y;}); // ok
}
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels