Have you tried using numactl
? It is very useful for memory and process binding here is a link to the man page.
For example
numactl --physcpubind=0 myapp args
Will bind he process myapp
to core 0.
Depending on what exactly you want to do there may be different syntax. For example specifying specific cores on a CPU or memory binding. The format of arguments for your application may also impact the numactl
syntax.
As for reducing the number of other processes there are several options, but the specifics are somewhat OS dependent. If you really want to test the system in an environment with minimal background noise you could design a custom OS image with only the minimal packages required to turn the node on and run the benchmarks. This approach is similar to the one employed in many modern HPC clusters. if you have multiple servers available using a cluster management tool like Warewulf might be useful, there are many reference designs and recipes available online for building a small cluster.
Other options include turning off any background and unnecessary programs and applications. You can also switch off unnecessary services and unload unused kernel modules.
Some power and performance setting in BIOS may also have an impact. Settings related to power consumption may impact things like frequency scaling and throttling, which can sometimes create unpredictable results during performance tests. Those factors generally impact workloads that produce large numbers of floating-point operations, but can be extended to any CPU intensive operation.
Understanding the constraints of the problem is very important when profiling code. Knowing if the code is CPU bound, memory bound or IO bound can make a big difference in the tools used to profile as well as the optimization techniques that can be used.