When to use '-mcpu' versus '-march'

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

When to use '-mcpu' versus '-march'

Manuel Klimek via cfe-dev

Hi CFE Devs,

 

For out-of-tree target developers, what is the best practice advice for when to use ‘-mcpu’ and when to use ‘-march’ to identify variants or various generations of a target?

 

Thanks,

 

            MartinO

 

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: When to use '-mcpu' versus '-march'

Manuel Klimek via cfe-dev
I guess Clang command line options tend to be compatible with GCC.
What GCC says about those options?

2018-03-14 22:48 GMT+08:00 ORiordan, Martin via cfe-dev
<[hidden email]>:

> Hi CFE Devs,
>
>
>
> For out-of-tree target developers, what is the best practice advice for when
> to use ‘-mcpu’ and when to use ‘-march’ to identify variants or various
> generations of a target?
>
>
>
> Thanks,
>
>
>
>             MartinO
>
>
>
> --------------------------------------------------------------
> Intel Research and Development Ireland Limited
> Registered in Ireland
> Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
> Registered Number: 308263
>
> This e-mail and any attachments may contain confidential material for the
> sole use of the intended recipient(s). Any review or distribution by others
> is strictly prohibited. If you are not the intended recipient, please
> contact the sender and delete all copies.
>
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>



--
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: When to use '-mcpu' versus '-march'

Manuel Klimek via cfe-dev
In reply to this post by Manuel Klimek via cfe-dev
Hi Martin,

Sorry about the delay here, but I've got some advice even though a lot of things aren't solid anywhere.

a) Does this match an out of tree target for gcc? If so, I'd match that.
b) Typically -march/-mtune (though the latter isn't supported in llvm at the moment, see an earlier post from me to llvm-dev on how to support that) are what I'd use for new ports. We used it in a number of new/out of tree ports in gcc as well.
c) -mcpu is occastionally used for "-march+-mtune" when -march by itself is generally "this architecture, but generic tuning".

Hope this helps and happy to elaborate if you need it anywhere.

-eric

On Wed, Mar 14, 2018 at 7:48 AM ORiordan, Martin via cfe-dev <[hidden email]> wrote:

Hi CFE Devs,

 

For out-of-tree target developers, what is the best practice advice for when to use ‘-mcpu’ and when to use ‘-march’ to identify variants or various generations of a target?

 

Thanks,

 

            MartinO

 

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: When to use '-mcpu' versus '-march'

Manuel Klimek via cfe-dev
Does clang differ from g++ in this respect?

This is from the man page for g++ 4.8.5 for Intel x86 and x86-64 processors:

        -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.
...
        -mtune=cpu-type
            Tune to cpu-type everything applicable about the generated code, except for the ABI and the set of available instructions.
            While picking a specific cpu-type schedules things appropriately for that particular chip, the compiler does not generate any
            code that cannot run on the default machine type unless you use a -march=cpu-type option.  ...
...
        -mcpu=cpu-type
            A deprecated synonym for -mtune.



On 03/20/2018 12:40 AM, Eric Christopher via cfe-dev wrote:
> Hi Martin,
>
> Sorry about the delay here, but I've got some advice even though a lot of things aren't solid anywhere.
>
> a) Does this match an out of tree target for gcc? If so, I'd match that.
> b) Typically -march/-mtune (though the latter isn't supported in llvm at the moment, see an earlier post from me to llvm-dev on how to support that) are what I'd use for new ports. We used it in a number of new/out of tree ports in gcc as well.
> c) -mcpu is occastionally used for "-march+-mtune" when -march by itself is generally "this architecture, but generic tuning".
>

--

Dick Hadsell 203-992-6320  Fax: 203-992-6001
Reply-to: [hidden email]
Blue Sky Studioshttp://www.blueskystudios.com
1 American Lane, Greenwich, CT 06831-2560

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: When to use '-mcpu' versus '-march'

Manuel Klimek via cfe-dev
Hi Richard,

On Tue, Mar 20, 2018 at 9:33 AM Richard Hadsell <[hidden email]> wrote:
Does clang differ from g++ in this respect?


It shouldn't, we strive for compatibility here.
 
This is from the man page for g++ 4.8.5 for Intel x86 and x86-64 processors:


This is because this is for the in-tree x86 target. ARM is different. Mips is more like what I said. mn10300 is more like what I said. Power is different again, and in a different way.

However, Martin was asking about a non-specific out of tree target and the advice there should still hold.

-eric
 
        -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.
...
        -mtune=cpu-type
            Tune to cpu-type everything applicable about the generated code, except for the ABI and the set of available instructions.
            While picking a specific cpu-type schedules things appropriately for that particular chip, the compiler does not generate any
            code that cannot run on the default machine type unless you use a -march=cpu-type option.  ...
...
        -mcpu=cpu-type
            A deprecated synonym for -mtune.



On 03/20/2018 12:40 AM, Eric Christopher via cfe-dev wrote:
> Hi Martin,
>
> Sorry about the delay here, but I've got some advice even though a lot of things aren't solid anywhere.
>
> a) Does this match an out of tree target for gcc? If so, I'd match that.
> b) Typically -march/-mtune (though the latter isn't supported in llvm at the moment, see an earlier post from me to llvm-dev on how to support that) are what I'd use for new ports. We used it in a number of new/out of tree ports in gcc as well.
> c) -mcpu is occastionally used for "-march+-mtune" when -march by itself is generally "this architecture, but generic tuning".
>

--

Dick Hadsell                    <a href="tel:(203)%20992-6320" value="+12039926320" target="_blank">203-992-6320  Fax: <a href="tel:(203)%20992-6001" value="+12039926001" target="_blank">203-992-6001
Reply-to:                       [hidden email]
Blue Sky Studioshttp://www.blueskystudios.com
1 American Lane, Greenwich, CT 06831-2560


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev