Scott,

First of all, I don't see how foreach may increase parallelism in this
case, as the swap happen for varying values, not for scalars. I.e. the
following code fragment
        float aux[2];
        aux[0] = c[2*x + 0];
        aux[1] = c[2*x + 1];
        c[2*x + 0] = c[2*y + 0];
        c[2*x + 1] = c[2*y + 1];
        c[2*y + 0] = aux[0];
        c[2*y + 1] = aux[1];
 operates on vectors. x and y are vectors, so all accesses to "c" are
effectively gathers.

As for why foreach behaves differently than "serial" version. Documentation
for foreach states that nested foreach not supported. It's not
exactly accurate statement. The accurate statement would be that foreach
reestablishes execution mask and for the context, which already has an
execution mask, which is intended to be preserved, this will cause
unpredictable effects.

Practically speaking, you can use "printf("x=%, y=%\n", x, y);" to print
the real values in both cases and see that the behaviour is not the one
that you expect. Note that printed values in double braces are masked out.

Dmitry.

On Thu, Sep 20, 2018 at 11:13 AM Scott Pakin <[email protected]> wrote:

> Pete,
>
> Thanks for the response.
>
> On Thursday, September 20, 2018 at 11:56:39 AM UTC-6, Pete Brubaker wrote:
>>
>> I think the problem here is that essentially you are nesting foreach
>> loops, which is not supported.
>>
>
> That had crossed my mind, but (a) I figured that the documentation meant
> literally foreach…foreach, not merely constructs that can be transformed
> into that, and (b) I seem to recall the compiler complaining when I last
> tried to nest foreach loops, so I concluded that the lack of an error
> message implies that the problem must lie elsewhere.
>
> If implicitly nested foreach loops is indeed the problem, is there any way
> to restructure the code to exploit a bit more concurrency, or do I just
> have to stick with my initial implementation?
>
> — Scott
>
> --
> You received this message because you are subscribed to the Google Groups
> "Intel SPMD Program Compiler Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Intel SPMD Program Compiler Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to