I am trying to run a highly multi-threaded application and want to measure its performance with different cores ( 0,1,2,3,4,5,6 ... 12). I saw taskset when googled,
taskset 0x00000003 ./my_app
but when I see system monitor of the fedora, It only shows one core doing 100% and others only 12%, 0%,...etc. Is there any way to tell the process to run on certain core. I also heard of an option like -t #no of cores . like
./my_app -t2
for 0 and 1 core .. but this also have no effect what am I doing wrong can any one please lead me to right direction.
taskset 0x00000003 ./my_app
sets the affinity of the my_app process to cores 1 and 2. If your application is multithreaded, the threads inherit the affinity, but their distribution between core 1 and 2 is not set.
To set the affinity of each thread within your process, you can either use taskset after the process is running (i.e. run myapp, examine the thread ids and call taskset -pc <core> <tid>
for each) or set the affinity at thread creation with sched_setaffinity
, pthread_setaffinity_np
if you are using pthreads etc).
Whatever ./myapp -t2
does is specific to you application.