Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: David Chase <chase@world.std.com>
Subject: Re: Final kick at the "Merced Guessing Game"
Date: 1997/10/15	[thread overview]
Message-ID: <34441501.7BBF@world.std.com> (raw)
In-Reply-To: 34427D66.F3558989@tonys.ecology.umn.edu


boo wrote:
> ... If you can show
> me some dimensionality of the cache (or other) memory that
> I can actually take advantage of at the assembly level, then
> I would love to hear about it.

Depends on the cache; certainly, linearly addressing along (in 
the same linear dimension, so to speak) works well.  If you have
a direct-mapped cache (I think these are rare on on-chip caches)
then you must worry about accesses to colliding addresses; that is,
there are three possible choices for two consecutive memory accesses:

1. same line, same tag (i.e., reuse line)
2. different lines
3. same line, different tag (i.e., collision)

Choice #1 is preferred, but is not always possible
Choice #3 is considered to be bad, unless you are so good at
  planning your memory accesses that the first access in the
  pair is that last access to its tag (i.e., you will not collide
  on this pair again), in which case it is a necessary evil.

There are some additional complications to this problem:

sometimes on-chip caches are somewhat associative, whereas
off-chip caches may be direct.  If the external cache "includes"
the on-chip cache, then two lines that could co-reside in the
on-chip cache but induce a collision in the external cache,
cannot co-reside (because otherwise the external cache would
not include the contents of the on-chip cache).

sometimes external caches are accessed using physical addresses.
This means that if there are collisions, they depend on properties
of the address that are not visible to the programmer (virtual
addresses are the common case).

sometimes operating systems are not entirely predictable or repeatable
in how they assign virtual addresses to physical pages; some do
"page coloring" (I figured this out once, but have long since
forgotten the details) where virtual addresses that look like
they ought not collide, are assigned to non-colliding physical
pages (my guess is that there are some caveats, provisos, and
quid pro quos related to what happens when no such pages are
available).

Sometimes operating systems do something else; they may reserve
a bunch of physical pages that collide into the same few cache
lines for use in a processes stack.  The reasoning here is that
stack access is generally linear and local (at least in certain
industry-standard-benchmarks) and that collisions with the stack
(e.g., code and stack, or hot data and stack) can lead to performance
anomalies.  I don't know if anyone does this.

If you have threads, and there is shared data, then you need to
know more.  It's a very bad idea, for instance, to allocate thread
specific flags like this:

  char thread_specific_flags[NTHREADS];

if the threads are all writing to their flags all the time, because
they will continually compete for ownership of the cache line 
containing that statically allocated variable.  Better to do
something like this:

  struct {
    char flag;
    char padding[cache_line_size_minus_one];
  } thread_specific_flags[NTHREADS];

though it would be even nicer if you could align these suckers
to the cache line size and store all your per-thread info like
that.  Keep in mind that the processor-level granularity for
owning memory may not correspond to the on-chip cache line size.

In some cases, there is also an issue with TLB thrashing;
if you (frequently) access more virtual pages than can fit
in the TLB, then that will slow you down, too.  I don't know
what recent processors do here.

As far as I know, no compiler does a very good job at the
cache-collision game.  Friends from IBM claim that anyone
building a direct-mapped cache is foolish (because of these
intractable problems) and friends at Tera claim that they
will take care of all of this by threading everything up,
down, and sideways.  The Tera approach is tremendously
elegant, and will almost certainly work for a large
category of Fortran programs, and may even work well for
C.

I wouldn't really want to claim that this mess has any
particular "dimension" to it.

-- 
David Chase, chase@world.std.com



  parent reply	other threads:[~1997-10-15  4:00 UTC|newest]

Thread overview: 207+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-08  4:00 Final kick at the "Merced Guessing Game" Robert Harley
1997-10-08  4:00 ` David Chase
1997-10-08  4:00 ` William Clodius
1997-10-08  4:00 ` brianh
1997-10-08  4:00   ` boo
1997-10-09  4:00     ` Eric Hildum
1997-10-09  4:00     ` brianh
1997-10-11  4:00     ` Jan Vorbrueggen
1997-10-12  4:00       ` boo
1997-10-13  4:00         ` Carl Perkins
1997-10-13  4:00         ` Michael Williams
1997-10-13  4:00           ` Craig Burley
1997-10-13  4:00             ` Paul Rubin
1997-10-13  4:00               ` Craig Burley
1997-10-13  4:00               ` William Clodius
1997-10-14  4:00               ` Richard A. O'Keefe
1997-10-14  4:00                 ` Shankar Unni
1997-10-15  4:00                   ` Richard A. O'Keefe
1997-10-15  4:00                     ` Paul D. DeRocco
1997-10-15  4:00                       ` William Clodius
1997-10-15  4:00                       ` Joe Buck
1997-10-16  4:00                       ` Richard A. O'Keefe
1997-10-16  4:00                         ` Craig Burley
1997-10-17  4:00                     ` Shankar Unni
1997-10-15  4:00                   ` Achim Gratz
1997-10-14  4:00                 ` Michael Williams
1997-10-14  4:00                   ` Richard Black
1997-10-15  4:00                     ` Michael Williams
1997-10-15  4:00                       ` Dr. Richard Black
1997-10-16  4:00                         ` Richard A. O'Keefe
1997-10-15  4:00                     ` Craig Burley
1997-10-18  4:00                     ` Bruce Hoult
1997-10-15  4:00                 ` Paul Hsieh
1997-10-13  4:00             ` boo
1997-10-15  4:00               ` Craig Burley
1997-10-16  4:00                 ` Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game") Ian Dall
1997-10-16  4:00                   ` Craig Burley
1997-10-17  4:00                   ` Richard A. O'Keefe
1997-10-17  4:00                     ` Keith Adams
1997-10-17  4:00                       ` [Reposted due to Enlow UCE cancel]: " John  Bayko
1997-10-20  4:00                         ` Paul D. DeRocco
1997-10-17  4:00                       ` John  Bayko
1997-10-18  4:00                       ` Kelly Hall
1997-10-20  4:00                         ` [Reposted due to Enlow UCE cancel]: " Eric Hildum
     [not found]                 ` <623ek6$ef5$1@news.iastate.edu>
1997-10-16  4:00                   ` Final kick at the "Merced Guessing Game" Craig Burley
1997-10-16  4:00                     ` SimGraphics
1997-10-17  4:00                       ` Craig Burley
1997-10-17  4:00                         ` David Chase
1997-10-18  4:00                           ` Victor Yodaiken
1997-10-20  4:00                             ` Eric Hildum
1997-10-17  4:00                         ` William Clodius
1997-10-19  4:00                           ` Craig Burley
1997-10-18  4:00                         ` Peter L. Montgomery
1997-10-19  4:00                           ` Craig Burley
     [not found]                             ` <3456700e.14141203@news.demon.co.uk>
1997-10-28  5:00                               ` Dirk van der Knijff
1997-10-20  4:00                           ` Richard A. O'Keefe
1997-10-20  4:00                             ` Peter L. Montgomery
1997-10-09  4:00   ` Gregg E Economou
1997-10-10  4:00     ` Jan Vorbrueggen
     [not found] ` <61ho3v$3m0$1@goanna.cs.rmit.edu.au>
1997-10-09  4:00   ` boo
1997-10-09  4:00     ` William Clodius
1997-10-10  4:00     ` Tyson Richard DOWD
1997-10-12  4:00       ` boo
1997-10-13  4:00         ` Patricia Shanahan
1997-10-15  4:00           ` boo
1997-10-15  4:00             ` Patricia Shanahan
1997-10-13  4:00         ` Steve Tate
1997-10-13  4:00           ` boo
1997-10-13  4:00             ` Victor Yodaiken
1997-10-14  4:00             ` Jason.Ozolins
1997-10-15  4:00               ` boo
1997-10-14  4:00             ` Aaron Spink
1997-10-15  4:00             ` David Chase [this message]
1997-10-13  4:00           ` Bernd Paysan
1997-10-13  4:00           ` boo
1997-10-13  4:00             ` Aaron Spink
1997-10-14  4:00               ` boo
1997-10-18  4:00                 ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-18  4:00                 ` tgg
1997-10-10  4:00     ` boo
1997-10-11  4:00       ` Toon Moene
1997-10-11  4:00       ` Paul DeMone
1997-10-11  4:00       ` Patricia Shanahan
1997-10-13  4:00         ` Gregg E Economou
1997-10-13  4:00           ` Patricia Shanahan
1997-10-14  4:00           ` Richard A. O'Keefe
1997-10-15  4:00             ` boo
1997-10-16  4:00               ` Timothy A. Seufert
1997-10-16  4:00                 ` boo
1997-10-16  4:00               ` Toon Moene
1997-10-17  4:00               ` Richard A. O'Keefe
1997-10-20  4:00               ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-20  4:00               ` Jason.Ozolins
1997-10-10  4:00     ` Richard A. O'Keefe
     [not found]   ` <EHrwv9.2w3@world.std.com>
1997-10-10  4:00     ` David Gould
1997-10-10  4:00       ` Maynard Handley
1997-10-11  4:00         ` new languages Preston Briggs
1997-10-10  4:00     ` Final kick at the "Merced Guessing Game" David Gould
1997-10-16  4:00       ` Patricia Shanahan
  -- strict thread matches above, loose matches on Subject: below --
1997-10-09  4:00 Robert Harley
1997-10-08  4:00 Robert Harley
     [not found] ` <343C0387.41C6@lanl.gov>
1997-10-08  4:00   ` boo
1997-10-09  4:00     ` David Chase
1997-10-08  4:00       ` boo
1997-10-09  4:00       ` William Clodius
1997-10-09  4:00     ` Patrick Chase
1997-10-10  4:00       ` boo
1997-10-09  4:00 ` David Chase
1997-10-08  4:00 Robert Harley
1997-10-08  4:00 ` Michael Meissner
1997-10-09  4:00 ` Richard A. O'Keefe
1997-10-07  4:00 Robert Harley
1997-10-07  4:00 ` Martin Rodgers
1997-10-07  4:00 ` Shankar Unni
1997-10-08  4:00   ` boo
1997-10-09  4:00     ` Patrick F. McGehearty
1997-10-10  4:00       ` Richard A. O'Keefe
1997-10-15  4:00         ` David Chase
1997-10-16  4:00           ` William Clodius
1997-10-07  4:00 ` Nick Maclaren
1997-10-03  4:00 Robert Harley
1997-10-06  4:00 ` Richard A. O'Keefe
1997-10-06  4:00   ` boo
1997-10-07  4:00     ` Richard A. O'Keefe
1997-10-06  4:00       ` Graham Hughes
1997-10-07  4:00       ` boo
1997-10-07  4:00         ` William Clodius
1997-10-07  4:00       ` William Clodius
     [not found]         ` <y4wwjon203.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>
1997-10-08  4:00           ` William Clodius
1997-10-08  4:00             ` Stanley Chow
1997-10-08  4:00         ` Richard A. O'Keefe
1997-10-08  4:00           ` William Clodius
1997-10-08  4:00           ` William Clodius
1997-10-09  4:00         ` William Clodius
1997-10-10  4:00           ` Larry Kilgallen
1997-10-10  4:00             ` Zalman Stern
1997-10-11  4:00             ` Andrew Cruickshank
1997-10-12  4:00               ` Paul D. DeRocco
1997-10-13  4:00               ` Michael Williams
1997-10-08  4:00       ` Gregg E Economou
1997-10-08  4:00         ` David Chase
1997-10-08  4:00         ` Richard A. O'Keefe
1997-10-07  4:00     ` Carlie Coats
1997-10-07  4:00       ` Paul Hsieh
1997-10-07  4:00         ` boo
1997-10-08  4:00           ` Carlie Coats
1997-10-07  4:00     ` Serge Pachkovsky
1997-10-07  4:00       ` Martin Rodgers
1997-10-07  4:00         ` Greg Weeks
1997-10-07  4:00           ` Martin Rodgers
     [not found]           ` <343AAE5A.A3FCC9D@no.informatik.spam.tu-muenchen.thanks.de>
1997-10-09  4:00             ` Torben AEgidius Mogensen
     [not found]               ` <EHsr7B.Dt8@bit3.com>
1997-10-10  4:00                 ` Torben AEgidius Mogensen
     [not found]       ` <61cv5e$qn$6@vixen.cso.uiuc.edu>
1997-10-08  4:00         ` William Clodius
1997-10-08  4:00     ` James C. Stutts
1997-10-02  4:00 Robert Harley
1997-10-02  4:00 ` Nick Maclaren
1997-10-02  4:00   ` Stanley Chow
1997-10-02  4:00 Robert Harley
1997-10-02  4:00 ` Nick Maclaren
1997-10-03  4:00 ` Richard A. O'Keefe
1997-09-30  4:00 Paul DeMone
1997-09-30  4:00 ` Guy Harris
1997-10-01  4:00   ` Tom Thornhill
1997-10-01  4:00 ` Richard A. Schumacher
1997-10-01  4:00 ` Tom Thornhill
1997-10-01  4:00   ` Jim Hull
1997-10-01  4:00   ` Paul DeMone
1997-10-01  4:00 ` Nick Maclaren
1997-10-01  4:00   ` J. Corbally
1997-10-01  4:00     ` Nick Maclaren
1997-10-01  4:00       ` Ketil Z Malde
1997-10-01  4:00         ` Michael D. Nahas
1997-10-01  4:00           ` Stefan Monnier
1997-10-01  4:00             ` Nick Maclaren
1997-10-01  4:00               ` P Murray
1997-10-01  4:00                 ` Nick Maclaren
1997-10-02  4:00                   ` Andrew Glew
1997-10-02  4:00                   ` Vesa Karvonen
1997-10-02  4:00                     ` Joseph H Allen
1997-10-02  4:00                       ` Wilco Dijkstra
1997-10-03  4:00                         ` Jason.Ozolins
1997-10-03  4:00                           ` Alex Colvin
1997-10-06  4:00                             ` Richard A. O'Keefe
1997-10-08  4:00                               ` Zalman Stern
1997-10-03  4:00                         ` Stefan Monnier
1997-10-03  4:00                       ` Stefan Monnier
1997-10-02  4:00                 ` Torben AEgidius Mogensen
1997-10-02  4:00                   ` Patrick F. McGehearty
1997-10-02  4:00                     ` brianh
1997-10-03  4:00                     ` Michael Williams
1997-10-01  4:00               ` John Wilson
1997-10-01  4:00               ` Allen Kim
1997-10-02  4:00               ` Jon Leech
1997-10-02  4:00               ` Stefan Monnier
1997-10-03  4:00                 ` Richard A. O'Keefe
1997-10-03  4:00               ` Mike Smith
1997-10-03  4:00                 ` Nick Maclaren
1997-10-03  4:00                   ` Rob Barris
1997-10-03  4:00                     ` Andrew Glew
1997-10-05  4:00                       ` Gianni Mariani
1997-10-04  4:00                     ` Nick Maclaren
1997-10-04  4:00                       ` H. Eckert
1997-10-05  4:00                       ` Andy "Krazy" Glew
1997-10-06  4:00                         ` Nick Maclaren
1997-10-01  4:00           ` brianh
1997-10-02  4:00           ` Eric Hildum
1997-10-01  4:00   ` Paul DeMone
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