[Swift-devel] Standard Library Proposal/Discussion Page

Mihael Hategan hategan at mcs.anl.gov
Thu Jan 22 01:12:40 CST 2015


On Thu, 2015-01-22 at 00:26 -0600, Tim Armstrong wrote:
> I agree that the language can pick whatever schedule with whatever degree
> of parallelism as long as it satisfies the partial order defined by data
> flow and there are no false control dependencies inserted that will prevent
> progress.

Right. There would be no false dependencies. But if the user has a data
dependency 

a[i + 1] = f(a[i])

then we can't say that they shouldn't. So the issue is not what
dependencies are there but whether we would allow that statement to be
written as "a = f(a)". This would allow nothing that isn't already
allowed.

We should probably drop this though. I think we went past usefulness and
I do think that a functional approach is more clear and easy to
implement, it has no blanks to fill in, and is almost certainly less
contentious.

[...]
> in the loop body to prevent them from doing so, since otherwise the program
> might fail to make progress when it should, or even deadlock if there is
> some sort of recursive dependency where the array being iterated over
> depends directly or indirectly on the computation in the loop body.

Hmm. Maybe I shouldn't point out that K allows this already and perhaps
this is the missing piece in the conversation. You can write the
following code:

float a[];
a[0] = 10;

foreach v, k in a {
  if (a[k] > 0.01) {
    a[k + 1] = f(a[k]);
  }
}

It's meant as a pure dataflow replacement for iterate{}.

Mihael




More information about the Swift-devel mailing list