From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
Subject: Re: Final kick at the "Merced Guessing Game"
Date: 1997/10/10 [thread overview]
Message-ID: <61kek8$9lh$1@goanna.cs.rmit.edu.au> (raw)
In-Reply-To: 61iuna$3li@deadzone.rsn.hp.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5582 bytes --]
Patrick F. McGehearty <patrick@convex.COM> writes:
>All this "my language is best because it is all I know" discussion is not
>very enlightening. Let's get back on the "language features which will
>aid/hender future architectures generate fast applications" topic.
Given my respect for David Chase, my awareness from the literature that
the kinds of transformations he is talking about _are_ used and _do_
pay off (indeed, I have a student doing a minor thesis on neural nets
trying to see if he can beat Sun's C compiler -- alas, he was unwilling
to learn Fortran --), and also given my strong liking for functional
programming languages like Haskell and Clean, I'm worried.
People in the functional programming community have put a _lot_ of work
into trying to implement functional languages really well. For example,
on the pseudoknot benchmark, Clean-compiled code ran as fast as C.
There are techniques like loop unrolling that can be applied in functional
languages as well. Let's take the well-known `member' function:
member :: a [a] -> Bool | == a
/* This declaration means that member is a function that will
accept homogeneous lists with any element type, as long as
that element type has an equality operation, and returns a
Boolean result.
*/
member x [e:es] = x == e || member x es
member x [] = False
Clean is a lazy language, but the Clean compiler is able to infer that
this function is strict. In fact, in the context of the definition
Start = member 3 [4,1,3,2,5]
the Clean compiler will make an instance member (int) and infer, without
any declarations at all
member (int) :: Int ![Int] -> Bool
where ! means strict. So the code that is generated is perfectly ordinary
call-by-value stuff. In fact, it's pretty much the equivalent of
template <class T>
bool member(T const x, list<T> es) {
for (; es != NULL; es = es->tail)
if (es->head == x) return true;
return false;
}
This is precisely the kind of code that David Chase decries as intrinsically
inefficient.
There _are_ things that can be done here, and they can be done precisely
because these languages have no mutable data structures and are fairly
straightforward to analyse. One thing I'd like to discuss _has_ been
implemented, but _not_ as far as I know in the Clean compiler. That is,
loop unrolling.
Instead of having
:: list a = Nil | Cons a (list a)
you unroll the type. Unrolling by 3 would give
:: list3 a = Nil3 | Cons31 a | Cons32 a a | Cons33 a a a (list3 a)
This would economise on space as well, taking an average of 4/3rds of a
word per element instead of 2 words per element. A compiler can automatically
rewrite the member function to
member3 x Cons33 e1 e2 e3 es = x == e1 || x == e2 ||
x == e3 || member3 x es
member3 x Cons32 e1 e2 = x == e1 || x == e2
member3 x Cons31 e1 = x == e1
member3 x Nil3 = False
I must repeat, the Clean compiler does NOT do this transformation, but
there has been published work on a compiler for another functional language
that does. So this kind of loop unrolling _is_ something that can be
applied to pointer chasing, *provided* the language is a high level one
which makes it impossible for a program to notice any difference, except
in performance.
In pure functional languages, speculative loading in such loops ought to
work very well. So that's another thing that should help.
The thing that has me worried is that fantastic improvements have been
made in compiler technology for functional languages, but the big money
is in compilers for C, C++, Fortran, and Java, so those languages are
always likely to enjoy a lead that relates to their popularity, not
their potential. This in turn means that such languages will continue
to predominate in benchmarks, which means that computer architects will
continue to bias their designs towards such languages, which means that
functional language implementors will have even more catching up to do.
The reason this is sad is that lifecycle costs can be reduced when you
have a language which is otherwise sufficiently expressive but in which
a large proportion of common errors _can't_ be expressed. (Ericsson
believe this. They have adopted a mostly-functional language of their
own design called Erlang, sacrificing performance in the interests of
time-to-market and reliability.)
Once upon a time, people used to advocate specialised hardware for
symbolic languages. The phenomenal price-performance improvements
of commodity hardware have made that a thing of the past, and I expect
that to remain true (although there were some seriously interesting
ideas in the LMI K machine which might still be useful). These days
systems like Clean and O'CAML and SISAL get _fine_ performance on
stock hardware. My impression, which is not completely up to date
(I'm trying to get through fifty papers this week, phew!), is that
the limiting factor for functional languages is memory. (For example,
Clean directly supports arrays of unboxed numbers.)
What I'm wondering, and here I go way beyond any expertise I might
possibly claim, is whether (a) there are patterns of memory use in
functional languages that hardware designers might exploit, without
adverse effect on more conventional languages? and (b) whether the
hardware designers see any point in worrying about this?
--
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
next prev parent reply other threads:[~1997-10-10 4:00 UTC|newest]
Thread overview: 201+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-10-07 4:00 Final kick at the "Merced Guessing Game" Robert Harley
1997-10-07 4:00 ` Martin Rodgers
1997-10-07 4:00 ` Nick Maclaren
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 [this message]
1997-10-15 4:00 ` David Chase
1997-10-16 4:00 ` William Clodius
1997-10-17 4:00 ` WAS " David Chase
1997-10-18 4:00 ` Nick Maclaren
1997-10-18 4:00 ` [Reposted due to Enlow UCE cancel]: " David Chase
1997-10-19 4:00 ` Nick Maclaren
1997-10-22 4:00 ` pointer checking (WAS Re: Final kick at the "Merced Guessing Game") Hans-Juergen Boehm
1997-10-18 4:00 ` WAS Re: Final kick at the "Merced Guessing Game" David Chase
-- strict thread matches above, loose matches on Subject: below --
1997-10-09 4:00 Robert Harley
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-08 4:00 Robert Harley
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 ` Michael Williams
1997-10-13 4:00 ` Craig Burley
1997-10-13 4:00 ` Paul Rubin
1997-10-13 4:00 ` William Clodius
1997-10-13 4:00 ` Craig Burley
1997-10-14 4:00 ` Richard A. O'Keefe
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-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 ` Joe Buck
1997-10-15 4:00 ` William Clodius
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-15 4:00 ` Paul Hsieh
1997-10-13 4:00 ` boo
1997-10-15 4:00 ` Craig Burley
[not found] ` <623ek6$ef5$1@news.iastate.edu>
1997-10-16 4:00 ` Craig Burley
1997-10-16 4:00 ` SimGraphics
1997-10-17 4:00 ` Craig Burley
1997-10-17 4:00 ` William Clodius
1997-10-19 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-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-13 4:00 ` Carl Perkins
1997-10-09 4:00 ` Gregg E Economou
1997-10-10 4:00 ` Jan Vorbrueggen
1997-10-08 4:00 ` David Chase
1997-10-08 4:00 ` William Clodius
[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 ` Richard A. O'Keefe
1997-10-10 4:00 ` Tyson Richard DOWD
1997-10-12 4:00 ` boo
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
1997-10-13 4:00 ` boo
1997-10-13 4:00 ` Aaron Spink
1997-10-14 4:00 ` boo
1997-10-18 4:00 ` tgg
1997-10-13 4:00 ` Bernd Paysan
1997-10-13 4:00 ` Patricia Shanahan
1997-10-15 4:00 ` boo
1997-10-15 4:00 ` Patricia Shanahan
1997-10-10 4:00 ` boo
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 ` Toon Moene
1997-10-16 4:00 ` Timothy A. Seufert
1997-10-16 4:00 ` boo
1997-10-17 4:00 ` Richard A. O'Keefe
1997-10-20 4:00 ` Jason.Ozolins
1997-10-11 4:00 ` Paul DeMone
1997-10-11 4:00 ` Toon Moene
[not found] ` <EHrwv9.2w3@world.std.com>
1997-10-10 4:00 ` David Gould
1997-10-16 4:00 ` Patricia Shanahan
1997-10-10 4:00 ` David Gould
1997-10-10 4:00 ` Maynard Handley
1997-10-08 4:00 Robert Harley
[not found] ` <343C0387.41C6@lanl.gov>
1997-10-08 4:00 ` boo
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 ` boo
1997-10-09 4:00 ` William Clodius
1997-10-09 4:00 ` David Chase
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 ` 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-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 ` Richard A. O'Keefe
1997-10-06 4:00 ` Graham Hughes
1997-10-07 4:00 ` William Clodius
1997-10-08 4:00 ` Richard A. O'Keefe
1997-10-08 4:00 ` William Clodius
1997-10-08 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-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-07 4:00 ` boo
1997-10-07 4:00 ` William Clodius
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-08 4:00 ` James C. Stutts
1997-10-02 4:00 Robert Harley
1997-10-02 4:00 ` Nick Maclaren
1997-10-03 4:00 ` Richard A. O'Keefe
1997-10-02 4:00 Robert Harley
1997-10-02 4:00 ` Nick Maclaren
1997-10-02 4:00 ` Stanley Chow
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 ` Tom Thornhill
1997-10-01 4:00 ` Jim Hull
1997-10-01 4:00 ` Paul DeMone
1997-10-01 4:00 ` Richard A. Schumacher
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 ` brianh
1997-10-01 4:00 ` Stefan Monnier
1997-10-01 4:00 ` Nick Maclaren
1997-10-01 4:00 ` Allen Kim
1997-10-01 4:00 ` P Murray
1997-10-01 4:00 ` Nick Maclaren
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 ` Stefan Monnier
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-02 4:00 ` Andrew Glew
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-02 4:00 ` Stefan Monnier
1997-10-03 4:00 ` Richard A. O'Keefe
1997-10-02 4:00 ` Jon Leech
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-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