From: Peter Boyle <pboyle@holyrood.ed.ac.uk>
Subject: Re: seti@home 2.4 for alpha linux ev5
Date: 2000/04/03 [thread overview]
Message-ID: <Pine.GSO.4.10.10004031706070.6075-100000@holyrood.ed.ac.uk> (raw)
In-Reply-To: 1c2ac8.9sm.ln@snowwhite.dera.gov
On Mon, 3 Apr 2000, Richard Simpson wrote:
> Is there anyone in this group who actually UNDERSTANDS page colouring and
> who could either give us an idiot's guide or point us to a sensible web
> page? All I know, is that it is related to the way that the cache is
> controlled and that it is a pain in the butt!!
>
Hi,
I wouldn't claim to UNDERSTAND cache coloring, but I'll splurge what
little I do know.
i) External Cache thrashing due to virt->real addressing
The basic problem arises because the external (L2/L3 depending on
system) cache is direct mapped in *real* address space, while
codes (and higher levels of cache) are operating with virtual
addresses.
Of course, the page table ( cached in the TLB on chip ) translates
virtual page numbers into physical page numbers, with the offset
within a page being unchanged. The problem is that the virtual
addressing gives absolutely no guarantee that the physical
When, for example, streaming two arrays which are laid out
uniformly, read with stride one access, and put in a common
block / global / whatever with padding to ensure that access
are well separated in the cache in virutal space, you can end
up accessing simultaneously from the same sub-page of the direct
mapped L3 cache for both streams. One evicting the other before
it is read. The worst case of this could arise if the padding
is such that modulo the page size, you are reading from
the same address concurrently. Then even if the
on-chip cache is multi-way associative, the vagaries
of the virt->real page mapping could make the direct mapped
external cache thrash and give huge loss of performance.
e.g. if page size is 8192
double precision A(8192*4)
double precision B(8192*4)
c should actually pad so as to add some nice number of cache
c lines in C, deliberately take worst number here.
double precision C(8192)
integer i
common /bad/ A,B
double precision dot
dot = 0.0
do i=1,8192*4
dot = dot + A(i)*B(i)
end do
Here the 2MB cache is 256 pages long, so we would concurrently
access 5 pages apart in the L3 which is fine, but depending
on how the OS lays out the processes memory map this may not be the
case.
Hence
> : Have you tried the 2.4.alpha-compaq-T64Uv4.0d version?
The binary doesn't have controll of the memory map, so should make
the difference. If there is a difference running under Linux it is
probably something like KAP in the compilation.
Given the ratio of cache to main memory latency, this page thrashing
doesn't have to happen all that often to become a significant performance
hit.
There is a performance tuning red book available on IBM websites
showing (i think ) the streams performance as function of size with
random drop spikes as a result of this.
ii) Cache coloring.
HPC orientated OS's (Tru64, and I think possibly IRIX and AIX but
I am probably wrong in at least one of these) divide the external cache
into a number of sectors called colors. Basically the aim is to detect
thrashing in the L3 and remap the processes page tables to split the
conflicting pages into different sectors of the L3.
They look at the on-chip perfmon counters to detect anomolously
high L3 misses on each task switch and flag processes for dynamic
remapping. How the info is obtained for which pages are conflicting
I don't know.
iii) Poor man's alternatives.
Easiest: reboot machine so that the memory space is unlikely
to be fragmented. Pad commons as though a
Run process as root, and mlock the array's that you
think are thrashing. One *hopes* a contiguous block of physical
memory is assigned to the contigous block of virtual space.
I did have a go at hacking the mlock/munlock into a
syscall to lock and remap the page table (because I was finding it hard to
reproduce stream figures for a ds10 and followed a red herring),
but turned out I wasn't getting wh64's produced, and I was too crap
a programmer anyway. It was at least able to scan the mappings
given base addresses and access strides looking for conflicts
and if anyone is interested in taking it further, email me.
Cheers,
Peter Boyle pboyle@physics.gla.ac.uk
next prev parent reply other threads:[~2000-04-03 4:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-19 5:00 seti@home 2.4 for alpha linux ev5 jmd
2000-03-21 5:00 ` Fredrik Lindvall
2000-03-21 5:00 ` Steve Lionel
2000-03-22 5:00 ` Ian Wilkinson
2000-03-28 5:00 ` Richard Simpson
2000-03-28 5:00 ` Jim Woodruff
2000-04-03 4:00 ` Richard Simpson
2000-04-03 4:00 ` Peter Boyle [this message]
2000-04-05 4:00 ` Richard Simpson
2000-04-06 4:00 ` Peter Boyle
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox