Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] 32 bit floats, SSE instructions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: brogoff <brogoff@s...>
Subject: Re: [Caml-list] 32 bit floats, SSE instructions
On Mon, 7 Jun 2004, Brandon J. Van Every wrote:
> 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?)

Bigarray supports 32 bit floats (note to Christophe, he said 32 bit floats, not
32 bit ints!). Since the main use of Bigarray is to interface to C and Fortran,
you can take this as an implicit suggestion to write those parts of your
code in C. Sorry.

I don't think the lack of true overloading (GCaml, where art thou?) is the
problem, you can always make up some new operators for 32 bit floats. Yes,
I'd prefer overloading, but that isn't a showstopper. In any case, certain
members of the Caml cabal have commented that they are in favor of
overloading, but as usual, they want to do it right, so we may need to wait
quite a while before we see it. There is already a GCaml branch in the CVS
tree.

I think the real problem with floats (pun intended) and doubles and chars and
all that is that you frequently get unwanted boxing in OCaml and other such
languages. This will of course lead to reduced performance, which, if I
understand the game programming realm, is generally unacceptable.

I don't think that problem is insurmountable. I spoke with Stephen Weeks about a
year ago and he was interested in doing an OCaml front end for MLton, but since
he's a lean fellow and needs to eat, he was also interested in remuneration. In
case you don't know, MLton is a whole program optimizing compiler for SML which
supports

    "Untagged native integers and words of many sizes, unboxed reals, and
     unboxed arrays."

which I think is what you want for coding some of the high performing parts of
games and many other apps.

> 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?

+@, -@, etc., etc.

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

C doesn't support this either, yet people get by. I'm not making excuses for the
lack of a desirable (IMO too) feature, just pointing out that the absence of
overloading isn't the big problem here.

-- Brian

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