How can I permanently set the processor affinity for an application on Multi-CPU machines on a Windows machine?

44 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 31 Mar 2010
Processor affinity is used when it is necessary to continue processing an application that is tied to a subset of the hardware, so that transitions from one processor to another are minimized. You can establish affinity on a server that is supporting multiple applications so that a processor is dedicated to each Application.
You can permanently set processor affinity for a non-operating system executable, on NT based operating systems (Windows NT, 2000 Family, XP Family, 2003 Family, Longhorn/Vista) by using the IMAGECFG.EXE tool from the \support\debug\i386 folder of a Windows NT 4.0 CD-ROM, or the IMAGECFG.EXE tool from the Windows 2000 Server Resource Kit Supplement One.
Copy imagecfg.exe to %systemroot%\system32
Doing so will make imagecfg a system command.
NOTE: This application will modify the exe and will write out a new header. You should backup the executable files you modify in case you need to set the application to use both cores again.
To permanently set the processor affinity for MATLAB.EXE, open a CMD prompt and type
move %MATLAB%\bin\win32\MATLAB.exe %MATLAB%\bin\win32\MATLAB_backup.exe
imagecfg -a 0xn %MATLAB%\bin\win32\MATLAB.exe
where 0xn is the affinity mask. The mask constrains your application to a specific CPU, from 0 - 31,
where:
CPU MASK
0 0x1
1 0x2
2 0x4
3 0x8
4 0x10
5 0x20
6 0x40
7 0x80
8 0x100
...

More Answers (0)

Categories

Find more on Multicore Processor Targets in Help Center and File Exchange

Products


Release

R2007a

Community Treasure Hunt

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

Start Hunting!