Octave taking too long to save image files - performance

I'm running Octave 3.8.1 on a i3 2GB DDR3 RAM powered notebook within Ubuntu 14.04 on dualboot with Windows 7.
And I'm having a really hardtime saving plots that I use on my seismologic research, they are quite simple and still I wait almost 5 min to save a single plot, the plot is built within seconds, the saving though...
Is it purely a problem with my notebook performance?
When I run a program for the first time I get the following warnings on shadowed functions, has one of them anything to do with it?
warning: function /home/michel/octave/specfun-1.1.0/x86_64-pc-linux-gnu-api-v49+/ellipj.oct shadows a built-in function
warning: function /home/michel/octave/specfun-1.1.0/erfcinv.m shadows a built-in function
warning: function /home/michel/octave/specfun-1.1.0/ellipke.m shadows a core library function
warning: function /home/michel/octave/specfun-1.1.0/expint.m shadows a core library function
Also, this started to happen when I upgraded from a very old version of Octave (2.8 if I'm not mistaken), it seems that the old one used to run on the linux default plot making functions, and the new one (3.8.1) runs on its own, is it correct? I used to take a little more time with this notebook that I take with the lab PC, but not even close to 5min+ for each plot.
Is there anything I can do, like upgrading anything within the octave or "unshadowing" the functions mentioned before?
Thanks a lot for the help.

Shadowing functions is just a name clash which is explained for example here: Warnings after octave installation
As for low performance, octave renderer doesn't seem to be well optimized for writing plots with huge number of points. For example, the following:
tic; x=1:10000; plot(sin(x)); saveas(gcf,'2123.png'); toc;
Will put octave in coma for quite a while. Even though the plot itself is made in an instant. If amounts of your data are of comparable magnitude, consider making it more sparce prior putting it on the graph.
There's no default linux plotmaker, there's gnuplot. You may try your luck with it by invoking
graphics_toolkit gnuplot
before plotting. (To me it didn't do much good though. graphics_toolkit fltk will return octave's usual plotter.)
If the slowness you refer to is in saving three dimensional plots (like mesh), the only workaround I've found on system similar to your is to use alt+prtscr.
Alternatively, you could try obtaining octave 4.0 which is released by now. It's changelogs mention yet another graphics toolkit.

Related

Using `callgrind` to count function calls in Linux

I am trying to track function call counts on a program I'm interested in. If I run the program on its own, it will run fine. If I try to run it with valgrind using the command seen below I seem to be getting a different result.
Command run:
Produces this input immediately, even though the execution is normally slow.
I'd say that this is more likely to be related to this issue. However to be certain you will need to tell us
what compilation options are being used - specifically are you using anything related to AVX or x87?
What hardware this is running on.
It would help if you can cut this down to a small example and either update this or the frexp bugzilla items.
valgrind has limited floating point support. You're probably using non-standard or very large floats.
UPDATE: since you're using long double, you're outta luck. Unfortunately,
Your least-worst option
is to find a way to make your world work just using standard IEEE754
64-bit double precision.
This probably isn't easy considering you're using an existing project.

How to track down source of memory leaks in luajit from calls to opencl api through FFI

A while ago I wrote fractal program in Lua. It works fine on my old Windows 7, and Windows 8 PCs.
I got a new laptop with Windows 10, and I run it with luajit 2.1.0 , that was working best for me in the past. Unfortunately some of the runs with various parameters failed with no errors or cause. And then I noticed that even successful execution is using too much memory. I tried my best to track down the problem using various builds of luajit from 2.0 to 2.1 , but only thing I can see is that memory leak is somehow connected to FFI calls to OpenCl api.
If someone is willing to take a look, I will provide complete code of program and required api dlls.
Attaching old demo lua code , that is also leaking on win10 , based on and using : https://github.com/malkia/luajit-opencl
cl-demo.lua : https://github.com/LuaJIT/LuaJIT/files/4366334/cl-demo.txt
I'm sure that my post was not worded correctly, English is not my first language, and maybe not in the right place. I didn't mean someone waste time debugging my cobbled together old code, but to maybe point me in the right direction, or suggest some easily available memory errors inspection tool, like purify. I used to use it to find memory bugs, unfortunately its no longer available for single user.
Also I now have a strong suspicion that something is overwriting memory after calls to opencl. as a result calls to os.time, math.random & etc. result in code unexplained execution stop.
The following code after calls to OpenCL starts to behave weird, ii value in the last loop in the if statement all of sudden gets value like 0.13900852449513657 !
clfns[1]=true;
for ii=2,34,1 do clfns[ii]=false; end
for ii=2,34,1 do if string.find(formula, c2fns[ii] .. "[(]") then
for jj=1,4,1 do if cdfns[ii][jj] then clfns[cdfns[ii][jj]]=true; end end
end end
for ii=1,34,1 do
if clfns[ii] then
cFuns = cFuns .. cfns[ii]; end end
I have created a workaround for various problems my program had running on windows 10 and 8.1 with latest updates from Microsoft.
First to prevent luajit abrupt unexplained terminations running various versions of my lua code, I have rebuild luajit 2.1 under Microsoft Developer studio 2008 with alternative optimization options (/Ox /Ot). I was able to use similar compile options under 2015 & 2020 versions of MsDev , but had to add /guard:cf /D_CRTDBG_MAP_ALLOC , resulting in slower execution, up to 32%, and still some very weird sporadic aberrations.
To combat memory leak (over 100mb per fractal image generation) , I had to add collectgarbage() after every cl kernel program completion. And add release , free, and recreate memory buffer for every que of results from OpenCL code execution, which solves most of memory problems, but slows execution depending on size and complexity of running formulas from 19% to 41%.
added code :
clEnqueueReadBuffer(commands, output[jb], cl.CL_TRUE, 0, ressize, results, 0, nil, nil)
...
clReleaseMemObject(output[jbo]);
output[jbo] = nil;
output[jbo] = ffi.gc(clCreateBuffer(context, cl.CL_MEM_WRITE_HOST_PTR, ressize), ffi.C.free);
There still some memory issues when I run my program with OpenGL 3D output utilizing iup libraries, mostly due to garbage collection not catching up, but I can probably solve it by implementing use of 4 parallel threads using same content program space but separate kernels.
Still any suggestions, explanation or corrections would be greatly appreciated

Why do different homographies affect running time?

I am applying OpenCV's warpPerspective() function to an image and I'm timing this task (only the call to the function, nothing else). I noticed that if I use different homographies the running time changes.
For example I tried using the identity matrix and found that it is faster than another homography that I generated with OpenCV's findHomography(), specifically this one:
[ -4.2374501377308356e+00, -4.1373817174321941e+00, 1.6044389922446646e+03,
-1.6805996938549963e+00, -9.0838245171456080e+00, 1.9901208871396577e+03,
-2.4454046226610403e-03, -8.2658343249518724e-03, 1. ]
Please note that the output is not my concern, I am only talking about running time. So why is it different?
Thanks
EDIT: I'm using OpenCV 3.4 on a PowerVR GX6650. I tested it with and without OpenCL and the pattern is still the same.
As mentioned by #Micka in the comments, the difference seems to be given by the different number of times that the interpolation method is called.

Matlab GUI windowButtonMotionFcn slows down when number of GUI object gets larger

I am now programming a Matlab GUI for accessing current point of cursor on an axes whenever user changes the location of cursor. However, I found a strange phenomenon that the speed of windowButtonMotionFcn got slower with an increase in number of GUI object. Below is the result
http://i.stack.imgur.com/fwjCK.jpg
I set the properties of all GUI objects as default value and my operating Matlab version is Matlab 2012a. Is there any possible way to keep the speed of windowButtonMotionFcn when number of GUI object increases?
Thank you for your attention and help.
Myrick
I do not know exactly how the event handlig is implemented in matlab. However, it seems reasonable that more gui objects will slow the process. Think of it as, more gui objects requires more memory, more objects to handle, more code, longer lists to search through... I have also experienced that the GUIs created with GUIDE is generally slower than a GUI made by hand. This is not tested in anyway and is thus not confirmed. However, when I do not need too many objects in the GUI, I normally prefer to create them by hand. The GUIDE guis is normally more general, but in most cases only a subset of the facilities is used anyway.
Try using the figure's underlying Java frame's MouseMovedCallback:
jFrame = get(handle(hFig), 'JavaFrame');
try
% This works up to R2011a
jClient = jFrame.fFigureClient;
catch
try
% This works from R2008b and up, up to HG2
jClient = jFrame.fHG1Client;
catch
% This works in HG2
jClient = jFrame.fHG2Client;
end
end
jWindow = handle(jClient.getWindow, 'CallbackProperties');
set(jWindow, 'MouseMovedCallback', #matlabCallbackFunction);
I had a bit similar problem with "slowing" and "memory leak".
Problem was avoided by using delete(gca) before redrawing only visible objects.

easy, programmable data plotting

I spend most of my time plotting data, but unfortunately I haven't found a decent solution for my plotting needs. At the moment, the most powerful and pleasant library I found that performs plotting is matplotlib. The results are stunning, but I mostly spend my time fighting with the library when trying to do simple things like having an arrow as I want. SImilar programs like R and gnuplot produce visually less appealing results, and they are not GUI based.
On the other hand, programs like xmgrace (or better) allow direct manipulation of the plotted objects and direct feedback, but they fail on two important points:
if my dataset (normally stored in csv files) changes for some reason, I have to reimport it and perform the manipulations again, by hand
once I obtain a nice plot setup, the only way I have to recreate the plot is to use a graphical, interactive program. I would like to have the possibility to run a command line utility on my csv files and get the .pdf as a result, with no human intervention.
I still have to find something that provides me both worlds, and it has an affordable price. Ideally, I would need an interactive GUI program (a la Origin) to generate matplotlib-based python scripts.
Does anyone have any hints on software that could address my needs on OSX (preferably) or Linux ?
You may want to check out Igor Pro. It's quite old, and quirky but it provides the most advanced plotting system I've found yet on the Mac. You can modify anything graphically, at a command line or in script files. The most powerful feature (IMO) is the ability to automatically generate a script to recreate a figure or to use a figure to create a script that generates figures like (in style etc.) a particular figure. I use Igor for all publication figures I produce.
Data is stored in "waves" (translation: vectors) which encapsulate data and information about the delta between data points (e.g. time step). Figures reference waves as their data source. When you update a wave (e.g. by re-importing a CSV file and specifying that the data overwrite specific waves), all figures that reference that wave are automatically updated.
You can create "layouts" which are page-layouts containing multiple graphs. These layouts are also automatically updated whenever any of the figures in the layout are updated (see above). You can add drawing/text/annotations to either graphs or layout.s
Be warned: Igor Pro's scripting language is something like the bastard child of VB and Matlab. It makes my eyes bleed. It makes me pray to whatever God that the pain just end. But the entire system is so powerful that it's worth it.
I have always used Matlab or R for this sort of thing. While you may not like how the generic plots look, I find that once I familiarize myself with the libraries I can make them as fancy as I want them to be.
R being free, I would try to stick it out with that. It is extremely powerful and perfectly suited to what you need (generate charts on the fly directly from datafiles). I bet that the more you get comfortable with it, you'll find yourself using R for a wide range of tasks outside of plotting data.
MathGL is cross-platform GPL library which meet all yours criteria. It can produce nice graphics, it can read csv files, it have window for displaying graphics (you don't need to know widget libraries), and it can plot in console (don't need a window or X at all). At this you can use C/C++/Fortran/Python/... for yours own code or MGL scripts for simplicity (see UDAV front-end in the last case).
Finally it can produce bitmaps (PNG/JPEG/GIF/...) or vector (EPS/SVG) output. Later it can be converted to PDF easily. Or you can create a PDF with U3D directly -- you'll need HPDF and U3D libraries in this case.

Resources