1

I have a couple of programs that will be put on a system with limited core's. I want to test performance of these programs on my current system that is a lot more powerful than the one it will be on.

Is the only way to fully limit the proper resource is through a Virtual Machine on my system, or can I just restrict my system to meet the same core limit as the other system my programs will run on?

  • Do you actually have 16 cores or just 8 cores + hyperthreading? – daniel.heydebreck Sep 22 '17 at 14:50
  • 1
    You will most likely not want to use a virtual machine to simulate the performance of another machine. – Johannes Overmann Sep 23 '17 at 20:36
  • Another idea -- if the application is parallelized via OpenMP you might set the environment variable `OMP_NUM_THREADS=X` prior to starting the application. `X` is the number of OpenMP threads allowed to run (e.g. `OMP_NUM_THREADS=4` to allow 4 threads). Additionally, you might control the distribution of threads on cores via the env. var. `KMP_AFFINITY` (if compiled with Intel compilers). Other compiled suites should have corresponding env. vars. to set. Please let me know, if the application is OpenMP-parallelized and I will post another answer. – daniel.heydebreck Sep 24 '17 at 16:14

1 Answers1

2

taskset might help you.

Start your application your_command as follows:

taskset -ac 0-3 your_command
# -c 0-3: your_command might run on cores 0 to 3
#  a    : all of the 4 cores may be used

If the application is already running:

taskset -acp 0-3 PID
# PID = process ID

See this answer to 'Limit process to one cpu core' at Unix & Linux for further details .

daniel.heydebreck
  • 768
  • 14
  • 22