World's most popular travel blog for travel bloggers.

[Solved]: Are compilers able to detect alternating accesses to arrays and interleave them in memory?

, , No Comments
Problem Detail: 

Is it possible to design a compiler which optimizes a loop in which arrays are accessed in alternate fashion? For example like this:

// int[] a,b int sum = 0; for(int i = 0; i < n; i++) {   sum += a[i] + b[i]; } 

With the usual sequential array storage, a[i] and b[i] may be far away from each other in memory. Therefore, I think a good compiler optimization would detect that a[i] and b[i] are always accesses at the "same" time, and store the arrays interleaved, that is a[0] b[0] a[1] b[1] ... so that one memory access may retrieve both a[i] and b[i].

Asked By : krammer

Answered By : Dave Clarke

Some work has been done that matches your description. For instance:

  • Compiler-directed array interleaving for reducing energy in multi-bank memories. by Delaluz, V. Design Automation Conference, 2002. Proceedings of ASP-DAC 2002. 7th Asia and South Pacific and the 15th International Conference on VLSI Design. Proceedings.

describes a such an optimization.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/3433

3.2K people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback