boostorg / boostorg/mpi

Reduce with Lambdas

Open
#128 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
64
Forks
65
PR merge metrics
No merged PRs in 30d

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
#include
#include
namespace mpi = boost::mpi;

#include
#include

int main()
{
mpi::environment env;
mpi::communicator world;

{
int a=1;
int s = mpi::all_reduce(world,a,std::plus()); // ok

std::vector v{1,2,3};
int s2 = std::accumulate(v.begin(),v.end(),0,std::plus()); // 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 v{1,2,3};
int s2 = std::accumulate(v.begin(),v.end(),0,[](int x,int y){return x+y;}); // ok
}
return 0;
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.