help-octave
[Top][All Lists]
Advanced

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

Re: OpenMP in oct files


From: Mike Puglia
Subject: Re: OpenMP in oct files
Date: Mon, 23 Sep 2013 04:13:15 -0700 (PDT)

Hi Daniel,

I'm certainly no expert in this, so I'm not sure I can answer your questions well, but I had almost the same problems getting openmp to work in Octave as well.  I don't know how the matrix classes are written, but I assume when you start accessing a matrix from multiple threads at the same time there will be a problem with pointers flying all over at least.  I tried to parallelize a few very simple for loops that acted on a (octave) matrix class and all I can say is the result was unstable.  Although all of the for loops were pretty similar, I had cases where the parallel loop worked flawlessly with the expected accelerations, I had cases where the loops worked flawlessly but with no acceleration (though multiple threads were active) and I had cases where the results were incorrect.  I don't think I had any problems with crashing however.  After looking into it I'm pretty sure that I wasn't making any of the basic mistakes for working with openmp.  All of the loops were pretty simple and should have had the same behavior (i.e. they all work or they all don't work, they are all accelerated or they are all not accelerated).  That was not the case however.  I'm sure someone with better knowledge of the matrix classes can explain why, but I eventually gave up on it.

Regarding CUDA, I'm just starting to work on that myself.  Did you use the VS2010 build by any chance?  If not, how did you link with the nvcc compiler output?

Cheers,

Mike



From: Daniel Kraft <address@hidden>
To: Mike Puglia <address@hidden>; "address@hidden" <address@hidden>
Sent: Monday, September 23, 2013 6:17 PM
Subject: Re: OpenMP in oct files

Hi Mike,

On 2013-09-23 05:01, Mike Puglia wrote:
> I don't remember that I had exactly the error you're having below, but I
> had a few problems getting OpenMP to work in oct files as well, even
> after trying some of the same posts.  I use the mingw build.  Ultimately
> I had to compile all the OpenMP functionality into a static library
> using gcc directly (with -fopenmp flag in the command line).  Then I
> wrote an octfile wrapper around the exposed library function, so that
> mkoctfile was more or less blind to the OpenMP functionality.  At the
> mkoctfile command line, I just included the static library and -lgomp
> during linking and everything worked fine from there.

thanks for your tips!  I indeed managed to fix my error by compiling the
OpenMP code directly with g++ instead of mkoctfile and linking it as a
shared library.  (The same approach also worked fine for me when I
played around with CUDA in oct-files.)

Unfortunately, the parallel code sometimes crashes or is at least not
any faster than the single-threaded version.  My code, also the one that
is in a parallel OpenMP loop, uses liboctave's Matrix and vector classes
-- I presume my problems arise because Octave is not thread-safe.  Is
this a likely explanation, even when I don't need any of the
higher-level things (files, symbol table, ...) in Octave but just the
basic octave_value classes?  Is there a way to make it work, or do I
have to use re-implement the parallel code without relying on liboctave
at all?

Yours,
Daniel

--
http://www.domob.eu/
--
Done:  Arc-Bar-Cav-Hea-Kni-Ran-Rog-Sam-Tou-Val-Wiz
To go: Mon-Pri



reply via email to

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