SPM/Faster SPM
From Wikibooks, the open-content textbooks collection
Contents |
[edit] SPM Optimisation
[edit] Adjusting SPM settings
A defaults variable 'maxmem' indicates how much memory can be used at the same time when estimating a model. If you have loads of memory, you can increase that memory setting in spm_defaults.m:
defaults.stats.maxmem = 2^30;
- 2^30 = 1GB
- 2^29 = 512MB
[edit] Compiling the MEX files
The compiled MEX files provided with SPM are built in such a way to be compatible with most platforms and MATLAB versions but you might benefit from compiling them for your exact platform/MATLAB version - some C compilers might also produce better optimised binaries (such as Intel Compilers). See the installation pages for more details on how to recompile SPM MEX files.
[edit] MATLAB Optimisation
[edit] General statements
Maximizing MATLAB Performance.
Note that it is not recommended to disable the JAVA Virtual Machine when launching MATLAB (matlab -nojvm). If you don't want to use the MATLAB desktop, you can preferably launch MATLAB with:
matlab -nodesktop
[edit] Multithreading
Recent MATLABs support implicit multiprocessing allowing to run multiple threads on a single machine without any change to the MATLAB code itself: this requires a multiple CPU (multiprocessor or multicore) system. The gain in compute time with SPM is not dramatic though.
See:
- http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/brdo29n-1.html
- http://www.mathworks.com/access/helpdesk/help/techdoc/ref/maxnumcompthreads.html
If you run many MATLAB sessions in parallel to manually distribute your SPM processings, it is recommended to set the number of computational threads to one.
[edit] Updating BLAS/LAPACK
Install the latest Basic Linear Algebra Subroutines (BLAS)/Linear Algebra PACKage (LAPACK) for your system, as MATLAB doesn't ship the latest version in its releases.
The main choices are between:
- ATLAS - Automatically Tuned Linear Algebra Software (open source)
- MKL - Intel Math Kernel Library
- ACML - AMD Core Math Library
For more information on how to upgrade your MATLAB libraries with ATLAS/MKL, see:
- http://software.intel.com/en-us/articles/using-intel-mkl-with-matlab/
- http://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-for-windows-using-intel-mkl-in-matlab-executable-mex-files/
- http://imaging.mrc-cbu.cam.ac.uk/imaging/SpmWithPentium4
[edit] Parallel Computing
[edit] SPM toolboxes
See pSPM for SPM2.
[edit] General tools
There is currently work in progress to provide an official parallel/distributed version of SPM8.
See also the Sun Grid Engine Project (SGE):
[edit] Using the Graphics Processing Unit (GPU)
Modern graphics cards have an enormous amount of processing power which could be harnessed for doing scientific calculations. It is already possible to have MATLAB making use of the GPU with the help of some external toolboxes.
If you are interested to learn more about it, these links might be useful:
- AccelerEyes Jacket Software for Matlab GPU computing
- Linear Algebra Operators for GPU Implementation of Numerical Algorithms
- GPUs doing scientific calculation
- BrookGPU - a compiler for GPUs
- GPGPU - General-Purpose Computation Using Graphics Hardware
- GPGPU Forums
- GPGPU thread on using GPU with MatLab
- Implementing Performance Libraries on Graphics Hardware
- Brook on GPUs: stream computing on graphics hardware Paper
- Brook for GPUs: Stream Computing on Graphics Hardware PDF powerpoint presentation
- The GPU as a Computational Resource in Medical Image Processing November 2004
[edit] Benchmarks
- SPM Benchmarks - possibly outdated.