Multicore - Parallel processing on multiple cores

This package provides parallel processing on multiple cores/machines.
Updated 21 Jul 2014

View License

This package provides parallel processing on multiple cores on a single machine or on multiple machines that have access to a common directory.
If you have multiple function calls that are independent of each other, and you can reformulate your code as

for k = 1:numel(parameterCell)
resultCell{k} = myfun(parameterCell{k});

then, replacing the loop by

resultCell = startmulticoremaster(@myfun, parameterCell);

allows you to evaluate your loop in parallel. All you need to do is to start as many additional Matlab sessions/processes as you want slaves to work, and to run


in those additional Matlab sessions.

Everything is programmed in plain and platform-independent Matlab - no toolboxes are used, no compilation of mex-files is necessary.

Please get started with 1. the documentation in file multicore.html, 2. the help lines of function startmulticoremaster.m and 3. the demo function multicoredemo.m.

Discuss with other users here:

I have spent many hours to develop this package. If you would like to let me know that you appreciate my work, you can do so by leaving a donation:

Keywords: Parallel processing, distributed computing, multiple cores.

Cite As

Markus Buehren (2024). Multicore - Parallel processing on multiple cores (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Big Data Processing in Help Center and MATLAB Answers

Inspired: gapolyfitn, Batch Job

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Performance improvement especially for projects using many slave processes.

Added parfor-loop to demo.

Performance improvement - especially when using a large number of slaves

New features:
1. Slave settings can be set via command line argument.
2. Slave Matlab process can be quit after a given time in seconds.

Bugfix: calling startmulticoremaster.m without settings works now.

Typo fixed.

Typo fixed.

Overhead resulting from expanding the function handle cell reduced.

Description changed again.

Links in help lines corrected.

Description modified to make it more concise.

Only E-mail changed in html document.


Small changes to documentation and gethostname.m

Structure being passed to post-processing function changed (still undocumented feature)

Estimation of time left changed, post-processing function introduced.

Bug fixed.

File displayerrorstruct.m was missing.

Call to "clear functions" now in master and slaves, bug fixed.

In each multicore run, "clear functions" is now called once to ensure that changes to m-files take effect.

Two bugs fixed, one regarding the waitbar, one regarding the semaphore mechanism.

Using system-dependent file separators in paths again. Waitbar shows progress during parameter file generation now.

Added estimation of time left in waitbar.

Added an optional waitbar.

If a slave is killed during working on a job, the master will now generate the parameter file of that job again instead of working on the file himself. This will increase performance in certain situations.

File regexptokens.m added.
Dicussion group created:

Another change to the semaphore mechanism.

I have nearly re-written both master and slave in order to make the package even more robust and to reduce the overhead for inter-process communication.

Introduced parameter EVALSATONCE which causes the multicore package to do several function evaluations after each other before saving/loading and thus reducing the communication overhead. Demo function MULTICOREDEMO heavily commented.

Semaphore mechanism improved.

Forgot to include file chompsep.m

Semaphore stuff improved.

Subfunction datenum2 was not needed.

A subfunction that is only executed on certain systems was missing.