From: Tamas K Papp <tkpapp@gm...> - 2010-02-02 20:42:17
I am trying to mmap an array of double-floats. In particular, my
ideal workflow would be the following:
1. create a 2d array, eg with
(make-array '(10000 100000) :element-type 'double-float)
and fill that array with elements.
2. Dump the array into a file.
3. Load it using mmap, so that it ends up as a Lisp object, and
analyze the contents.
I think I pieced together something that does 3. by slightly modifying
code from a blog post of Juho Snellman:
(defun mmap-lisp-object (map-file)
"Return a lisp object, corresponding to data dumped into a file."
(with-open-file (file map-file)
(let* ((sap (sb-posix:mmap nil
(addr (logior (sb-sys:sap-int sap)
But I don't know how to do the dumping. I know I can get a pointer to
the contents of the lisp array with sb-sys:vector-sap, but that is
only the elements, not the header. Ideally, I am looking for the
function that returns the pointer at the start of the object
(including the header) and the total length in bytes. Then I could
just pin the array, query the pointer & length, and write out stuff in
a loop. Does this make sense, or are there better ways?
I would appreciate any help on which SBCL functions I could use to
actually do this.