[Swift-devel] problems with external dependencies

Michael Wilde wilde at mcs.anl.gov
Mon Mar 23 09:56:03 CDT 2009



On 3/23/09 2:26 AM, Ben Clifford wrote:
> On Sun, 22 Mar 2009, Michael Wilde wrote:
> 
>> What statement can I use to "wait for the array to be closed before
>> executing"?
> 
> At the moment, I think the only thing that will wait for an array to be 
> closed is an app procedure taking that array as a parameter.

Ah - I keep misisng this critical point: that only *app()* procs wait 
for arrays to be closed. Compound procs dont.

> When thats a 
> file array, you will then get the file handling that you don't want.

Right, so of no use.

I dont think what you have below works. Perhaps it was fooled by a prior 
  existing datadir?  When I change your path back to my local datadir, I 
get a failure in ls, because it runs before datadir exists.

I think the problem is that generate returns as soon as the foreach 
launches its echo apps, but before they run.

I solved this problem in my later examples by putting a sync external on 
each app() invocation and waitig for them all in an iterate() loop which 
forces the generate procedure to not return till the iterate is complete 
(as far as I can tell).

This is all subtle, so my assessment above may still be flawed.

However, as far as I can tell, the iterate-wait technique seems to work; 
Ive tested it up to 2000 jobs on the bgp.


> However, its not clear from your example that you need it:
> 
> type file;
> 
> app (file o) echo (int i) { echo i stdout=@o; }
> 
> (external s, file r[]) generate() {                                              
>   int j[] = [0:10];
>   foreach i in j {
>     r[i] = echo(i*i);
>   }
> }
> 
> app (file o) ls (string dir, external w) { ls "-l" dir stdout=@o; }
> 
> file datadir[]<simple_mapper;prefix="datadir/">;
> external sync;
> (sync,datadir) = generate();
> 
> file out <"ls.out">;
> out = ls("/Users/benc/work/cog/modules/swift/datadir/", sync);
> 



More information about the Swift-devel mailing list