Hi all
I am a total newbie to assembly ...
My question is as much about assembly as it is about computer architecture ..

I am doing a write-up about caches in college .. I understand there are instructions to bypass the CPU cache.... so that one can be sure that this particular instruction did not use the cache and loaded/stored directly from RAM.. I would simply like a small example of this.

Is there any way to time the difference of two instructions (in VC++?), one that bypasses cache and one that dosent. Is this even possible or is there no timer with high enough resolution ?

Any pointers would be nice ...

:confused:
Posted on 2003-11-09 19:46:18 by ashayh
I don't know how to load past the cache - don't think it is possible. Might want to use the prefetch instructions or count on the hardware prefetch for data loads. Instruction caching is done by the processor automatically.

Writing past the cache is done with the MOVNT* instructions. I don't think there is harware writing past the cache, but there should be (AMD/Intel - are you listening?).

Search the board for MOVNTQ for some examples I've coded, and there is much on the board about timing with the time stamp counter. Better to time several instructions to understand the latency and thoughput.

Memory copying is also a popular area of research relating very closely to this topic.
Posted on 2003-11-09 20:33:10 by bitRAKE

Hi all
I am a total newbie to assembly ...
My question is as much about assembly as it is about computer architecture ..

I am doing a write-up about caches in college .. I understand there are instructions to bypass the CPU cache.... so that one can be sure that this particular instruction did not use the cache and loaded/stored directly from RAM.. I would simply like a small example of this.

Is there any way to time the difference of two instructions (in VC++?), one that bypasses cache and one that dosent. Is this even possible or is there no timer with high enough resolution ?

Any pointers would be nice ...

:confused:


Though a particular processor may provide instructions to bypass the cache, the usual way to do this is by setting certain bits in the page tables. Most (protected mode) operating systems provide a special form of memory allocation call that lets you control the cache setting (e.g., Win32 provides VirtualAlloc and its ilk with certain flags to control this, Linux has mmap, etc.).
Cheers,
Randy Hyde
Posted on 2003-11-12 12:05:45 by rhyde
"Invl" flushes all cache and "Invlpg" flushes a page entry from the TLB.
Posted on 2003-11-15 01:24:20 by mrgone