How do I maximse the use of cache( both data and instruction ) in the
code .
comp.arch might be a better newsgroup for you, if you want
information on how various systems work with their caches (i.e.,
with a goal of writing cache-friendly code suitable for multiple
systems.) If you do not care about how cache-friendly your code is
on general systems as long as it maximizes the cache use on a
particular platform, then consult a newsgroup specific for that platform.
The C programming language says little or nothing about caches, and
does itself not provide any of the tools you would need to measure
or improve cache performance. Caching is a matter not within the
pervue of C itself, so this is not an appropriate newsgroup for
advice on cache use.
I know use of loops and local variables will help but more would be of
good help
Even that is wrong on some platforms. On some platforms, there is
a small section of memory at the beginning of the address space that
can be addressed with shorter faster instructions (fewer address
bits to work with.) On such systems, the best cache performance
might involve use of that small section of memory rather than involve
use of local variables: when instructions are shorter, more of them
fit into instruction cache. Thus, to maximize your cache use, you
need to use platform-specific information.