[Numpy-discussion] Fast threading solution thoughts

Francesc Alted faltet@pytables....
Thu Feb 12 07:51:42 CST 2009


A Thursday 12 February 2009, Sturla Molden escrigué:
> On 2/12/2009 1:50 PM, Francesc Alted wrote:
> > Hey!  That's very nice to know.  We already have OpenMP support in
> > Cython for free (or apparently it seems so :-)
>
> Not we don't, as variable names are different in C and Cython. But
> adding support for OpenMP would not bloat the Cython language.
>
> Cython must exhange the variable names and leave the comment in C as
> a pragma to the C compiler.

Ah, I see.  I've just had a look at the code and seen this:

#pragma omp parallel for private(c) schedule(guided) 
num_threads(nthreads)

and I thought that the support was there.  But obviously name mangling 
is the problem.

>
> IMHO, OpenMP is the easiest way to use parallel computing in
> scientific projects. It is much easier than manually fiddling with
> threads, processes, MPI, etc. Just write code as you normally would,
> debug and verify. Then you spend five minutes inserting pragmas to
> the compiler, and et voilá you have a parallel program. The same code
> will then compile and run correctly for parallel or sequential
> execution, depending on a compiler switch (-fopenmp). You get load
> balancing for free, as that is built into OpenMP. OpenMPs API is so
> small that it just takes 10 minutes to learn.

Well, ten minutes if you are *already* used to parallelism ;-)  But I 
agree, it is, by far, the easiest path to it.

> OpenMP currently works on SMPs (e.g. multicore CPUs), but there is
> work going on to port it to clusters as well.

That's good to know.

-- 
Francesc Alted


More information about the Numpy-discussion mailing list