Hi Brad,

I hadn't thought of the tuple solution, but I like it as a solution (even
with the slightly lisp-like trail of closing parens).

Were you suggesting that this should work now? I get a syntax error if I
try to pass a tuple as in your example, although if I define a tuple
variable as in the code below, it works fine.

-- Nikhil

var tup : 2*int;
> forall ii in 1..N with (+ reduce tup) {
>   tup(1) += ii;
>   tup(2) += ii*ii;
> }
> writeln(tup);




---------------------------------
Nikhil Padmanabhan
[email protected]

On Tue, Feb 28, 2017 at 12:25 PM, Brad Chamberlain <[email protected]> wrote:

>
> Belatedly: Another potential direction to take this would be to consider
> whether leaning on tuples harder would help out.  E.g., what if the
> examples were:
>
>         forall i in 1..10 with (in (x, y), + reduce (sum1, sum2))) do ...
>
> I shy away from this slightly due to knowing that our specification and
> implementation of tuples has historically had some holes, but maybe that's
> just something I need to shake if this makes sense and is attractive.
>
> -Brad
>
>
> On Tue, 28 Feb 2017, Nicholas Park wrote:
>
> Hi Nikhil,
>>
>> I think this would be a nice simplification, and I'd suggest expanding it
>> to all task intents; e.g.,
>>
>> var x = 42, y = 29;
>>>
>>> forall i in 1..10 with (in x, y) { // instead of (in x, in y)
>>
>>>
>>>  x += 2*i;
>>
>>>
>>>  y += 3*i;
>>
>>>
>>> }
>>
>>>
>>>
>> I think the programmer's intent (no pun intended) is still clear in this
>> syntax.
>>
>> Thanks,
>>
>> Nick
>>
>> On Mon, Feb 27, 2017 at 5:42 PM, Nikhil Padmanabhan <
>> [email protected]> wrote:
>>
>> Dear chapel-developers,
>>>
>>> I often find myself doing multiple reductions of the same type in forall
>>> loops (eg. multiple accumulators). The way I currently do this is to
>>> specify separate reduce intents (as in the commented line in the code
>>> below....)
>>>   (+ reduce sum1, + reduce sum2)
>>>
>>> While this works fine, it would be nice to write this as
>>>
>>>   (+ reduce sum1,sum2)
>>>
>>> or something like that (with a different delimiter, for instance).
>>>
>>> I'll note that OpenMP allows specifying such common reductions over a
>>> list
>>> of variables.
>>>
>>> Any thoughts?
>>>
>>> Thanks in advance,
>>> -- Nikhil
>>>
>>> ------------------------------------------------
>>>
>>> var sum1, sum2 = 0;
>>>
>>> config const N=100000;
>>>
>>> forall ii in 1..N with (+ reduce sum1,sum2) {
>>> //forall ii in 1..N with (+ reduce sum1, + reduce sum2) {
>>>   sum1 += ii;
>>>   sum2 += ii*ii;
>>> }
>>>
>>> writeln(sum1);
>>> writeln(sum2);
>>>
>>>
>>> ------------------------------------------------------------
>>> ------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>>> _______________________________________________
>>> Chapel-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/chapel-users
>>>
>>>
>>>
>>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to