3 ms·
How does Owl handle representing arrays of Float64s (for example) in BLAS-compatible format? That is, as contiguous memory blocks, instead of having each float
by StefanKarpinski 7y ago
How does Owl handle representing arrays of Float64s (for example) in BLAS-compatible format? That is, as contiguous memory blocks, instead of having each float value individually heap allocated and boxed with the array being an array of pointers to these values. That ability seems like the most basic requirement for a language in which scientific computing is done—if for no other reason than to call BLAS and LAPACK and other Fortran/C/C++ libraries. Vanilla OCaml doesn't support this (as far as I'm aware), so you'd need something like NumPy which grafts typed arrays onto Python, but for OCaml. Of course, OCaml already has typed arrays, unlike Python, there's just a legacy insistence that all collections work with pointers to values, since other wise you might need to compile generic code more than once (god forbid). Is such an "efficient array library" part of Owl? Any tidbits on how it works?
- srean 7y agoIf I understand correctly its based on http://caml.inria.fr/pub/docs/manual-ocaml/libref/Bigarray.html http://caml.inria.fr/pub/docs/manual-ocaml/libref/Bigarray.h... What is a little strange is that Bigarray seems to support both C and Fortran order, but as of now Owl Ndarrays are C order only.
- mseri 7y agoThat’s correct. Afaik, in Owl, the choice to support just C was intentional to avoid overcomplicating the implementation
- tomp 7y agoOCaml has native support for unboxed ("flat") double arrays. https://github.com/ocaml/ocaml/blob/d3e73595e55e84250fa77f04e9c239dee1224b7b/runtime/caml/mlvalues.h#L279 https://github.com/ocaml/ocaml/blob/d3e73595e55e84250fa77f04...
- StefanKarpinski 7y agoBut only for doubles as a one-off thing? That's more than a little a bit unsatisfying...
- mseri 7y agoBigarray[1] allows you to do that and share the memory between C and OCaml. [1]: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Bigarray.html https://caml.inria.fr/pub/docs/manual-ocaml/libref/Bigarray....