Hi Tom!
On 2022-03-29T14:03:22+0200, Tom de Vries via Gcc-patches
wrote:
> Say we have an sm_50 board, and we want to run a benchmark using the highest
> possible march setting.
>
> Currently there's march=sm_30, march=sm_35, march=sm_53, but no march=sm_50.
>
> So, we'd need to pick march=sm_35.
>
> Likewise, for a test script that handles multiple boards, we'd need a mapping
> from native board sm_xx to march, which might have to be updated with newer
> gcc releases.
ACK.
> Add an option march-map, such that we can just specify march-map=sm_50, and
> let the compiler map this to the appropriate march.
So, I understand that the idea is, that users should use
'-march-map=[...]' instead of '-misa=[...]' or alias '-march=[...]',
because the former ('-march-map=[...]') will always Do The Right Thing:
pick the best available SM level for GCC/nvptx code generation (like
you've said: may change with GCC releases, and users then don't have to
change their receipes), and it'll never error out, in contrast to
'-misa=[...]' or alias '-march=[...]' do when the requested architecture
isn't directly supported:
xgcc: error: unrecognized argument in option ‘-misa=sm_50’
xgcc: note: valid arguments to ‘-misa=’ are: sm_30 sm_35 sm_53 sm_70 sm_75
sm_80; did you mean ‘sm_30’?
My question, though, is: why did you add a new option name '-march-map'
instead of directly using '-march' for that (instead of "[nvptx] Add
march alias for misa", added on the same day)? Would you accept a patch
that: (a) un-aliases '-march' -> '-misa', and (b) renames '-march-map' to
'-march', and (c) sets up a '-march-map' -> '-march' alias for backwards
compatibility (if so desired)? Regarding (a), (b), in my opinion,
there's no backwards compatibility issue there: the "new '-march'" will
simply accept more options than the "old '-march'" did. Regarding (c),
I'd even drop the user-visible '-march-map' option completely; I suppose
nobody's really used that by now?
Grüße
Thomas
> The option is implemented as a list of aliases, such that we have a somewhat
> lengthy (17 lines in total):
> ...
> $ gcc --help=target
> ...
> -march-map=sm_30Same as -misa=sm_30.
> -march-map=sm_32Same as -misa=sm_30.
> ...
> -march-map=sm_87Same as -misa=sm_80.
> -march-map=sm_90Same as -misa=sm_80.
> ...
>
> This implementation was chosen in the hope that it'll be easier if
> we end up with some misa multilib.
>
> It would be nice to have the mapping list generated from an updated
> nvptx-sm.def, but for now it's spelled out in nvptx.opt.
>
> Tested on nvptx.
>
> Committed to trunk.
>
> Thanks,
> - Tom
>
> [nvptx] Add march-map
>
> gcc/ChangeLog:
>
> 2022-03-29 Tom de Vries
>
> PR target/104714
> * config/nvptx/nvptx.opt (march-map=*): Add aliases.
>
> gcc/testsuite/ChangeLog:
>
> 2022-03-29 Tom de Vries
>
> PR target/104714
> * gcc.target/nvptx/march-map.c: New test.
>
> ---
> gcc/config/nvptx/nvptx.opt | 51
> ++
> gcc/testsuite/gcc.target/nvptx/march-map.c | 5 +++
> 2 files changed, 56 insertions(+)
>
> diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt
> index b5d0170e9e9..58eddeeabf4 100644
> --- a/gcc/config/nvptx/nvptx.opt
> +++ b/gcc/config/nvptx/nvptx.opt
> @@ -60,6 +60,57 @@ march=
> Target RejectNegative Joined Alias(misa=)
> Alias:
>
> +march-map=sm_30
> +Target RejectNegative Alias(misa=,sm_30)
> +
> +march-map=sm_32
> +Target RejectNegative Alias(misa=,sm_30)
> +
> +march-map=sm_35
> +Target RejectNegative Alias(misa=,sm_35)
> +
> +march-map=sm_37
> +Target RejectNegative Alias(misa=,sm_35)
> +
> +march-map=sm_50
> +Target RejectNegative Alias(misa=,sm_35)
> +
> +march-map=sm_52
> +Target RejectNegative Alias(misa=,sm_35)
> +
> +march-map=sm_53
> +Target RejectNegative Alias(misa=,sm_53)
> +
> +march-map=sm_60
> +Target RejectNegative Alias(misa=,sm_53)
> +
> +march-map=sm_61
> +Target RejectNegative Alias(misa=,sm_53)
> +
> +march-map=sm_62
> +Target RejectNegative Alias(misa=,sm_53)
> +
> +march-map=sm_70
> +Target RejectNegative Alias(misa=,sm_70)
> +
> +march-map=sm_72
> +Target RejectNegative Alias(misa=,sm_70)
> +
> +march-map=sm_75
> +Target RejectNegative Alias(misa=,sm_75)
> +
> +march-map=sm_80
> +Target RejectNegative Alias(misa=,sm_80)
> +
> +march-map=sm_86
> +Target RejectNegative Alias(misa=,sm_80)
> +
> +march-map=sm_87
> +Target RejectNegative Alias(misa=,sm_80)
> +
> +march-map=sm_90
> +Target RejectNegative Alias(misa=,sm_80)
> +
> Enum
> Name(ptx_version) Type(int)
> Known PTX ISA versions (for use with the -mptx= option):
> diff --git a/gcc/testsuite/gcc.target/nvptx/march-map.c
> b/gcc/testsuite/gcc.target/nvptx/march-map.c
> new file mode 100644
> index 000..00838e55fc0
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/nvptx/march-map.c
> @@ -0,0 +1,5 @@
> +/* { dg-options "-march-map=sm_50" } */
> +
> +#include "main.c"
> +
> +/* { dg-final { s