From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 110292,45b50f14dadfce5b X-Google-Attributes: gid110292,public X-Google-Thread: 1164f8,45b50f14dadfce5b X-Google-Attributes: gid1164f8,public X-Google-Thread: 102b75,45b50f14dadfce5b X-Google-Attributes: gid102b75,public From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) Subject: Re: Final kick at the "Merced Guessing Game" Date: 1997/10/14 Message-ID: <61uvsh$br0$1@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 280290486 References: <61g30t$o2n@news-rocq.inria.fr> <343CE2F4.362D80F0@tonys.ecology.umn.edu> <343EF1C9.61670DFC@tonys.ecology.umn.edu> <343FAA72.2ED97125@acm.org> <61tnd5$6m8@usenet.srv.cis.pitt.edu> Organization: Comp Sci, RMIT University, Melbourne, Australia. NNTP-Posting-User: ok Newsgroups: comp.sys.intel,comp.arch,comp.sys.dec geest3+@pitt.edu (Gregg E Economou) writes: >You miss the point that while yes, they may be physically multidimensional, >and even organisationally multidimensional, and even architecturally >multidimensional, they are *logically* linear, and accessed in a linear >fashion. Yes, there are strange exceptions out there, but the majority >of memories are linear int the majorities or architectures and the >majority of machines ever designed, made, or sold. With everybody accusing everyone else of missing *the* point, perhaps it is time to make *a* point. Today, if you want to write high-performance code on stock hardware, you have to view your plain ordinary so-called 'linear' address space as three dimensional. For example, I am writing this on an UltraSPARC 2. Level 1 data cache: (The L1 code cache is the same, 16 kbytes I _think_) 32 bytes per line 1-way association Level 2 cache: (Unified, I _think_) 512 kbytes 64 bytes per line 1-way association VM 2 Gbytes 8 kbytes per page Physical memory 512 Mbytes I've loaned the manual to a student, but if I remember correctly, latency for load from L1 cache: 3 cycles latency for load from L2 cache: 8 cycles latency for load from physical: 30 cycles (if mapped) latency for load from disc : on the order of 2 000 000 cycles The machine is four-way superscalar. With well-blocked code working on data that fits into L2 cache, it isn't very hard to get a floating add and a floating multiply every cycle. But you simply cannot sustain that kind of speed on larger amounts of data without taking the memory hierarchy with extreme seriousness. I had my first real lesson in memory hierachies back on a Sun 3/50 years ago, where an algorithm that normally did 6000 interesting things per second suddenly dropped to 6 things per second, thanks to paging. We fixed that problem by replacing a conventional internal hash table with a kind of hash table originally designed for data on disc. There are about 130 processes running on this machine. Perhaps a more useful indicator is the number of people logged in, which is about 50 (not counting multiple logins). 512Mb of memory sounds like a lot, but practically speaking my share is about 10Mb. (About what you'd get to yourself on a PC with 32Mb of RAM if you shut just about everything not directly connected with your task down). If I want to do anything that takes _much_ more than my share of (physical) memory, I had better design my code very carefully. 'boo' said something about not having to worry about the dimensionality of memory, and also said something about cache in the same message. Well, that's another area where it _does_ matter. This machine, like some others, offers block load and block store instructions. A single load or store can move 64 bytes. For marching sequentially through big arrays, it's pretty good, because these instructions don't pollute the cache, so you can walk through a large array _without_ flushing stuff you'll want again out of the cache. NIce. But in order to use those instructions, you have to envisoage your simple linear vector as an array of 64-byte vectors. On this machine, think of memory as an array of 65536 // physical memory arrays of 128 // pages arrays of 64 // L2 cache lines (load/store blocks) bytes Organising your code to stick with the same small set of 'rows' (cache lines) wins up to a factor of 4 in memory performance compared with scattered access. Organising your code to stick with the same small set of 'planes' (pages) wins a factor of 10s of thousands in memory performance compared with scatted access. The means whereby you access a location is independent of where it is, but the *cost* certainly isn't. (Oh, and I didn't mention the page mapping caches! There's another performance knee there, if you don't watch out.) -- John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL. Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok