On Thursday 10 June 2010, Han Dong wrote: > Hi, > > There's this function inside a DistArray > > > *reduce<http://dist.codehaus.org/x10/xdoc/2.0.3/x10/array/DistArray.html#re > duce%28op:%28id$10:T,%20id$11:T%29%7B%7D=> > *(x10.lang.Fun_0_2<T<http://dist.codehaus.org/x10/xdoc/2.0.3/x10/array/Dis > tArray.html> ,T > <http://dist.codehaus.org/x10/xdoc/2.0.3/x10/array/DistArray.html>,T<http: > //dist.codehaus.org/x10/xdoc/2.0.3/x10/array/DistArray.html>> op, > T <http://dist.codehaus.org/x10/xdoc/2.0.3/x10/array/DistArray.html> unit) > *Declaration*: reduce(op:(id$10:T, id$11:T){}=> Tunit:T): T. > Could anybody explain to me what does it actually do and a sample > utilization example? Is it similar to the reduce used in map reduce > applications? > > Thanks, > > Han Dong > h...@umbc.edu > University of Maryland '10 >
My understanding is the following (please anyone correct me if I am wrong). If T is (say) Double and op:(id$10:T, id$11:T){}=> Tunit:T is Double.+ then reduce computes the global sum of all elements of DistArray across all places. If T is (say) Double and op:(id$10:T, id$11:T){}=> Tunit:T is Double.* then reduce computes the global product of all elements of DistArray across all places. The order in which the operands are added or multiplied, respectively, is chosen by X10 runtime and depends on the number of places and the Distribution under DistArray. Therefore, in general any operand op:(id$10:T, id$11:T){}=> Tunit:T needs to be commutative and associative to allow for the freedom of changing the order of the reduction. Also, for Double.+ in particular, you have to make sure that the round of errors don't bite you. Albeit addition is commutative and associative in general, it no longer holds when applied to IEEE floating point numbers of finite length. All values positive is fine, a mix of positive and negative values might be dangerous. Please note that this is not restricted to X10, but true for every (!) programming language on every possible CPU (past, present and future) from every vendor. -- Mit freundlichen Grüßen / Kind regards Dr. Christoph Pospiech High Performance & Parallel Computing Phone: +49-351 86269826 Mobile: +49-171-765 5871 E-Mail: christoph.pospi...@de.ibm.com ------------------------------------- IBM Deutschland GmbH Vorsitzender des Aufsichtsrats: Erich Clementi Geschäftsführung: Martin Jetter (Vorsitzender), Reinhard Reschke, Christoph Grandpierre, Klaus Lintelmann, Michael Diemer, Martina Koederitz Sitz der Gesellschaft: Ehningen / Registergericht: Amtsgericht Stuttgart, HRB 14562 WEEE-Reg.-Nr. DE 99369940 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users