[Swift-devel] Possible bug with iteration in stable branch

wilde at mcs.anl.gov wilde at mcs.anl.gov
Tue Jun 1 09:44:37 CDT 2010


David, you can find some discussion on this issue in the swift-devel and/or swift-user archives. Im forwarding two relevant messages on it, below.

We should review these and decide if this issue should just be documented for now, including an example of the typical problem and its remedy. We need to think about whether this behavior could and should be improved.

- Mike


----- Forwarded Message -----
From: "Ben Clifford" <benc at hawaga.org.uk>
To: "Erin Hodgess" <HodgessE at uhd.edu>
Cc: swift-user at ci.uchicago.edu
Sent: Tuesday, June 16, 2009 5:26:25 PM GMT -06:00 US/Canada Central
Subject: Re: [Swift-user] still stuck on fold9.swift


On Tue, 16 Jun 2009, Hodgess, Erin wrote:

> Ok.  We're back to fold9.swift again, but it's saying that there are 
> multiple writers.
> These are in /home/erin/swift1.
> 
> Is it because of the recursive nature of the a[v+1] setup, maybe?

This is a static compile time analysis problem - Swift looks at the source 
code and sees that you are assigning to the a[] array in one place (the 
a[0] statement, outside of iterate) and again in another place (the a[v+1] 
place inside of iterate).

Its bothered me in the past that this hasn't worked, but I hadn't realised 
that it did at one stage actually work (which it must have done to be 
written in the tutorial).

Its probably useful to file a bug about this, then - its a comment I have 
from doing things with the 3rd provenance challenge over the past couple 
of months too. I think in the long term its a use that should be accepted, 
but the syntax of Swift makes this kind of analysis incredibly awkward to 
get right.

You can maybe around this by something like this (untested):

replace 

  a[v+1] = countstep(a[v]);  

with
  if(v==0) { a[v+1] = countstep(startfile); } 
  else { a[v+1] = countstep(a[v]); } 

and replace the a[0] assignment line with:

countfile startfile = echo("793578934574893");


-- 
_______________________________________________
Swift-user mailing list
Swift-user at ci.uchicago.edu
http://mail.ci.uchicago.edu/mailman/listinfo/swift-user

----

----- Forwarded Message -----
From: "Michael Wilde" <wilde at mcs.anl.gov>
To: "Tiberiu Stef-Praun" <tiberius at ci.uchicago.edu>
Cc: "swift-devel" <swift-devel at ci.uchicago.edu>, swift-user at ci.uchicago.edu
Sent: Wednesday, February 17, 2010 10:56:33 AM GMT -06:00 US/Canada Central
Subject: Re: [Swift-devel] Problem with iterate

Tibi, while it may not be the most elegant approach, I think you need to put all statements that set the array statePathFiles *inside* the loop, and conditionally execute the setting of element 0 using an if statement.

- Mike


----- "Tiberiu Stef-Praun" <tiberius at ci.uchicago.edu> wrote:

> Hi Guys
> 
> I have put together this really simple iteration example, which I
> expected to work (and it used to work in the past):
> 
> ==============
> type file;
> 
> app (file initOut) initFunc (string inputString){
> echo inputString stdout=@filename(initOut);
> }
> 
> app (file catOut) catFunc (file catIn){
> cat @filename(catIn) @filename(catOut);
> }
> 
> runLoop(){
> 
> file statePathFiles[]<concurrent_mapper; prefix="statePathName.",
> suffix=".mat">;
> 
> statePathFiles[0]=initFunc("hello");
> 
> iterate it{
> trace(@strcat("Iteration: ",it));
> statePathFiles[it+1]=catFunc(statePathFiles[it]);
> } until (it==0);
> }
> 
> runLoop();
> ================
> 
> However, I get an error like this:
> 
> Running UC Eval
> Could not start execution.
> variable statePathFiles has multiple writers.
> 
> 
> Please suggest solutions for it .
> 
> Thank you
> Tibi
> 
> 
> 
> --
> Tiberiu (Tibi) Stef-Praun, PhD
> Computational Sciences Researcher
> Computation Institute
> 5640 S. Ellis Ave, #405
> University of Chicago
> http://www-unix.mcs.anl.gov/~tiberius/
> 
> ____________________
-- 
Michael Wilde
Computation Institute, University of Chicago
Mathematics and Computer Science Division
Argonne National Laboratory


----- "David Kelly" <dk0966 at cs.ship.edu> wrote:

> Hello,
> 
> I believe there may be a bug with iteration in the stable branch of
> Swift. Below is the code I am using (which came from the swift
> tutorial):
> 
> iterate.swift
> -----------------
> type counterfile;
> 
> (counterfile t) echo(string m) {
> app {
> echo m stdout=@filename(t);
> }
> }
> 
> (counterfile t) countstep(counterfile i) {
> app {
> wcl @filename(i) @filename(t);
> }
> }
> 
> counterfile a[] <simple_mapper;prefix="foldout">;
> 
> a[0] = echo("793578934574893");
> 
> iterate v {
> a[v+1] = countstep(a[v]);
> trace("extract int value ", at extractint(a[v+1]));
> } until (@extractint(a[v+1]) <= 1);
> ----------------
> 
> wcl
> ---------
> #!/bin/bash
> echo -n $(wc -c < $1) > $2
> ---------
> 
> Using the development version of swift the script works correctly,
> with the following output:
> 
> Swift svn swift-r3335 cog-r2752
> 
> RunID: 20100528-1243-6on02joa
> Progress:
> SwiftScript trace: extract int value , 16.0
> SwiftScript trace: extract int value , 2.0
> SwiftScript trace: extract int value , 1.0
> Final status: Finished successfully:4
> 
> However, when I use the stable branch (either using the tar.gz or by
> downloading from svn) I get:
> 
> Could not start execution.
> variable a has multiple writers.
> 
> 
> 
> 
> _______________________________________________
> Swift-devel mailing list
> Swift-devel at ci.uchicago.edu
> http://mail.ci.uchicago.edu/mailman/listinfo/swift-devel

-- 
Michael Wilde
Computation Institute, University of Chicago
Mathematics and Computer Science Division
Argonne National Laboratory




More information about the Swift-devel mailing list