help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unexpected OCTAVE_LOCAL_BUFFER behavior


From: mpender
Subject: Re: Unexpected OCTAVE_LOCAL_BUFFER behavior
Date: Tue, 7 Jan 2014 19:29:34 -0800 (PST)

>My understanding is that OCTAVE_LOCAL_BUFFER is intended for locally
>scoped temporary buffers, not for allocating persistent memory. When the
>variable (the 2nd macro argument) goes out of scope, the memory for the
>buffer is freed. Attempting to assign it to a global variable and then
>letting the buffer free itself is probably not a good idea.

>From the description in the documentation as an alternative to the C++
new/delete combination
(http://www.gnu.org/software/octave/doc/interpreter/Allocating-Local-Memory-in-Oct_002dFiles.html)
I thought the scope of the allocated local buffer would be persistent for
the duration that Octave runs, and that Octave would release the buffer on
exit.  I don't want to allocate memory that is persistent only for the
duration of the oct file function call -- I really need to allocate a buffer
that persists for the duration of the main Octave process and is released
when the Octave script is complete or terminates prematurely due to an
error.

I'm trying to integrate CUDA functions into Octave and want to create a
persistent memory storage that is linked to memory on the CUDA device. 
There is a bandwidth limit on copying fresh data from Octave to the device
every time before calling the device to perform the math operations.  If I
have to recreate my buffer space every time, then the process flow will be
like this:
1) pass parameters to OCT file.
2) copy data from host to CUDA device.
3) perform math on CUDA device.
4) copy data from CUDA device back to host.
5) pass results back from OCT file.

I want to simplify the process flow by eliminating duplicate memory
allocations.  I intend to create Octave functions to allocate memory on the
CUDA device and call the math operations to operate in that space, allowing
this process flow:
1) pass parameters to the OCT file.
2) perform math on the CUDA device using data already present in the CUDA
device.
3) pass results back from the OCT file.

In essence, I don't want to create a choke point by repeatedly copying
matrices to and from the CUDA device for operations like multiplication
because it will undermine the time savings possible from the speed of the
device for math processing. 

Is there a better alternative than OCTAVE_LOCAL_BUFFER available to use that
will be persistent for the duration of the Octave process?



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Unexpected-OCTAVE-LOCAL-BUFFER-behavior-tp4660725p4660778.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]