# Mpiallreduce probelm

**URL:** https://community.freefem.org/t/mpiallreduce-probelm/1290
**Category:** General Discussion
**Created:** [October 28, 2021, 3:43pm UTC](https://community.freefem.org/t/mpiallreduce-probelm/1290 "2021-10-28T15:43:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zcwang6](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zcwang6/32/371_2.png) [@zcwang6](https://community.freefem.org/u/zcwang6)
#### Post date: [October 28, 2021, 3:43pm UTC](https://community.freefem.org/t/mpiallreduce-probelm/1290/1 "2021-10-28T15:43:44Z")

</div>

Hello there, a quick question about MPIALLREDUCE; I used this function in the following script

mpiComm Comm(mpiCommWorld, 0, 0);

real nubl = mpirank;  
real nubg=0;

mpiAllReduce(nubg, nubl, mpiCommWorld, mpiSUM);

cout \<\< “finnal SUM " \<\< nubg \<\< " elements” \<\< " mpi "\<\< mpirank \<\< " has " \<\< nubl \<\< endl;

real[int] S1(4),S2(4),S(4);  
real MP;  
MP = mpirank\*2;  
S = [0,0,0,0];  
S2 = [MP,MP,MP,MP];

mpiAllReduce(S,S2, mpiCommWorld, mpiSUM);

cout \<\< S \<\< endl;

the data types are real and real[int]; it seems mpiALLReduce reinitialized my data; But I believe this function works fine when I am doing domain decomposition method;

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [October 28, 2021, 3:55pm UTC](https://community.freefem.org/t/mpiallreduce-probelm/1290/2 "2021-10-28T15:55:01Z")

</div>

You are switching all parameters, it is `mpiAllReduce(in, out...)`, not `mpiAllReduce(out, in...)`.

---

<div class="post-metadata">

### Author: ![zcwang6](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zcwang6/32/371_2.png) [@zcwang6](https://community.freefem.org/u/zcwang6)
#### Post date: [October 28, 2021, 4:01pm UTC](https://community.freefem.org/t/mpiallreduce-probelm/1290/3 "2021-10-28T16:01:43Z")

</div>

damn it, Thx for pointing it out; 😂
