<div class="gmail_quote">On Tue, Apr 24, 2012 at 08:30, Jim Dinan <span dir="ltr"><<a href="mailto:dinan@mcs.anl.gov">dinan@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm not sure if I'm following all the discussion, but here's my<br>
understanding:<br>
<br>
MPI_Reduce takes an array of elements and combines all elements from<br>
every process to produce a single element of the original datatype as a<br>
result. It doesn't pick apart the datatype of each element to do a<br>
reduction on the individual basic units contained inside it. The<br>
builtin operations only understand the builtin types; if you have a<br>
derived datatype, you have to tell MPI how to combine elements of that<br>
type and produce a new one of the same type.<br>
<br>
MPI_Accumulate, on the other hand, works at the level of the basic units<br>
which are described by the datatype and applies the operation at that level.<br>
<br>
So, the operation names are the same, but Accumulate and Reduce utilize<br>
datatypes in different ways. Reduce applies the op at the level of the<br>
aggregate datatype and Accumulate applies the op at the level of the<br>
basic units in the datatype.<br>
<br>
It's an interesting suggestion to add the Accumulate interpretation to<br>
the Reduce operations. We can't break backward compatibility, so we<br>
would probably have to define a new set of operations to do the<br>
reduction at the level of the basic datatypes.<br></blockquote><div><br></div><div>It's not an API change to make something that was a run-time error become not a run-time error.</div><div><br></div><div>Let's step over the implementation issues for a moment. Does anyone want to make the claim that there shall be no (non-deprecated) way for a user to create an environment where they can write the following?</div>
<div><br></div><div>typedef std::complex<double> Complex;</div><div>MPI_Op SUM; // MPI_SUM or a new op</div><div>MPI_Datatype COMPLEX; // from MPI or created here</div><div><br></div><div>Complex a,b;</div><div><br>
</div><div>MPI_Allreduce(&a,&b,1,COMPLEX,SUM,MPI_COMM_WORLD);</div><div>MPI_Accumulate(&a,1,COMPLEX,rank,0,1,COMPLEX,SUM,window);</div><div><br></div><div>If the above is a reasonable thing for a user to request, then either (a) MPI_Accumulate must accept user-defined MPI_Ops, (b) MPI_SUM must operate on the base elements of a derived type for collectives (instead of just for MPI_Accumulate), or (c) the issue is delayed by adding a non-deprecated predefined std::complex<double> type.</div>
<div><br></div><div>I think that both (a) and (b) should be done because then we could do __float128 or quaternions without having to change the standard. (I cannot currently use __float128 with one-sided, so any time I use one-sided because it's a better algorithmic fit, I will also have to implement the algorithm using MPI-1 so that __float128 works.)</div>
</div>