caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* RE: [Caml-list] 32 bit floats, SSE instructions
@ 2004-06-08  8:10 Ennals, Robert
  2004-06-08 11:17 ` skaller
                   ` (2 more replies)
  0 siblings, 3 replies; 47+ messages in thread
From: Ennals, Robert @ 2004-06-08  8:10 UTC (permalink / raw)
  To: Nicolas Cannasse, Brandon J. Van Every, caml


[snip]

> The main problem with float's - whatever if they are 32 or 64 bits -
is
> their boxing . OCaml runtime value representation is efficient but a
float
> -
> even 32 bits - cannot be carried in a register as it could be in C.
> (actually some unboxing can be performed locally by ocamlopt). This is
> mainly because OCaml is an high-level language, with a garbage
collector,
> and so needs to keep the track of what is being allocated in an
efficient
> way. 

I assume you are referring to the way in which OCaml reserves one bit in
each word to use as a tag that indicates whether the word represents a
pointer or not (which is also the reason for ints being 31 bits).

While a GC does need to have some way to distinguish between pointers
and data, this is not the only way that this can be done. Another
approach (used by GHC) is to dispense with tag bits and instead store a
bitmask for each datatype and each stack layout, indicating which fields
are pointers.

I don't know much about the relative advantages/disadvantages of the two
approaches, but there is definitely a design space to be explored, and
it is definitely possible to have native 32 bit floats in a garbage
collected language.

[snip]

-Rob


-------------------
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] 47+ messages in thread
* RE: [Caml-list] 32 bit floats, SSE instructions
@ 2004-06-08 17:15 Jon Harrop
  2004-06-08 19:59 ` Brandon J. Van Every
  2004-06-09 16:26 ` Xavier Leroy
  0 siblings, 2 replies; 47+ messages in thread
From: Jon Harrop @ 2004-06-08 17:15 UTC (permalink / raw)
  To: caml


This post of mine seems to have gone walkies:

On Mon, 7 Jun 2004, Brandon J. Van Every wrote:
> A 3D graphics guy has to contend with a large number of numeric
> problems.  Some of them are cut, dried, and repetitive enough to justify
> coding up a C routine for them.  For example, transforming a large
> number of XYZW vectors by a 4x4 matrix is a 'pat' problem that occurs at
> some point in 3D graphics processing.

If you want high performance, which you seem to want, the hardware should
be doing those for you.

> However, lotsa 3D problems are exploratory in nature.  For those you
> want to use an efficient high level language, i.e. OCaml.  You'd like to
> code it up once, have it be pretty fast, and not ever worry about
> futzing with C <--> OCaml bureaucracy.  There isn't necessarily an
> 'array version' of the problem, and you may not wish to figure it out in
> any event.

If you don't want to "figure out" optimisations then you can't expect to
get efficient programs.

> C interfaces carry overhead, i.e. you'd rather have stuff go
> straight down to machine code without any function calls, if all you're
> doing is twiddling a few floats.

I'm not sure you would rather do that. Can you give an example of where
ocamlopt is so inefficient that a whole program could benefit
significantly from optimising such a piece of code?

> Basically it's not an answer to say "Ah, yes, look at this great
> language OCaml!" when in practice all you're ever doing is writing C.

I would expect to be dropping to C for only a tiny piece of (trivial to
write) code. If you want to do anything complicated (which is where all
the important optimisations are) then OCaml would be a much better choice.

> I'm not exactly sure why language designers think 32 bit floats "don't
> count."  Quite a number of high level languages make the choice of
> blowing them off.

Typically because the language designers know that other aspects of the
run-time will degrade performance significantly more.

> I guess quite a lot of high level languages aren't
> interested in widespread industrial application, just ease of compiler
> implementation.

In the case of OCaml, the language is there because it is a research
project. Adding 32-bit floats doesn't count as research these days. Not
even in France. ;-)

> The reality is that 32 bit floats get used in the real
> world all over the place by 3D graphics guys.

Don't read that, Xavier.

> The last time I tried to talk about 32 bit floats with 'language guys'
> was the Python crowd.  Generally speaking, that community doesn't have a
> clue about performance, and hasn't coughed up any significant 3D
> graphics work either.

I don't believe Python was designed for doing 3D graphics.

Most people want to write 3D graphics programs which run in real-time. In
order to even attempt to satisfy this design criterion it is necessary to
be close to the hardware - you need to know what it is capable of doing
and how quickly. This goes directly against one of the fundamental design
criteria of ML which is to "abstract from the machine".

On the other hand, well designed graphics software can generically make
very efficient use of modern, consumer graphics hardware from a high-level
language such as OCaml. When used correctly, the OpenGL API is quite
high-level. Also, it is much more effective (and interesting!) to spend
your time performing algorithmic optimisations rather than tweaking your
code at the 32-bit float level.

Cheers,
Jon.

-------------------
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] 47+ messages in thread
* [Caml-list] 32 bit floats, SSE instructions
@ 2004-06-07 11:13 Brandon J. Van Every
  2004-06-07 11:32 ` Christophe TROESTLER
                   ` (2 more replies)
  0 siblings, 3 replies; 47+ messages in thread
From: Brandon J. Van Every @ 2004-06-07 11:13 UTC (permalink / raw)
  To: caml

[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]

Game developers do tons of stuff with 32 bit floats.  How difficult to
add these to OCaml?  I'm not saying, "do it for me," I'm asking how
difficult it would be to add to the language.  If it were feasible, then
this mod could be distributed as a patch, until such a time as it is
accepted as A Good Thing.  (Anyone already tried this?)

Does the lack of operator overloading pretty much prevent this support
in practice?  If there's only one +. operator available, and it's for 64
bit floats, whaddya gonna do?

SSE instructions I imagine would be more involved.  The data type I'm
interested in is a vector of 4 32 bit floats.  Sounds like another job
for operator overloading.


Cheers,                     www.indiegamedesign.com
Brandon Van Every           Seattle, WA

"The pioneer is the one with the arrows in his back."
                          - anonymous entrepreneur


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.693 / Virus Database: 454 - Release Date: 5/31/2004
 

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 2216 bytes --]

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2004-06-10 19:47 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-08  8:10 [Caml-list] 32 bit floats, SSE instructions Ennals, Robert
2004-06-08 11:17 ` skaller
2004-06-08 17:42 ` John Carr
2004-06-09 16:13 ` Xavier Leroy
  -- strict thread matches above, loose matches on Subject: below --
2004-06-08 17:15 Jon Harrop
2004-06-08 19:59 ` Brandon J. Van Every
2004-06-09  3:15   ` skaller
2004-06-09  4:08   ` Brian Hurt
2004-06-09  6:33     ` skaller
2004-06-09 16:26 ` Xavier Leroy
2004-06-09 17:58   ` Christophe TROESTLER
2004-06-09 18:15     ` Daniel Ortmann
2004-06-09 18:52       ` Kenneth Knowles
2004-06-09 20:03         ` John Carr
2004-06-09 19:54   ` Brandon J. Van Every
2004-06-07 11:13 Brandon J. Van Every
2004-06-07 11:32 ` Christophe TROESTLER
     [not found]   ` <20040607131717.GA12136@gaia.cc.gatech.edu>
2004-06-07 16:53     ` Christophe TROESTLER
2004-06-07 19:30       ` Brandon J. Van Every
2004-06-07 20:39         ` Nicolas Cannasse
2004-06-08  5:42           ` Brandon J. Van Every
2004-06-08 16:54             ` Jon Harrop
2004-06-08 20:50               ` Brandon J. Van Every
2004-06-09  3:19                 ` skaller
2004-06-08 14:23           ` Keith Wansbrough
2004-06-10 14:43             ` David Brown
2004-06-10 15:20               ` Keith Wansbrough
2004-06-10 15:57                 ` skaller
2004-06-10 16:23                   ` Keith Wansbrough
2004-06-10 16:47                     ` skaller
2004-06-10 19:46                     ` Evan Martin
2004-06-07 21:00         ` Richard Jones
2004-06-07 21:42           ` Jon Harrop
2004-06-09 15:55           ` Richard Jones
2004-06-07 22:48         ` Chris Clearwater
2004-06-07 17:01 ` brogoff
2004-06-08  1:50 ` Brian Hurt
2004-06-08  5:27   ` Brandon J. Van Every
2004-06-08 15:05     ` Brian Hurt
2004-06-08 16:50       ` art yerkes
2004-06-08 17:10     ` Jon Harrop
2004-06-08 19:24       ` Brandon J. Van Every
2004-06-09  0:25         ` Jon Harrop
2004-06-09  1:33           ` Brandon J. Van Every
2004-06-09  3:04             ` Jon Harrop
2004-06-09  3:27           ` skaller
2004-06-09 14:21             ` Christophe TROESTLER

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).