help-octave
[Top][All Lists]
Advanced

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

Re: Run and interface external program compiled with ICC (NOT mkoctfile!


From: Przemek Klosowski
Subject: Re: Run and interface external program compiled with ICC (NOT mkoctfile!)
Date: Mon, 28 Jun 2010 17:30:13 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b1 Thunderbird/3.0.5

On 06/28/2010 12:31 PM, Carlos222 wrote:

Dear colleagues.
I need your help. I have a code in matlab that now I implement in the
Octave. As you should know the octave for many operations using matrix is
much slower than matlab. Anyway, I am intend to take the slowest part of my
code and compile using the intel compiler and the intel MKL (math kernel
libraries) using all the advantageous of the parallelization in my core i7
processor.

Well, the matrix operations in Octave are usually as fast or faster than matlab. You have to make sure that you use an optimized BLAS library, of course. Octave lags when your .m code uses explicit loops (for, while...), accessing the data element-by-element. The usual cure for that is rewriting the .m code to vectorize it. If you can't vectorize, only then you'd rewrite it in compiled language.

You should run some speed tests for your code; use tic/toc and/or cputime functions to measure the speed of operations that matter to you.

The compile program should receive a vector as input and gives
another longer vector as output. My first idea was using files in the hard
disk to interface the program with octave. Something like :
   "save input_file.txt"
   "system(run_icc_compiled)"
  "wait sometime or check the output_file.txt"
  "load the output_file.txt"

The problem is that this part of the program that I want to compile will run
thousand of times and this read/write in disk can make everything slower...

My question is: Is there some more intelligent (and hopefully easy) way to
do this interface without write/read in the disk?

Octave has excellent library interface, so you can write your computational kernel and compile it into an Octave-loadable native binary module (an .oct file); you'd then write the I/O and pre/post-processing in the interpreted language (.m files), and then call out your binary computation code, passing the data into and out of it using Octave data API. There have been good examples of that on this list, even quite recently.


reply via email to

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