Locality Optimization Algorithms for Compilation of Out-of-Core Codes