Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Bigarray is a pig
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David McClain <dmcclain1@m...>
Subject: Re: [Caml-list] Bigarray is a pig
I hesitate to tell you this, but have a look at my Foreign Arrays code and
you will see direct access at all times from OCaml. However, in order to
achieve this you have to commit to some very dangerous practices!

For example, OCaml only knows natively how to access unboxed contiguous
arrays of double precision. So when you need to see a foreign array directly
from OCaml it must first be converted to this format. That's okay, not
dangerous, just a potentially massive overhead on the first reference.

Secondly, the dangerous part comes in accessing the so-called Arena of the
array to direct and unsafe access from OCaml. No bounds checking here. No
function calls to each element either. The array can't move on you during GC
because it is foreign. (recent updates in my possession now conform to the
more modern Custom_tag blocks, up from the older Finalization blocks. So
these are now directly compare'able, hashable, and streamable, in addition
to being finalizable.)

With honorable respect to Xavier and the INRIA team, I did this purely for
myself, while breaking a ton of other OCaml cherished ideals as well. It
works well for me in my numerical modeling language, but the language is
explicitly unsafe. It never bombs out, mind you, but it does accept and
compile statements of utter nonsense that produce runtime errors on the
console, asking you to repeat what you said, but in a different manner...

As one respondent put it, a call is quick, and a cache miss is horrible by
comparison. You will actually generate quite a few cache misses if your
array has any significant size to it.

Cheers,

David McClain
Senior Corporate Scientist
Avisere, Inc.

+1.520.390.7738 (USA)
david.mcclain@avisere.com




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