[Swift-devel] strange behavior evaluating function call as trace arg

Michael Wilde wilde at mcs.anl.gov
Thu Feb 5 11:34:48 CST 2009


OK, thanks, that helps me get closer, but Im not quite there yet.

The "automatic parallelization scheme" (i.e. the swift dataflow model) 
works by chaining together lvalues, correct? In other words, it is the 
setting of lvalues that enables a statement waiting on a variable to get 
a value to execute. Is that correct?

Conceptually, one could view the dataflow model as existing solely in 
the memory of the swift interpreter.  The creation of files is in some 
sense a side effect of executing app procedures, and the creation of 
files within an app() and the consequent execution of assignment 
operations then results in lvalues being set, which enables execution of 
any statement waiting on an lvalue to proceed. The assignment operations 
  can be explicit (lvalue=value) or implicit (procedure return).

To fully understand this, you need to go further into the details of 
mapping, scoping, procedure activation/completion, array closing, and 
single assignment.

So to take a few steps in that direction:

Question: are the following tuples the correct abstract representations 
of lvalues and dshandles?

lvalue: type, *handle, state (set/unset) - same as handle==null?
handle: type, value(if simple type), mapping

Question: how are arrays and structures represented in this model?

Getting this into writing in a concise and correct form would be useful 
for gaining a full understanding of Swift and also help in the language 
paper.

Is it reasonable to put this into latex form and jointly edit until 
we're satisfied with it?

If so, I will do that.

It could go into a version of the language paper that we post on the 
site, while we submit a condensed version to a conference.

- Mike




On 2/5/09 10:22 AM, Mihael Hategan wrote:
> On Thu, 2009-02-05 at 16:06 +0000, Ben Clifford wrote:
>> On Thu, 5 Feb 2009, Michael Wilde wrote:
>>
>>> I dont understand this - can you clarify?
>>>
>>> I understand an "lvalue" in swift to be one of:
>>> - a var (eg var=value)
>>> - an array element (eg a[i]=value)
>>> - a struct element (eg s.a=value)
>> yes.
>>
>>> But swift procedures do indeed return a list of values, right?
>> no.
> 
> Another way of viewing this would be the following:
> 
> Returns from swift procedures are not actually returns but arguments
> passed by reference. This is there in order to support the automatic
> parallelization scheme.
> 
> So assuming 
> 
> (int s) add(int x, int y) { s = x + y; }
> int s;
> s = add(1, 2);, this translates to (in C-like pointerish pseudocode):
> 
> add(int* s, int* x, int* y) {
>   *s = *x + *y;
> }
> int *s = malloc(sizeof(int));
> add(s, newInt(1), newInt(2));
> 
> where newInt(int) allocates an int pointer, puts some value into it and
> returns the address. Pointers here are DSHandles (Swift's way of dealing
> with data).
> 



More information about the Swift-devel mailing list