How many cores is my program using?

The following description shows a way of finding out how many cores a particular program or command is using.

In this example I am using the screen command to manage multiple screens. The program runs in one screen and commands in the second.

First start your program:

Now create a new screen and list the processes you are running using the command:

ps -u <userid> -L -o pid,tid,psr,pcpu,comm

 

In this example the program I am interested in is "ox.bin". There are eight instances of this program. The PSR column lists the number of the core the process is running on. Sso in this case "ox.bin" is running on eight separate cores, as all the numbers are unique. The %CPU column gives an indication of how much CPU time of that core your program is using. If the figure is below say 85% your either have a very poorly written program, or the computer is heavily loaded, and you are sharing that core with other users. In this case the oxl.bin process running on core 57 is idle and probably waiting for the other processes to complete.