Related articles |
---|
Simulating memory accesses punter_pun@yahoo.com (2004-03-06) |
Re: Simulating memory accesses alex@iliasov.org (2004-03-11) |
Re: Simulating memory accesses vbdis@aol.com (2004-03-11) |
From: | vbdis@aol.com (VBDis) |
Newsgroups: | comp.compilers |
Date: | 11 Mar 2004 13:02:56 -0500 |
Organization: | AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com |
References: | 04-03-023 |
Keywords: | storage |
Posted-Date: | 11 Mar 2004 13:02:56 EST |
punter_pun@yahoo.com (Adi) schreibt:
>Is there any other solution to bypass these unwanted accesses like
>storing value of i in registers etc... ?
I see no solution, as long as the addresses are stored in an array. In the case
of your simple array initialization you could move the code
a[i] = a[i-1]+16; //storing the addresses in the array
into the final loop, incrementing the address by 16 for every iteration. Any
halfways optimizing compiler should be able to hold the index in a register ;-)
In a more complex case you can use some random number algorithm to calculate
the next address on the fly.
As long as no address is accessed more than once, and provided that a test
array of pointers, or of indices, is acceptable instead of an array of chars,
you can store in the test array the index or address of the next memory
location to be accessed.
i=x[i]; //until i==sentinel
or
p=*p; //until p==NULL
For a more general solution write the unrolled test loop as code into an source
file, compile and link...
BTW, I wonder what you want to explore with your program?
For a dumb CPU you can sum up the clock cycles from the instruction set
documentation, whereas on clever systems, with multitasking and caches, the
results can vary with every single run. In "life" programs many more memory
references will occur, to the actual code and with every subroutine call also
to the stack.
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.