From c60340d67e86bd3cc6e2e48143d7af403f7e1aca Mon Sep 17 00:00:00 2001 From: bonachea Date: Sun, 21 Dec 2025 13:32:47 -0500 Subject: [PATCH 1/7] sort refs --- drafts/local-reduce-edits.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drafts/local-reduce-edits.txt b/drafts/local-reduce-edits.txt index e9ebe2e..ed789c8 100644 --- a/drafts/local-reduce-edits.txt +++ b/drafts/local-reduce-edits.txt @@ -2,7 +2,7 @@ To: J3 J3/26-103 From: Brandon Cook & Dan Bonachea Subject: US20: Edits for Local Prefix Operation Intrinsics Date: 2025-December-19 -References: 25-145r1, 25-186r2, 25-195r1, WG5/N-2249, 25-196r1, 25-007r1 +References: 25-145r1, 25-186r2, 25-195r1, 25-196r1, 25-007r1, WG5/N-2249 1. Background ============= From de74f8aa83097f0ce8b1d9a860a8ec3030333e71 Mon Sep 17 00:00:00 2001 From: bonachea Date: Sun, 21 Dec 2025 13:35:51 -0500 Subject: [PATCH 2/7] intrinsic section headers: make line breaks more consistent --- drafts/local-reduce-edits.txt | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drafts/local-reduce-edits.txt b/drafts/local-reduce-edits.txt index ed789c8..3623c51 100644 --- a/drafts/local-reduce-edits.txt +++ b/drafts/local-reduce-edits.txt @@ -71,9 +71,8 @@ SUM_PREFIX_INCLUSIVE(ARRAY, DIM [, MASK]) [469:21+] In 16.9 Specifications of the standard intrinsic procedures, after the specification of REDUCE, add: -16.9.173a \ -REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL [, ORDERED]) or -REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL, DIM [, ORDERED]) +16.9.173a REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL [, ORDERED]) or \ + REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL, DIM [, ORDERED]) <> General exclusive prefix reduction of array. @@ -160,9 +159,8 @@ Case (ii): If A is the array | 2 2 3 4 | then REDUCE_PREFIX_EXCLUSIVE(A, MULT, INITIAL=1, DIM=2) is | 1 2 4 12 | | 1 2 2 4 |. -16.9.173b \ -REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION [, ORDERED]) or -REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION, DIM [, ORDERED]) +16.9.173b REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION [, ORDERED]) or \ + REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION, DIM [, ORDERED]) <> General inclusive prefix reduction of array. @@ -249,9 +247,8 @@ Case (ii): If A is the array | 2 3 5 | [482:26+] In 16.9 Specifications of the standard intrinsic procedures, after the specification of SUM, add: -16.9.201a \ -SUM_PREFIX_EXCLUSIVE(ARRAY [, MASK]) or \ -SUM_PREFIX_EXCLUSIVE(ARRAY, DIM [, MASK]) +16.9.201a SUM_PREFIX_EXCLUSIVE(ARRAY [, MASK]) or \ + SUM_PREFIX_EXCLUSIVE(ARRAY, DIM [, MASK]) <> Exclusive prefix sum of array. @@ -310,9 +307,8 @@ Case (iii): If A is | 1 2 3 | which is | 0 1 3 | | 0 4 9 |. -16.9.201b \ -SUM_PREFIX_INCLUSIVE(ARRAY [, MASK]) or \ -SUM_PREFIX_INCLUSIVE(ARRAY, DIM [, MASK]) +16.9.201b SUM_PREFIX_INCLUSIVE(ARRAY [, MASK]) or \ + SUM_PREFIX_INCLUSIVE(ARRAY, DIM [, MASK]) <> Inclusive prefix sum of array. From 82d81dc01ad20a18f7d2d40484e032d896e850bb Mon Sep 17 00:00:00 2001 From: bonachea Date: Sun, 21 Dec 2025 13:37:41 -0500 Subject: [PATCH 3/7] REDUCE_PREFIX_EXCLUSIVE: Fix order in argument listing --- drafts/local-reduce-edits.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drafts/local-reduce-edits.txt b/drafts/local-reduce-edits.txt index 3623c51..08fa108 100644 --- a/drafts/local-reduce-edits.txt +++ b/drafts/local-reduce-edits.txt @@ -92,12 +92,12 @@ OPERATION shall be a pure function with exactly two arguments; each argument commutative. If ORDERED is absent or false, then OPERATION should implement a mathematically associative operation. +INITIAL shall be scalar with the same declared type and type parameters as + ARRAY. + DIM shall be an integer scalar with a value in the range 1 <= DIM <= n, where n is the rank of ARRAY. -INITIAL shall be scalar with the same declared type and type - parameters as ARRAY. - ORDERED (optional) shall be a logical scalar. <> If OPERATION is not computationally associative, From e0e46d926df4fd3ff8f267b370991c9ca2a45c96 Mon Sep 17 00:00:00 2001 From: bonachea Date: Sun, 21 Dec 2025 13:46:06 -0500 Subject: [PATCH 4/7] Misc polish --- drafts/local-reduce-edits.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drafts/local-reduce-edits.txt b/drafts/local-reduce-edits.txt index 08fa108..9cbfc05 100644 --- a/drafts/local-reduce-edits.txt +++ b/drafts/local-reduce-edits.txt @@ -109,8 +109,8 @@ ORDERED (optional) shall be a logical scalar. <> -The result is of the same declared type, type parameters, rank, -and shape as ARRAY. +The result is of the same declared type, type parameters, rank, and shape as +ARRAY. <> @@ -213,7 +213,7 @@ Case (i): The result of REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION) is the of the two selected items in the sequence with the value OPERATION(x, y), preserving order. If the ORDERED argument is present with the value true, then x is the first item in the sequence. Otherwise, the - choice of x is processor dependent. When the sequence has a single + choice of x is processor-dependent. When the sequence has a single item, that is the result. Case (ii): If ARRAY has rank one, then the result of From f2eef5a59efda94a3ea0b9637983a1b2b08f7b97 Mon Sep 17 00:00:00 2001 From: bonachea Date: Sun, 21 Dec 2025 13:55:50 -0500 Subject: [PATCH 5/7] Normalize the use of keyword arguments in equivalence prose The convention appears to be that initial arguments appearing in the same position in all forms are passed positionally, and all subsequent arguments are passed by keyword, presumably to avoid possible ambiguity. --- drafts/local-reduce-edits.txt | 44 ++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drafts/local-reduce-edits.txt b/drafts/local-reduce-edits.txt index 9cbfc05..f384ad2 100644 --- a/drafts/local-reduce-edits.txt +++ b/drafts/local-reduce-edits.txt @@ -133,17 +133,18 @@ Case (i): The result of REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL) is sequence has a single item, that is the result. Case (ii): If ARRAY has rank one, then the result of - REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL, DIM [, ORDERED]) - has a value equal to REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, - INITIAL [, ORDERED]). Otherwise, the result of - REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL, DIM [, ORDERED]) - is defined by the semantics of Case (i) applied independently along + REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL, DIM = DIM + [, ORDERED = ORDERED ]) has a value equal to + REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL [, ORDERED = + ORDERED]). Otherwise, the result of REDUCE_PREFIX_EXCLUSIVE(ARRAY, + OPERATION, INITIAL, DIM = DIM [, ORDERED = ORDERED]) is defined by + the semantics of Case (i) applied independently along each sequence of ARRAY elements in dimension DIM. The value of result elements (i_1,i_2,...,i_(DIM-1),:,i_(DIM+1),...,i_n) of - REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL, DIM [, ORDERED = - ORDERED]) is equal to REDUCE_PREFIX_EXCLUSIVE( - ARRAY(i_1,i_2,...,i_(DIM-1),:,i_(DIM+1),...,i_n), OPERATION = - OPERATION, INITIAL = INITIAL, DIM = 1 [, ORDERED = ORDERED] ). + REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL, DIM = DIM + [, ORDERED = ORDERED]) is equal to REDUCE_PREFIX_EXCLUSIVE( + ARRAY(i_1,i_2,...,i_(DIM-1),:,i_(DIM+1),...,i_n), OPERATION, INITIAL, + DIM = 1 [, ORDERED = ORDERED] ). <> The generalized noncommutative reduction described above matches the iterative process specified for REDUCE. @@ -217,17 +218,18 @@ Case (i): The result of REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION) is the item, that is the result. Case (ii): If ARRAY has rank one, then the result of - REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION, DIM [, ORDERED]) has a - value equal to REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION [, ORDERED]). - Otherwise, the result of REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION, - DIM [, ORDERED]) is defined by the semantics of Case (i) applied + REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION, DIM = DIM [, ORDERED = + ORDERED]) has a value equal to REDUCE_PREFIX_INCLUSIVE(ARRAY, + OPERATION [, ORDERED = ORDERED]). Otherwise, the result of + REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION, DIM = DIM [, ORDERED = + ORDERED]) is defined by the semantics of Case (i) applied independently along each sequence of ARRAY elements in dimension DIM. The value of result elements (i_1,i_2,...,i_(DIM-1),:,i_(DIM+1),...,i_n) of - REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION, DIM [, ORDERED = ORDERED]) - is equal to REDUCE_PREFIX_INCLUSIVE( - ARRAY(i_1,i_2,...,i_(DIM-1),:,i_(DIM+1),...,i_n), OPERATION = - OPERATION, DIM = 1 [, ORDERED = ORDERED] ). + REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION, DIM =DIM [, ORDERED = + ORDERED]) is equal to REDUCE_PREFIX_INCLUSIVE( + ARRAY(i_1,i_2,...,i_(DIM-1),:,i_(DIM+1),...,i_n), OPERATION, DIM = 1 + [, ORDERED = ORDERED] ). <> The generalized noncommutative reduction described above matches the iterative process specified for REDUCE. @@ -289,8 +291,8 @@ Case (iii): If ARRAY has rank one, the result of SUM_PREFIX_EXCLUSIVE(ARRAY, (i_1, i_2, ..., i_{DIM-1}, :, i_{DIM+1}, ..., i_n) of SUM_PREFIX_EXCLUSIVE(ARRAY, DIM = DIM [, MASK = MASK]) is equal to SUM_PREFIX_EXCLUSIVE(ARRAY(i_1, i_2, ..., i_{DIM-1}, :, i_{DIM+1}, - ..., i_n), DIM = 1 [, MASK(i_1, i_2, ..., i_{DIM-1}, :, i_{DIM+1}, - ..., i_n)]) + ..., i_n), DIM = 1 [, MASK = MASK(i_1, i_2, ..., i_{DIM-1}, :, + i_{DIM+1}, ..., i_n)]) <> @@ -349,8 +351,8 @@ Case (iii): If ARRAY has rank one, the result of SUM_PREFIX_INCLUSIVE(ARRAY, (i_1, i_2, ..., i_{DIM-1}, :, i_{DIM+1}, ..., i_n) of SUM_PREFIX_INCLUSIVE(ARRAY, DIM = DIM [, MASK = MASK]) is equal to SUM_PREFIX_INCLUSIVE(ARRAY(i_1, i_2, ..., i_{DIM-1}, :, i_{DIM+1}, - ..., i_n), DIM = 1 [, MASK(i_1, i_2, ..., i_{DIM-1}, :, i_{DIM+1}, - ..., i_n)]) + ..., i_n), DIM = 1 [, MASK = MASK(i_1, i_2, ..., i_{DIM-1}, :, + i_{DIM+1}, ..., i_n)]) <> From 4cf2032b5f0c7f106aef1e4284059c33f162320a Mon Sep 17 00:00:00 2001 From: bonachea Date: Sun, 21 Dec 2025 14:37:36 -0500 Subject: [PATCH 6/7] Excise "generalized noncommutative reduction" Define the value of each r_i in REDUCE_PREFIX without coining the term "generalized noncommutative reduction". This also shortens the description somewhat. --- drafts/local-reduce-edits.txt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drafts/local-reduce-edits.txt b/drafts/local-reduce-edits.txt index f384ad2..6cbd674 100644 --- a/drafts/local-reduce-edits.txt +++ b/drafts/local-reduce-edits.txt @@ -120,10 +120,8 @@ Case (i): The result of REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL) is result sequence provided in array element order. The exclusive prefix reduction of a sequence s_1, s_2, ..., s_n, with OPERATION and initial value INITIAL, is the sequence r_1, r_2, ..., r_n. r_1 is INITIAL, - and for i>1, r_i is the generalized noncommutative reduction with - OPERATION of the sequence INITIAL, s_1, s_2, ..., s_{i-1}. The result - of a generalized noncommutative reduction of a sequence of items with - OPERATION is the result of an iterative process. While the sequence + and for i>1, each r_i is the result of an iterative process over the + sequence INITIAL, s_1, s_2, ..., s_{i-1}. While the sequence has more than one item, each iteration involves the selection of two adjacent items x and y, with x immediately preceding y, and the subsequent replacement of the two selected items in the sequence with @@ -146,7 +144,7 @@ Case (ii): If ARRAY has rank one, then the result of ARRAY(i_1,i_2,...,i_(DIM-1),:,i_(DIM+1),...,i_n), OPERATION, INITIAL, DIM = 1 [, ORDERED = ORDERED] ). -<> The generalized noncommutative reduction described above matches the +<> The iterative process described above for each r_i matches the iterative process specified for REDUCE. <> The following examples use the function MULT, which returns the @@ -205,10 +203,8 @@ Case (i): The result of REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION) is the ARRAY in array element order, with the result sequence provided in array element order. The inclusive prefix reduction of a sequence s_1, s_2, ..., s_n, with OPERATION, is the sequence r_1, r_2, ..., - r_n. r_i is the generalized noncommutative reduction with OPERATION - of the sequence s_1, s_2, ..., s_i. The result of a generalized - noncommutative reduction of a sequence of items with OPERATION is the - result of an iterative process. While the sequence has more than one + r_n. Each r_i is the result of an iterative process over the sequence + s_1, s_2, ..., s_i. While the sequence has more than one item, each iteration involves the selection of two adjacent items x and y, with x immediately preceding y, and the subsequent replacement of the two selected items in the sequence with the value OPERATION(x, @@ -231,7 +227,7 @@ Case (ii): If ARRAY has rank one, then the result of ARRAY(i_1,i_2,...,i_(DIM-1),:,i_(DIM+1),...,i_n), OPERATION, DIM = 1 [, ORDERED = ORDERED] ). -<> The generalized noncommutative reduction described above matches the +<> The iterative process described above for each r_i matches the iterative process specified for REDUCE. <> The following examples use the function MULT, which From f5078f7b8f2493efecdbca3c5177b51cd9c77639 Mon Sep 17 00:00:00 2001 From: bonachea Date: Mon, 22 Dec 2025 15:58:08 -0500 Subject: [PATCH 7/7] REDUCE_PREFIX Case 1: Clarify that case 1 handles the optional ORDERED argument. --- drafts/local-reduce-edits.txt | 51 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/drafts/local-reduce-edits.txt b/drafts/local-reduce-edits.txt index 6cbd674..6eb6ce4 100644 --- a/drafts/local-reduce-edits.txt +++ b/drafts/local-reduce-edits.txt @@ -114,21 +114,22 @@ ARRAY. <> -Case (i): The result of REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL) is - the exclusive prefix reduction, with initial value INITIAL, of the - sequence defined by elements of ARRAY in array element order, with the - result sequence provided in array element order. The exclusive prefix - reduction of a sequence s_1, s_2, ..., s_n, with OPERATION and initial - value INITIAL, is the sequence r_1, r_2, ..., r_n. r_1 is INITIAL, - and for i>1, each r_i is the result of an iterative process over the - sequence INITIAL, s_1, s_2, ..., s_{i-1}. While the sequence - has more than one item, each iteration involves the selection of two - adjacent items x and y, with x immediately preceding y, and the - subsequent replacement of the two selected items in the sequence with - the value OPERATION(x, y), preserving order. If the ORDERED argument - is present with the value true, then x is the first item in the - sequence. Otherwise, the choice of x is processor-dependent. When the - sequence has a single item, that is the result. +Case (i): The result of REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL + [, ORDERED]) is the exclusive prefix reduction, with initial value + INITIAL, of the sequence defined by elements of ARRAY in array element + order, with the result sequence provided in array element order. The + exclusive prefix reduction of a sequence s_1, s_2, ..., s_n, with + OPERATION and initial value INITIAL, is the sequence r_1, r_2, ..., + r_n. r_1 is INITIAL, and for i>1, each r_i is the result of an + iterative process over the sequence INITIAL, s_1, s_2, ..., s_{i-1}. + While the sequence has more than one item, each iteration involves the + selection of two adjacent items x and y, with x immediately preceding + y, and the subsequent replacement of the two selected items in the + sequence with the value of OPERATION(x, y), preserving order. If the + ORDERED argument is present with the value true, then x is the first + item in the sequence. Otherwise, the choice of x is + processor-dependent. When the sequence has a single item, that is the + result. Case (ii): If ARRAY has rank one, then the result of REDUCE_PREFIX_EXCLUSIVE(ARRAY, OPERATION, INITIAL, DIM = DIM @@ -198,20 +199,20 @@ ARRAY. <> -Case (i): The result of REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION) is the - inclusive prefix reduction of the sequence defined by elements of +Case (i): The result of REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION [, ORDERED]) is + the inclusive prefix reduction of the sequence defined by elements of ARRAY in array element order, with the result sequence provided in array element order. The inclusive prefix reduction of a sequence s_1, s_2, ..., s_n, with OPERATION, is the sequence r_1, r_2, ..., r_n. Each r_i is the result of an iterative process over the sequence - s_1, s_2, ..., s_i. While the sequence has more than one - item, each iteration involves the selection of two adjacent items x - and y, with x immediately preceding y, and the subsequent replacement - of the two selected items in the sequence with the value OPERATION(x, - y), preserving order. If the ORDERED argument is present with the - value true, then x is the first item in the sequence. Otherwise, the - choice of x is processor-dependent. When the sequence has a single - item, that is the result. + s_1, s_2, ..., s_i. While the sequence has more than one item, each + iteration involves the selection of two adjacent items x and y, with x + immediately preceding y, and the subsequent replacement of the two + selected items in the sequence with the value of OPERATION(x, y), + preserving order. If the ORDERED argument is present with the value + true, then x is the first item in the sequence. Otherwise, the choice + of x is processor-dependent. When the sequence has a single item, that + is the result. Case (ii): If ARRAY has rank one, then the result of REDUCE_PREFIX_INCLUSIVE(ARRAY, OPERATION, DIM = DIM [, ORDERED =