[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #54788] Implementation of memmapfile
From: |
Guillaume |
Subject: |
[Octave-bug-tracker] [bug #54788] Implementation of memmapfile |
Date: |
Mon, 8 Oct 2018 05:01:27 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 |
Follow-up Comment #1, bug #54788 (project octave):
As a follow-up, I attach a version of the toy example I mentioned previously,
__mmap__.cc, rewritten as a DEFUN_DLD. It works like this:
octave> fid = fopen ("data.dat", "w");
octave> fwrite (fid, 1:128, "uint8");
octave> fclose (fid);
octave>
octave> h = __mmap__ ("data.dat", 128, 0); % mmap
octave> __mmap__ (h, "uint8", 0:7)
ans =
1 2 3 4 5 6 7 8
octave> typecast (ans, "double")
ans = 5.4476e-270
octave> __mmap__ (h, "double", 0)
ans = 5.4476e-270
octave> __mmap__ (h, 128); % munmap
One question I have pertains to subsref/subsasgn: instead of having my own
inefficient implementation (speed- and memory-wise), is there a way to reuse
Octave's versions? I.e., given:
void *ptr; /* from mmap */
dim_vector dim; /* array dimensions */
std::string precision; /* eg, "uint32" */
octave_value_list idx; /* eg, {":", [3 4 5], 2, ":", [2 3]} */
would return a uint32NDArray containing the values from *prt corresponding to
idx.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?54788>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/