CPU Affinity Mask Calculator

Tools

CPU Affinity Mask Calculator

Select logical processors to build a CPU affinity bitmask, or type a mask to see which processors it includes.

Set this to the number of logical processors on the PC you are configuring.

Command
start /affinity 0x0 notepad.exe

Calculator source code on GitHub

How CPU Affinity Masks Work

An affinity mask is a number in which each bit stands for one logical processor: Bit 0 is CPU 0, bit 1 is CPU 1, and so on. A process runs only on the processors whose bits are set. Masks are usually written in hexadecimal; for example, 0x55500 selects CPUs 8, 10, 12, 14, 16 and 18.

The numbers are logical processors as Windows counts them, so on CPUs with Hyper-Threading or SMT, each core usually counts as two. On PCs with more than 64 logical processors, Windows divides them into processor groups of up to 64, and a mask applies within one group.

How to Set the CPU Affinity of a Windows Process Permanently

The best way to set a CPU affinity permanently on Windows is to use Process Lasso. The custom CPU affinity is applied each time the process runs.

Download Process Lasso
Process Lasso's Select CPU Affinity dialog, with CPU checkboxes, P-Cores, E-Cores, Invert and Clear buttons, and the affinity bitmask in hexadecimal
Process Lasso CPU affinity rules

Start a Program With a CPU Affinity Once

To start a program at a specific CPU affinity once, use the start command in cmd.exe. The calculator above builds this command for you.

start /affinity 0x0000000000055500 notepad.exe

When run from the Start Menu, include the command shell (cmd.exe), for example:

c:\windows\system32\cmd.exe /C start /affinity 0x0000000000055500 notepad.exe

Change It Until the Program Closes

To change the CPU affinity of a program that is already running, use Task Manager. The change lasts until the program closes.

  1. Open Task Manager and go to the Details tab.
  2. Right-click the process and choose Set affinity.
  3. Select the processors it may use, then click OK.

Measure the Difference

To see what an affinity change does under load, run the Thread Scaling preset in StressTest, give your browser a CPU affinity rule in Process Lasso, and run it again.

Bitsum Technologies

Independent Windows software since 2002. We build novel solutions to software performance and automation challenges.