Array reuse failure: threat or menace?
Bugzilla Link | 360 |
Created on | May 10, 2007 20:50 |
Resolution | REMIND |
Resolved on | May 15, 2007 11:52 |
Version | 1.00beta |
OS | Linux |
Architecture | PC |
Extended Description
The following function has the interesting property that, when compiled with -DFAST, it runs about 100X faster. Visual inspection at -b11 suggests that the problem appears to be, at least in part, a failure of the "r = r + val" code to see that it could work in place on r, rather than allocating a new array. --------------cut here------------ use Array: all; use String: {tochar,to_string,strtod,sprintf}; use StdIO: all; int main() { n = 1000000; r=[0]; vec = iota( n) ; lim = (shape(vec)[[0]])-1; for(i=0; i <= lim; i++){ val = vec[i]; #ifdef FAST r = modarray(r, [0], r[0] + val); #else r = r + val; #endif } print(sum(r)); return(0); }
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information