* [Caml-list] OCaml on G4
@ 2004-06-23 6:03 David McClain
2004-06-23 15:05 ` David Brown
0 siblings, 1 reply; 2+ messages in thread
From: David McClain @ 2004-06-23 6:03 UTC (permalink / raw)
To: caml-list
I have to congratulate the OCaml team! While I don't yet read PPC
Assembly fluently enough to make sense of the generated OCamlOpt
output, I have run some indirect math tests that verify its generation
of optimal floating point math code.
Of course, optimal is in the eye of the beholder in this case, c.f.,
"MatLab's Loss is Nobody's Gain" by Prof. William Kahan of UC Berkeley,
where he discusses the advantages and the pitfalls of using Fused MAC
hardware when the host processor makes it available.
But at any rate, using some of the tests he outlines in that paper, it
is easy to see that simple loops like the following:
let vdot v1 v2 =
let rec iter sum n =
if n < 0 then sum
else
iter (sum +. Array.unsafe_get v1 n *.
Array.unsafe_get v2 n)
(n-1)
in
iter 0.0 (pred len1)
generate results consistent with the use of the Fused MAC on the PPC G4
on the Mac OS X Panther.
Given the loose structure of this code, as written, I might have
expected the storage of intermediate sums to memory. But that does not
appear to be happening. Instead, when I perform a computation such as
the vdot of two vectors given by [1-eps; eps-1] and [1+eps; eps+1],
where eps = (nextafter 1.0 2.0 - 1.0), or the smallest discernible
delta in the double precision numbers at magnitudes around 1.0, I get
the answer for the dot product of -4.93e-32, instead of zero. That
(slightly erroneous) value indicates the use of a Fused MAC instruction
sequence.
Now I don't mind the slight incorrectness as long as I'm aware of how
and why it occurs, because I can certainly compensate for this effect.
But in general the use of a Fused MAC is desirable in computing long
dot products because it implies a lower than typical accumulation of
roundoff errors.
But more than this, I just wanted to say how impressed I am at the
prowess of the OCaml team in constructing an elegant compiler back end
where the code generation occurs. That is a very challenging part of
any compiler and the OCaml team has earned considerable respect for
their efforts!
Long live OCaml!!
David McClain
Senior Corporate Scientist
Avisere, Inc.
david.mcclain@avisere.com
+1.520.390.7738 (USA)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-06-23 15:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-23 6:03 [Caml-list] OCaml on G4 David McClain
2004-06-23 15:05 ` David Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).