help-octave
[Top][All Lists]
Advanced

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

Re: "clear mex" in octave?


From: Ben Abbott
Subject: Re: "clear mex" in octave?
Date: Fri, 20 Feb 2009 12:51:40 -0500

 
On Friday, February 20, 2009, at 12:43PM, "Joris Mooij" <address@hidden> wrote:
>On Fri, Feb 20, 2009 at 11:57:01AM -0500, Ben Abbott wrote:
>> On Friday, February 20, 2009, at 08:53AM, "Joris Mooij" <address@hidden> 
>> wrote:
>> >On Fri, Feb 20, 2009 at 07:34:32AM -0500, Ben Abbott wrote:
>> >> On Feb 19, 2009, at 8:58 AM, Joris Mooij wrote:
>> >>
>> >>> Hi all,
>> >>>
>> >>> does anybody know why octave does not automatically reload a mex file
>> >>> when I recompile it (using "mkoctfile --mex filename.cpp")? The only
>> >>> way I get octave to use the new .mex file is to restart octave, which
>> >>> is not very practical (in matlab, MEX files are reloaded  
>> >>> automatically).
>> >>> Even "clear mex" or "clear all" would not reload the mex files in
>> >>> octave.
>> >>>
>> >>> Thanks for your help,
>> >>> Joris
>> >>
>> >> Are you saying that when running Matlab, "clear mex" actually reloads  
>> >> mex files?
>> >>
>> >> Are you sure?
>> >>
>> >> Ben
>> >
>> >Actually I have never tried "clear mex" in Matlab, because Matlab
>> >automatically reloads mex files when they are recompiled... at
>> >least when the Matlab command prompt is shown.
>> 
>> In my experience, Matlab does not load mex-files until they are needed (i.e. 
>> run).
>> 
>> >So I am not sure whether "clear mex" actually reloads mex files in
>> >Matlab. However, according to the Matlab documentation for 7.0.1
>> >(R14SP1) [1], it should.
>> 
>> The link you provided says: "The command clear mex now clears MEX-functions, 
>> but not M- and MEX- functions. Entering clear mex does not clear locked 
>> functions or functions that are currently in use. It does however clear 
>> breakpoints and persistent variables."
>> 
>> I may be wrong, but it does not appear to me that Matlab loads a mex file 
>> (dll on windows) until it is needed.
>> 
>> >My actual question is about how to reload mex files in octave after
>> >they have changed on disk.
>> 
>> You should only need to run them. However, the mex file will need to be in 
>> your path.
>> 
>> If my understanding is wrong, I expect someone will correct me shortly.
>> 
>> Ben
>
>
>Thank you for your assistance. I believe I have not made myself
>sufficiently clear, though, so I will try to pose my question more
>verbosely.
>
>I believe that you are correct when you say that Matlab loads mex-files
>when they are needed. 
>
>Suppose I have some source mymexfcn.cpp and I have built it using
>Matlab's mex compile script, which yields mymexfcn.mexglx.
>Then I start Matlab and run mymexfcn:
>
>>> mymexfcn;
>
>Matlab will search for mymexfcn.mexglx in the path and execute it. 
>A little while later, it finishes and I get my command prompt back:
>
>>>
>
>Now I change the source mymexfcn.cpp and recompile it, so I get a new
>modified mymexfcn.megxlx. I switch back to the Matlab window and run
>mymexfcn again:
>
>>> mymexfcn;
>
>Now Matlab runs the new, modified mymexfcn.mexglx: Matlab detects that
>mymexfcn.mexglx has changed on disk compared with the version that it
>has previously executed. That's nice.
>
>My problem is simply that when I do the same in octave (using "mkoctfile
>--mex mymexfcn.cpp" to build mymexfcn.mex), the second call of mymexfcn
>actually runs the ORIGINAL version of mymexfcn.mex (i.e. the first
>version of mymexfcn.mex that octave has executed during that session),
>even though in the meantime the mymexfcn.mex file has changed.
>
>In order to execute the _modified_ mymexfcn.mex in octave, I know of no
>other possibility then to quit and restart octave. But that is not
>really a practical workflow...
>
>
>So my question is: is there an easier way to get octave to use the
>modified mymexfcn.mex, which does not involve restarting octave?
>
>It could also be that this is just a bug, although I don't know what
>octave is supposed to do in this situation. The only relevant
>passage in the octave manual that I found
>(http://www.gnu.org/software/octave/doc/interpreter/Function-Files.html)
>says:
>"When Octave defines a function from a function file, it saves the full
>name of the file it read and the time stamp on the file. If the time
>stamp on the file changes, Octave may reload the file. When Octave is
>running interactively, time stamp checking normally happens at most once
>each time Octave prints the prompt."
>
>First, it says "Octave [...] MAY reload the file", so it is not clear
>whether it will actually do it. Second, it is not clear to me whether
>this applies to MEX files as well (is a MEX file a function file?).
>Finally, what should one do if octave actually doesn't do a reload? Even
>using "clear mymexfcn; mymexfcn" doesn't seem to help...
>
>I would be delighted if anybody could answer this question.
>
>Kind regards,
>Joris
>

ok, I understand.

First, please file a bug report as Octave should work as Matlab does (type 
"bug_report" at the octave prompt and follow the instructions).

Ben



reply via email to

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