Configurable affinity changer for Windows
Posted: Fri Sep 12, 2008 7:05 am
I imagine most of you have heard of the other affinity changer program and its PPD benefits when used with the supported folding clients/numbers of cores. And I think there are also many who would like a more flexible affinity changer that works with other non-standard configurations.
I was one of these people when I bought my Intel Quad core about half a year ago. I wanted to run a Linux SMP client in a VMWare virtual machine on two of the cores, and a Windows SMP client on the other two cores. At that time I decided to write my own affinity changer which would deal with my particular setup. I also wanted the program to automatically detect the two pairs of cores that share an L2 cache on the Intel quad, and schedule each client on one of the pairs of cores. This task took only one week-end at that time, and I used this code for the last 6 months without any problems. However, my affinity changer was hard coded for my particular setup.
Three weeks ago when I decided to give a try to the new GPU client, I realized that I needed a more flexible affinity changer program. In the last 2-3 weeks I transformed my affinity changer in a configurable program that can be used to manage affinities for arbitrary applications and arbitrary number of cores, with the goal to also make a public release.
The philosophy behind this new affinity changer was to be as flexible as possible (unfortunately that are still things that you cannot do), at the expense of requiring some cooperation from the user who must specify which applications should be managed by the affinity changer, how many CPUs to assign to each application, and optionally what policy to use for assigning processes to CPUs.
In addition, the code uses an heuristic to detect eventual asymmetries in the CPU configuration, in other words if certain CPUs have a higher affinity for each other. This heuristic detects the cores that share an L2 cache on an Intel Quad with very high confidence, creating logical CPU IDs to identify them, i.e. PAIR0 and PAIR1 for an Intel quad.
These logical CPU IDs can then be used in the affinity profiles that the user writes in a configuration file. These application profiles are very concise and easy to write once you understand the syntax. For example, to specify that a VMWare virtual machine should run on two cores that share an L2 cache, you write a profile as the one below:
*\vmware-vmx.exe := PAIR1
Without going into further detail now, I point you to the first public release of this program, which is distributed under the GNU public license.
The program can be downloaded from: http://sourceforge.net/project/platform ... _id=238550
Some lengthy documentation which hopefully will give you an idea of how the program works, is included with the program, but can also be viewed online at: http://affinitychanger.sourceforge.net/. The documentation includes also 6 simple configuration files to give you a better idea of how things are glued together.
Finally, you might have noticed that in all my examples I referred to Intel Quads. The reason for this is that I own such a CPU and it was the only architecture that I could test the program on.
However, the program aims to be general and it works with any architecture and number of cores, at least with physical CPU IDs (see the link above for an explanation). The only thing of which I am uncertain at this time is if the heuristic that detects asymmetric CPU configurations works well with AMD quad cores, or with dual socket systems. Some discussion about this topic can be found here: http://affinitychanger.sourceforge.net/#section_3
So I would like to hear any reports from people with more "exotic" configurations, where by exotic I mean a system with more than 4 cores, or a 4 core system that is not an Intel quad.
Of course, I am interested in positive or negative reports from other people as well. This is the first release, and some things might not work as expected in the wild.
I was one of these people when I bought my Intel Quad core about half a year ago. I wanted to run a Linux SMP client in a VMWare virtual machine on two of the cores, and a Windows SMP client on the other two cores. At that time I decided to write my own affinity changer which would deal with my particular setup. I also wanted the program to automatically detect the two pairs of cores that share an L2 cache on the Intel quad, and schedule each client on one of the pairs of cores. This task took only one week-end at that time, and I used this code for the last 6 months without any problems. However, my affinity changer was hard coded for my particular setup.
Three weeks ago when I decided to give a try to the new GPU client, I realized that I needed a more flexible affinity changer program. In the last 2-3 weeks I transformed my affinity changer in a configurable program that can be used to manage affinities for arbitrary applications and arbitrary number of cores, with the goal to also make a public release.
The philosophy behind this new affinity changer was to be as flexible as possible (unfortunately that are still things that you cannot do), at the expense of requiring some cooperation from the user who must specify which applications should be managed by the affinity changer, how many CPUs to assign to each application, and optionally what policy to use for assigning processes to CPUs.
In addition, the code uses an heuristic to detect eventual asymmetries in the CPU configuration, in other words if certain CPUs have a higher affinity for each other. This heuristic detects the cores that share an L2 cache on an Intel Quad with very high confidence, creating logical CPU IDs to identify them, i.e. PAIR0 and PAIR1 for an Intel quad.
These logical CPU IDs can then be used in the affinity profiles that the user writes in a configuration file. These application profiles are very concise and easy to write once you understand the syntax. For example, to specify that a VMWare virtual machine should run on two cores that share an L2 cache, you write a profile as the one below:
*\vmware-vmx.exe := PAIR1
Without going into further detail now, I point you to the first public release of this program, which is distributed under the GNU public license.
The program can be downloaded from: http://sourceforge.net/project/platform ... _id=238550
Some lengthy documentation which hopefully will give you an idea of how the program works, is included with the program, but can also be viewed online at: http://affinitychanger.sourceforge.net/. The documentation includes also 6 simple configuration files to give you a better idea of how things are glued together.
Finally, you might have noticed that in all my examples I referred to Intel Quads. The reason for this is that I own such a CPU and it was the only architecture that I could test the program on.
However, the program aims to be general and it works with any architecture and number of cores, at least with physical CPU IDs (see the link above for an explanation). The only thing of which I am uncertain at this time is if the heuristic that detects asymmetric CPU configurations works well with AMD quad cores, or with dual socket systems. Some discussion about this topic can be found here: http://affinitychanger.sourceforge.net/#section_3
So I would like to hear any reports from people with more "exotic" configurations, where by exotic I mean a system with more than 4 cores, or a 4 core system that is not an Intel quad.
Of course, I am interested in positive or negative reports from other people as well. This is the first release, and some things might not work as expected in the wild.