size(libpointer.Value). Can it be done *without* copying the array

4 vues (au cours des 30 derniers jours)
Thomas Carpenter
Thomas Carpenter le 20 Mar 2015
Hi,
I am returning a pointer to an array to MATLAB from a DLL using the following (simplified) code:
arrayWidth = 16;
wordsRequired = 16*2048*1024*16*16; %16GB of uint16's
bufferPtr = lib.pointer('uint16Ptr'); %Null Pointer
status = calllib('TestLib','GetBuffer',bufferPtr, wordsRequired);
if (status >= 0)
setdatatype(bufferPtr,'uint16Ptr',arrayWidth,wordsRequired/arrayWidth); %Set size
wasSuccessful = 1;
end
That all works fine, I get the pointer back and status from my library tells me that there was enough data in the buffer for the requested length.
Now, just to make sure, I did the following:
size(bufferPtr.Value());
Expecting that to tell me the size - which it should as I used setdatatype. It tells me the correct values
ans = 16 536870912
Excellent.
BUT
What it also does, which I really don't want and have no idea why on earth it would do, is first make a local copy of the ENTIRE 16GB array. So it spends 30 seconds copying 16GB of RAM just to tell me two numbers which I told it on the line above.
Is there any way to get the size of a libpointer value without it copying it?
(p.s. I'm using 64bin Win7 with MATLAB 2013a)

Réponses (0)

Catégories

En savoir plus sur Call C from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by