Results 1 to 4 of 4

Thread: GCC -march=native -mtune=native

  1. #1
    Join Date
    Sep 2007
    Location
    /dev/null/
    Beans
    1,589

    GCC -march=native -mtune=native

    Gday,

    So when I use native for march and mtune, will the compiler automatically use sse, sse2, mmx and so on if my processor supports it?

    Am I required to specify both march and mtune together?

    I'm doing some experiments with the command:

    gcc -march=native -mtune=native -O3 -Wall -pipe -o hello hello.c
    He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.

  2. #2
    Join Date
    May 2008
    Location
    Canada
    Beans
    75
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: GCC -march=native -mtune=native

    Regarding sse, I've read accounts going both ways.

    However, if you run gcc with the '-S' flag, it will spew out the assembler code in a '.s' file. This file begins with a header which lists the options gcc used. Thus, you can see if it picks up the sse options as you wished. (Running v4.3.2, mine appears to have detected sse without me explicitly specifying it.)

    Regarding '-march' and '-mtune', I've tried compiling with different combinations of '-mtune' and '-march', and it appears that '-march' over-rules '-mtune' (i.e., compiling with both or just '-march' resulted in the same assembler file, but running with just mtune resulted in some differences.)
    Last edited by cyfur01; February 28th, 2009 at 10:30 AM.

  3. #3
    Join Date
    Sep 2007
    Location
    /dev/null/
    Beans
    1,589

    Re: GCC -march=native -mtune=native

    Great, thanks
    He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.

  4. #4
    Join Date
    Sep 2007
    Location
    Hungary
    Beans
    33

    Re: GCC -march=native -mtune=native

    Hi, I know it's probably a bit late, but at least I can help out others who stumble into this thread.

    You can see the actual flags gcc use, by using the -Q -v options.
    Code:
    gcc -march=native -Q -v source.c
    Actually, when you use -march=native, GCC usually sets -mtune to the appropriate value (at least on my machine it works that way). So, there is no reason to set -mtune if you already set -march.

    Source/Further reading:
    Gentoo has a good read about gcc optimizations.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •