LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Gentoo
User Name
Password
Gentoo This forum is for the discussion of Gentoo Linux.

Notices


Reply
  Search this Thread
Old 05-05-2019, 01:43 PM   #1
drillsar
Member
 
Registered: Jan 2017
Posts: 144

Rep: Reputation: Disabled
GCC Optimization and make.conf?


I determined my cpu is ivybridge with 4 cores with one thread

in /mnt/gentoo/etc/portage/make.conf

Code:
CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=ivybridge -O2 -pipe"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j4"
is this correct?
 
Old 05-16-2019, 08:39 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,552

Rep: Reputation: 103Reputation: 103
AFAIK whether that works will depend on the GCC version you have installed.

E. g. I checked my GCC on Centos 7 and it is version

Quote:
# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
and according to its local man page, it does NOT support an architecture string "ivybridge" in the

-march

commandline parameter.

(E. g. you probably need a newer GCC than 4.8.5 20150623 - and if you have one, check in its man pages if supports "ivybridge" as a target machine architecture.)

From the 4.8.5 GCC manpage on my Centos 7 box:

Code:
Intel 386 and AMD x86-64 Options
       These -m options are defined for the i386 and x86-64 family of computers:

       -march=cpu-type
           Generate instructions for the machine type cpu-type.  In contrast to -mtune=cpu-type, which merely tunes the generated code
           for the specified cpu-type, -march=cpu-type allows GCC to generate code that may not run at all on processors other than the
           one indicated.  Specifying -march=cpu-type implies -mtune=cpu-type.

           The choices for cpu-type are:

           native
               This selects the CPU to generate code for at compilation time by determining the processor type of the compiling machine.
               Using -march=native enables all instruction subsets supported by the local machine (hence the result might not run on
               different machines).  Using -mtune=native produces code optimized for the local machine under the constraints of the
               selected instruction set.

           i386
               Original Intel i386 CPU.

           i486
               Intel i486 CPU.  (No scheduling is implemented for this chip.)

           i586
           pentium
               Intel Pentium CPU with no MMX support.

           pentium-mmx
               Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.

           pentiumpro
               Intel Pentium Pro CPU.

           i686
               When used with -march, the Pentium Pro instruction set is used, so the code runs on all i686 family chips.  When used with
               -mtune, it has the same meaning as generic.

           pentium2
               Intel Pentium II CPU, based on Pentium Pro core with MMX instruction set support.

           pentium3
           pentium3m
               Intel Pentium III CPU, based on Pentium Pro core with MMX and SSE instruction set support.
           pentium-m
               Intel Pentium M; low-power version of Intel Pentium III CPU with MMX, SSE and SSE2 instruction set support.  Used by
               Centrino notebooks.

           pentium4
           pentium4m
               Intel Pentium 4 CPU with MMX, SSE and SSE2 instruction set support.

           prescott
               Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2 and SSE3 instruction set support.

           nocona
               Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE, SSE2 and SSE3 instruction set support.

           core2
               Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3 and SSSE3 instruction set support.

           corei7
               Intel Core i7 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1 and SSE4.2 instruction set support.

           corei7-avx
               Intel Core i7 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AES and PCLMUL instruction set
               support.

           core-avx-i
               Intel Core CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AES, PCLMUL, FSGSBASE, RDRND and
               F16C instruction set support.

           core-avx2
               Intel Core CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2, AES, PCLMUL,
               FSGSBASE, RDRND, FMA, BMI, BMI2 and F16C instruction set support.

           atom
               Intel Atom CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3 instruction set support.

           k6  AMD K6 CPU with MMX instruction set support.

           k6-2
           k6-3
               Improved versions of AMD K6 CPU with MMX and 3DNow! instruction set support.

           athlon
           athlon-tbird
           AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow! and SSE prefetch instructions support.

           athlon-4
           athlon-xp
           athlon-mp
               Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow! and full SSE instruction set support.

           k8
           opteron
           athlon64
           athlon-fx
               Processors based on the AMD K8 core with x86-64 instruction set support, including the AMD Opteron, Athlon 64, and Athlon
               64 FX processors.  (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow! and 64-bit instruction set extensions.)

           k8-sse3
           opteron-sse3
           athlon64-sse3
               Improved versions of AMD K8 cores with SSE3 instruction set support.

           amdfam10
           barcelona
               CPUs based on AMD Family 10h cores with x86-64 instruction set support.  (This supersets MMX, SSE, SSE2, SSE3, SSE4A,
               3DNow!, enhanced 3DNow!, ABM and 64-bit instruction set extensions.)

           bdver1
               CPUs based on AMD Family 15h cores with x86-64 instruction set support.  (This supersets FMA4, AVX, XOP, LWP, AES,
               PCL_MUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)

           bdver2
               AMD Family 15h core based CPUs with x86-64 instruction set support.  (This supersets BMI, TBM, F16C, FMA, AVX, XOP, LWP,
               AES, PCL_MUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)

           bdver3
               AMD Family 15h core based CPUs with x86-64 instruction set support.  (This supersets BMI, TBM, F16C, FMA, AVX, XOP, LWP,
               AES, PCL_MUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.

           btver1
               CPUs based on AMD Family 14h cores with x86-64 instruction set support.  (This supersets MMX, SSE, SSE2, SSE3, SSSE3,
               SSE4A, CX16, ABM and 64-bit instruction set extensions.)

           btver2
               CPUs based on AMD Family 16h cores with x86-64 instruction set support. This includes MOVBE, F16C, BMI, AVX, PCL_MUL, AES,
               SSE4.2, SSE4.1, CX16, ABM, SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.

           winchip-c6
               IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction set support.

           winchip2
               IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!  instruction set support.

           c3  VIA C3 CPU with MMX and 3DNow! instruction set support.  (No scheduling is implemented for this chip.)

           c3-2
               VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.  (No scheduling is implemented for this chip.)

           geode
               AMD Geode embedded processor with MMX and 3DNow! instruction set support.
E. g. no "ivybridge".

Regards

Stefan

Last edited by rylan76; 05-16-2019 at 08:46 AM.
 
Old 05-16-2019, 08:52 AM   #3
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
When I ran Gentoo, I don't ever remember specifically naming a CPU in my make.conf, plus I thought the "-j" flag was number of cores +1. Is that not the case any more?
 
Old 05-17-2019, 06:37 AM   #4
drillsar
Member
 
Registered: Jan 2017
Posts: 144

Original Poster
Rep: Reputation: Disabled
I went here and as you can see they have -march=ivybridge

https://wiki.gentoo.org/wiki/Safe_CFLAGS#Ivy_Bridge
 
Old 05-17-2019, 12:06 PM   #5
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
Are you using distcc? If not, the recommended way to set up make.conf is "A recommended default choice for CFLAGS or CXXFLAGS is to use -march=native. This enables auto-detection of the CPU's architecture."

Code:
CFLAGS="-O2 -pipe -march=native"
CXXFLAGS="${CFLAGS}"
If you ARE using distcc, there is documentation on how to set up these flags in make.conf.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] GCC and -march=native optimization towheedm Programming 14 12-15-2017 08:30 AM
Applying optimization recursively by compiling again using optimization flags $u$hil_k$ Linux - General 1 11-18-2013 12:19 PM
Trouble compiling gcc and glibc with piledriver cpu optimization (march=bdver2) Holering Slackware 3 01-25-2013 10:25 AM
Looking for kernel config and gcc optimization CFLAGS for Intel Atom N270 sparky.summer Linux - Kernel 3 11-23-2009 12:30 PM
How to get GCC and Make without having GCC or Make??? ayteebee Linux - General 2 01-22-2006 05:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Gentoo

All times are GMT -5. The time now is 05:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration