[Swift-user] How to wait on functions that return no data?
Michael Wilde
wilde at mcs.anl.gov
Tue Mar 25 09:46:14 CDT 2008
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.
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.
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().
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.
More information about the Swift-user
mailing list