We've been using iterators in a variety of ways, and have come across a "performance bug" that seems to come up when an iterator is *not* created in the header of the loop whose iteration space it defines. The memory requirement is much higher in this case, perhaps proportional to the total number of iterations? It seems to be allocating memory (on the free store heap, presumably) for each iteration, as would happen if the result of the iterator were heap-allocated rather than on the stack. The memory use grows quickly for a large iteration space, filling our RAM plus swap on our machine; some examples just run really really slowly, and others crash.

We have attached a fairly minimal Chapel program that demonstrates the difference. We are using "chpl Version 1.11.0" on Ubuntu 14.04.

Thanks,
  Dave Wonnacott & Blair Rush, Haverford College

// chpl -O help_help_im_being_oppressed.chpl -o help_help && ./help_help

var debug = false;

proc create_wire(size, low_temp){
    var wire_dom: domain(2) = {0..1,0..size-1};
    var wire_arr: [wire_dom] real;
    for i in wire_dom.dim(2) do
        wire_arr[0,i] = low_temp + (i*i)%40;
    return wire_arr;
}



iter it(T:int,X:int){
    for t in 1..T do
        for i in 0+1..X-1 do
            yield (t,i);
}


proc update_wire_standard(wire: [?D] real, air_temp, htc, hcc, ahtc, T, N)
{
    for (t,i) in it(T,N) do
        wire[t%2,i] = 0.9999 * wire[(t-1)%2,i] +20;
}

proc update_wire_iter_var(wire: [?D] real, air_temp, htc, hcc, ahtc, T, N)
{
    var iterator = it(T,N); 
    for (t,i) in iterator do
        wire[t%2,i] = 0.9999 * wire[(t-1)%2,i] +20;
}




const T = 25000;
const N = 10000;

var w = create_wire(N, 270.0);

    writeln("Why does this work, staying at O(N) memory and 100% CPU usage 
...");
   update_wire_standard(w, 280, 0.2,1.0,0.05,T,N);

    writeln("  ... and this use huge amounts of memory (over 6GB) and page like 
crazy?");
   update_wire_iter_var(w, 280, 0.2,1.0,0.05,T,N);
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Chapel-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-bugs

Reply via email to