From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,b0efc8b077039d04 X-Google-Attributes: gid111c93,public From: Peter Boyle Subject: Re: seti@home 2.4 for alpha linux ev5 Date: 2000/04/03 Message-ID: #1/1 X-Deja-AN: 606129649 References: <38d524b3$0$87872@news.voyager.net> <1c2ac8.9sm.ln@snowwhite.dera.gov> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Complaints-To: usenet@scotsman.ed.ac.uk X-Trace: scotsman.ed.ac.uk 954780563 10238 129.215.16.14 (3 Apr 2000 16:49:23 GMT) Organization: Edinburgh University Mime-Version: 1.0 NNTP-Posting-Date: 3 Apr 2000 16:49:23 GMT Newsgroups: comp.os.linux.alpha 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