How do I set processor affinity for MATLAB 7.7 (R2008b) in Linux?

7 views (last 30 days)
The "Profiling for Improving Performance" section of the MATLAB documentation states the following:
"If your system uses Intel multicore chips, and you plan to profile using CPU time, set the number of active CPUs to one before you start profiling. This results in the most accurate and efficient profiling."
It goes on to explain how to set Processor Affinity in Windows, but I can not find a similar explanation for Linux.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 19 May 2010
This change has been incorporated into the documentation in Release 2010a (R2010a). For previous releases, read below for any additional information:
Setting processor affinity for a certain process is a task of the operating system. As such, any Linux scheduling utility that is able to deal with this can be used to set processor affinity for MATLAB.
For example, you can use the 'taskset' command in Linux to set the processor affinity to only one CPU, as required by the profiler. For 'taskset' to be used, you will need the PID (process ID) of the currently running MATLAB instance. To get this PID, execute the following command from a Linux terminal:
ps -C MATLAB
The number at the start of the output is MATLAB's PID. Then, you can call taskset to set the processor affinity for the MATLAB process to one CPU (e.g. CPU #0):
taskset -pc 0 16351
The '-p' option specifies that taskset should operate on an existing PID instead of creating a new task. The '-c' option allows you to specify a list of processor numbers instead of a bitmask representing the processors you would like to use. For more information on the syntax of taskset, it is best to look at the manpage for this command (i.e. by executing 'man taskset' from a Linux terminal).

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2008b

Community Treasure Hunt

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

Start Hunting!