[J3] Commutativity of co_reduce
Malcolm Cohen
malcolm at nag-j.co.jp
Wed Oct 23 01:17:38 UTC 2024
Hi Brad,
What operation is associative but not commutative?
Also, the answer is not deterministic anyway: the rule is "mathematically associative" not "computationally associative".
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
-----Original Message-----
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Brad Richardson via J3
Sent: Wednesday, October 23, 2024 9:47 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Brad Richardson <everythingfunctional at protonmail.com>; fortran at lbl.gov
Subject: [J3] Commutativity of co_reduce
Hi all,
The LBL group has encountered another question, this time with respect to co_reduce. At present the description of OPERATION argument states "OPERATION shall implement a mathematically associative operation." The subsequent description of how OPERATION is applied:
The computed value of a reduction operation over a set of values is the result of an iterative process. Each iteration involves the evaluation of OPERATION (x, y) for x and y in the set, the removal of x and y from the set, and the addition of the value of OPERATION (x, y) to the set.
The process terminates when the set has only one element; this is the computed value.
Of note is that the word "set" implies that there is no ordering of the values. The description also does not imply an order in which the values are combined nor does it specify what subsequent iteration consumes the result of a given combination. Thus the reduction only has a deterministic answer if OPERATION is both associative *and* commutative. We believe that it would be clearer if this requirement was stated explicitly. The edits for this would be quite simple. I.e.
[383:5] Add "and commutative" after "associative" so that the sentence reads:
OPERATION shall implement a mathematically associative and
commutative operation.
[383:29+] Delete the NOTE
Do others have opinions? Would it be reasonable to submit this change as an edits paper as just a clarifying change?
Regards,
Brad Richardson
More information about the J3
mailing list