[Swift-user] How to wait on functions that return no data?
Mihael Hategan
hategan at mcs.anl.gov
Tue Mar 25 10:00:54 CDT 2008
On Tue, 2008-03-25 at 09:46 -0500, Michael Wilde wrote:
> For the petro-model app Im working on, it would be interesting to run
> the parameter sweep in "map reduce" manner, in which each invocation
> bites off a portion of the parameter space and processes it, resulting
> in a set of result tuples. Each run of the model will produce a set of
> tuples, and when all are done, we want to aggregate and plot the tuples.
>
> While with batching this is not strictly needed, it would be interesting
> to let the model results accumulate on the local filesystem (as in this
> case they are small) and collect them either at the end of the run, or
> periodically and perhaps asynchronously during the run.
>
> To do this, we'd want to write the model invocation as a swift function
> with only scalar numeric parameters, and no output.
That assertion I'm not sure about.
>
> The question is how to call a zero-returns function in a swift foreach()
> loop, and embed that foreach() in a function that doesnt return until
> all members of the foreach() have been processed.
The very notion of "return" as it would appear in a strict language
doesn't make much sense in Swift, so I'm not quite sure.
>
> I havent tried to code this yet, because I cant think of a way to
> express it in swift, due to the data-dependency semantics.
>
> In the example below, I want collectResults() to get invoked after all
> the runam() calls complete in doall().
results = doall();
collectResults(results);
Mihael
>
> Anyone have any ideas?
>
> This is a low-priority question, just food for thought, as the batched
> way of running this parameter sweep should be straightforward and efficient.
>
> Mike
>
>
>
> // Amiga-Mars Parameter Sweep
>
> type amout;
>
> runam (string id , string p1, string p2) // no ret val
> {
> app { runam3 id p1 p2 ; }
> }
>
> type params {
> string id;
> string p1;
> string p2;
> };
>
> doall(params p[])
> {
> foreach pset in p {
> runam(pset.id, pset.p1, pset.p2);
> }
> // waitTillAllDone();
> // want to block here till all above finish,
> // but no data to wait on. any way to
> // achieve this???
> }
>
> // Main
>
> params p[];
> p = readdata("paramlist");
> doall(p);
> amout amdata <some mapping>;
> amdata = collectResults();
>
> // ^^^ Want collectresults to run AFTER all runam() calls finish
> // in the doall() function.
>
>
>
>
>
>
> _______________________________________________
> Swift-user mailing list
> Swift-user at ci.uchicago.edu
> http://mail.ci.uchicago.edu/mailman/listinfo/swift-user
>
More information about the Swift-user
mailing list