9

I have an executable foo.exe that I need to run concurrently 6 times on a multiprocessor setup where the first 3 instances will be assigned to cores in Group 0 and the next 3 instances will be assigned to the cores in Group 1.

I have 6 shortcuts for the foo.exe program on my desktop. Each shortcut gives the foo.exe program a different set of parameters to run with.

I simply click on the shortcuts to run the 6 instances of the foo.exe programs. They all start up, however I then have to go into the task manager and make sure 3 are assigned to CPU's in group 0 and 3 are assigned to the CPU's group 1, by setting their group affinity.

Is there a way I can modify the shortcuts I have on my desktop to make sure 3 of the foo.exe programs use Group 0 and 3 of them use Group 1?

Burgi
  • 6,768
Zareh
  • 193

2 Answers2

12

You can use the /affinity flag using the start command to specify the cores a process should use.

Usage

start /affinity n foo.exe -arguments

So, your shortcut would look like:

c:\windows\system32\cmd.exe /C start /affinity n foo.exe -arguments where n is CPU core number +1.

So to run on Core 0 it'd be:

c:\windows\system32\cmd.exe /C start /affinity 1 foo.exe -arguments.

Source

Specifying multiple cores

Assume a CPU has 4 cores. To specify the cores to use:

  1. Visualize the cores as an array with the length of the array equal to the number of cores. The cores will be arranged in descending order from right to left:

    [CPU3, CPU2, CPU1, CPU0]

  2. Now, replace cores you would like your process to use with 1 and those you won't with 0. Assuming I want my process to use core 3 & 1, my array would like this:

    [0,1,0,1]

  3. "Pop" the elements of the array to a string. Now it would be represented as 0101.

  4. Assume the string is in binary and convert it to hexadecimal. Now it would be 0x5

  5. Now use the same command start /affinity n foo.exe -arguments but now n will be 0x5, giving start /affinity 0x5 foo.exe -arguments

Source

Notes:

  • The source explains the visualization as a binary string, not an array( check it out). I find this a bit confusing so I explained using an array.
  • The source does not specify that you must prefix 0x to show it's hexadecimal in the command. Reading start /? specifies it is to be hex.
Bass
  • 693
MrFregg
  • 398
0

I don't know if processor group assignment is possible on the command line, but you can set the required NUMA node number using start /node <node_number> /affinity <affinity_value>. Windows promise you that that the entire node will be contained in a single processor group. If the Node processor count is higher than 64 processor than windows will divide it into multiple virtual nodes. So if you using node you basically set the process to run on the node's processor group...