Hi, my question is quite similar. VTune is telling me that I'm having some 64k aliasing conflicts, but I failed to detect them by printing the pointer values.
It's only one thread, one function.
This function works with a number of buffers; I printed out the starting positions of them (and knowing their sizes) but I couldn't find -analytically- where the 64k modulus distance occurs.
Supposing I have two buffers accessed in the same function:
buffer1: starts at [addr1], size [len1]
buffer2: starts at [addr2], size [len2]
The manual explains that if bits 15-6 of the two memory addresses being accessed are the same, then a 64K aliasing conflict will occur. By adding 64 to one of the addresses, you make the value in bits 15-6 different and thereby remove the conflict. That is, if you are traversing the buffers in order from beginning to end, lock stop, offsetting the start of one of the buffers will remove the conflicts. Otherwise, you will experience a conflict on every single memory access.
Message Edited by dlanders on 04-27-2004 04:02 PM
Hi, thanks for your answer.
I thought that bits under consideration were 15-0 rather than 6 -> 15, that's why I 'anded' my pointer values by 0xFFFF. In fact, my clause was (given ptr1 and ptr2)
bool conflict = ((unsigned int) ptr1 & 0xFFFF) == ((unsigned int) ptr2 & 0xFFFF);
and it happened that NONE of the accessed addresses of the function fit this condition, and that's why I could not find where the '64k al. conflict' occurs.
Note that the function is written in ASM, stack is used _only_ at the beginning for obtaining one parameter, and the ESP is never accessed again.
I will really appreciate your help.
Why "if bits 15-6 of the two memory addresses being accessed are the same, then a 64K aliasing conflict will occur"? Can anybody give a detailed description?
Hi FERN and zhen_heng:
All I can do is point you to the reference manual: http://www.intel.com/design/pentium4/manuals/248966.htm
On page 105 (2-43), the 64k Aliasing Conflict is described, including which bits for which Pentium 4 and Xeon processor models.
The line size is 64 bytes, which explains why bit 0-5 are ignored. From page 2-41, "Note that first-level cache lines are 64 bytes. Thus the least significant 6 bits are not considered in alias comparisons."
Also, the definition of the data conflict may be enlightening, "Data conflict can only have one instance of the data in the first-level cache at a time. If a reference (load or store) occurs with its linear address matching a data conflict condition with another reference (load or store) which is under way, then the second reference cannot begin until the first one is kicked out of the cache.On Pentium 4 and Intel Xeon processors with CPUID signature of family encoding 15, model encoding of 0, 1 or 2, the data conflict condition applies to addresses having identical value in bits 15:6 (also referred to as 64K aliasing conflict)."
Now, why this condition causes a conflict is obviously an architectural issue and I cannot explain that. I believe what matters is that if you detect a high number of conflicts with the analyzer, you could improve yourcode's performance by mitigating the conflict.
Anyone else have any ideas/answers?
Message Edited by DaveA on 06-21-2004 03:09 PM