Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

gcc compile flags to use all processors

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
techsavvy
Posts: 55
Joined: 2019-07-06 20:02

gcc compile flags to use all processors

#1 Post by techsavvy »

Greetings, running a compiled "motion 4.2.2" on an Odroid XU4 dual-quadcore yields the following "top" output:

Code: Select all

Tasks: 128 total,   1 running, 127 sleeping,   0 stopped,   0 zombie
%Cpu0  :100.0 us,  0.0 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu4  : 88.9 us, 11.1 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu5  : 56.2 us,  0.0 sy,  0.0 ni, 43.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu6  : 64.7 us,  0.0 sy,  0.0 ni, 35.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu7  :  0.0 us,  6.2 sy,  0.0 ni, 93.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :   1996.9 total,   1111.6 free,    343.6 used,    541.7 buff/cache
MiB Swap:    998.4 total,    998.4 free,      0.0 used.   1590.6 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
  988 techs     20   0  489868 265712   6916 S 306.2  13.0 165:21.87 motion
 2996 root      20   0    4660   2032   1676 R   6.2   0.1   0:00.03 top
    1 root      20   0   31036   6736   5216 S   0.0   0.3   0:04.70 systemd
...
What gcc flags do I need in order to utilize the "%Cpu[1-3,7]", please?
Last edited by techsavvy on 2019-10-26 21:38, edited 1 time in total.

neuraleskimo
Posts: 195
Joined: 2019-03-12 23:26

Re: gcc compile flags to use all processors

#2 Post by neuraleskimo »

If I understand you correctly, it is really a question of your build tools. For make, you want to use ''-j":

Code: Select all

make -j ...
or

Code: Select all

make -j 4 ...
Edit: The first option will use all cores. The second will use four cores. For example, you have six core but want to leave two for other work while building.

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: gcc compile flags to use all processors

#3 Post by stevepusser »

I gather that the motion program is already compiled and you want the running binary to automatically use all cores, like x264 does for video transcoding, not the much simpler process of getting the motion build to use all cores.

In that case, it's much much more complicated. The motion source code will need to be rejiggered to detect all available cores and split its processing into multiple threads.
MX Linux packager and developer

Post Reply