Parallel Fieldtrip

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Tue Dec 11 09:56:30 CET 2007


On 8 Dec 2007, at 5:10, Sebastian Gonzalez wrote:
> I was wandering if it is possible or is already done, to use intel
> TBB to build mex files to use in filedtrip. ("It is a library that
> helps you take advantage of multi-core processor performance
> without having to be a threading expert." from http://
> threadingbuildingblocks.org/ )
>
> If it's done, I would like to know how, and if is not, I would like
> to try to rewrite some functions using TBB.

Hi Sebastian

In the past there has been some parallelism geared toward running
FieldTrip on a linux cluster (see http://oase.uci.ru.nl/~roberto/
index.php/mentat), but that was too difficult to maintain and
therefore I removed it. Recently I evaluated StarP (http://
www.interactivesupercomputing.com) and the Distributed Computing
Toolbox+Engine (http://www.mathworks.com/products/distribtb/). StarP
was not suitable because of not supporting the Matlab toolboxes on
the "computing engines", and the DCT was not optimal because of the
relatively slow data transport protocol between the master node and
the engines. I will continue looking into DCT to see whether it can
be tweaked to prevent the data transport between cluster nodes being
the bottleneck.

Your sugegstion of using multithreading in a mex file is new to me.
FieldTrip comes with 8 mex files, most of them related to forward
computation. That means that speeding these mex files up will only
impact the sourceanalysis and dipolefitting function. For
sourceanalysis (which uses a fixed and pre-defined dipole grid), the
prepare_leadfield function is already a good way of speeding up the
computations. Although I like the idea, I doubt whether working on
those 8 mex files will result in a noticeable speed increase. But
that of course depends a lot on the exact nature of the computations
that you do a lot. Let me give a list of functions and what they are
involved in:

* meg_leadfield1.mexa64
This one is used for MEG forward modelling using single and local-
spheres models.

* lmoutr.mexa64
* ptriproj.mexa64
* routlm.mexa64
* solid_angle.mexa64
These are used for forward computation in the BEM-EEG case, but only
in the preparatory phase (i.e. not while iterating over dipole
positions). They are also used for determining which dipoles are
inside the head of a volume conduction model (which is done for
almost all forward computation methods, but also only once). After
one call to prepare_leadfield and these functions would not be used
any more in the sourceanalysis function.

* plgndr.mexa64
This is used for 3 and 4-sphere EEG forward computation, and will be
called on each iteration in dipolefitting.

* read_24bit.mexa64
This is for reading BDF files.

* splint_gh.mexa64
This is for computing the EEG surface laplacian.

The source code of these mex files is included in the fieldtrip
release version (private/mex directory). I presume that you are aware
of the Matlab profiler: that will give you a good overview of the
time spent in these mex files, compared to teh time spent in other
parts of the code. Subtracting the time spent in the mex files from
the total time gives you the maximum speed increase that can be
achieved by optimizing the mex files (i.e. if 20% of the time would
be spent in a mex file, then speeding up that mex file to infinitely
fast would result in 0% time spent in that mex file, but you would
still spend the 80% of the time in the other parts of the code).

I am curious to see how much it can be sped up.

best regards,
Robert

PS I am also not aware of people having tried to speed up the
standard Matlab BLAS computations as explained here http://
www.mathworks.com/support/solutions/data/1-34HE9M.html. It would also
be interesting to see how muct that might help.

PS

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/fcdonders/fieldtrip.



More information about the fieldtrip mailing list