[Swift-user] iterate adding dependencies
Mihael Hategan
hategan at mcs.anl.gov
Wed Jun 17 16:35:49 CDT 2015
Hi,
There is no good reason why that would be the case. The only things that
need to be serialized are the things that the "until" expression depends
on. In other words the sequencing is only so that the number of
iterations can be determined unambiguously.
So the issue should be fixed.
In the mean time, there are two workarounds I can think of:
1. Use foreach instead of iterate:
progress[0] = 0.;
step = 5;
foreach p, i in progress {
// Build executable
if (i == 0){
// Run from initial condition
output[i] = run_new();
} else {
// Resume from old run
output[i] = run_old(output[i-1]);
}
// Expensive post-processing
refined[i] = post_process(output[i]);
if (progress[i] < 100) {
progress[i+1] = progress[i] + step;
}
}
2. Move post_process outside of iterate:
progress[0] = 0.;
step = 5;
iterate i {
// Build executable
if (i == 0){
// Run from initial condition
output[i] = run_new();
} else {
// Resume from old run
output[i] = run_old(output[i-1]);
}
progress[i+1] = progress[i] + step;
} until (progress[i] < 100.);
foreach v, i in output {
// Expensive post-processing
refined[i] = post_process(output[i]);
}
Mihael
On Wed, 2015-06-17 at 20:49 +0000, Max Hutchinson wrote:
> Hello,
>
> I'm using an iterate loop like this:
>
> progress[0] = 0.;
> step = 5;
> iterate i {
> // Build executable
> if (i == 0){
> // Run from initial condition
> output[i] = run_new();
> } else {
> // Resume from old run
> output[i] = run_old(output[i-1]);
> }
> // Expensive post-processing
> refined[i] = post_process(output[i]);
> progress[i+1] = progress[i] + step;
> } until (progress[i] < 100.);
>
> run_old doesn't depend on refined, but will not run until the post_process
> application completes (which is a while; it is expensive). I'm inferring
> that iterate is sequential at the iteration-granularity.
>
> Is this intentional? I think that iterate is the natural way to express
> this computation, but the serialization of run_old wrt post_process is very
> expensive. Is there a case where the assumption that iterations are
> evaluated sequentially changes the result of the program?
>
> Max
> _______________________________________________
> Swift-user mailing list
> Swift-user at ci.uchicago.edu
> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user
More information about the Swift-user
mailing list