Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 394
    • Issues 394
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 16
    • Merge requests 16
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #1445
Closed
Open
Created May 10, 2007 by Robert Bernecky@rbeDeveloper

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
Assignee
Assign to
Time tracking