gcc compile flags to use all processors

Need help with C, C++, perl, python, etc?

gcc compile flags to use all processors

Postby techsavvy » 2019-10-25 02:16

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.
techsavvy
 
Posts: 19
Joined: 2019-07-06 20:02

Re: gcc compile flags to use all processors

Postby neuraleskimo » 2019-10-25 13:21

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
neuraleskimo
 
Posts: 113
Joined: 2019-03-12 23:26
Location: Bloomington, Indiana, USA

Re: gcc compile flags to use all processors

Postby stevepusser » 2019-10-25 17:49

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.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Clipgrab 3.8.6, Hedgewars 1.0.0, PulseEffects 4.6.8, Telegram-desktop 1.8.15, Pale Moon 28.7.2, KeepassXC 2.5.1
User avatar
stevepusser
 
Posts: 11254
Joined: 2009-10-06 05:53


Return to Programming

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable