Bug 104283 - nvptx-none needs more user friendly architecture handling
Summary: nvptx-none needs more user friendly architecture handling
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: 12.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-29 20:34 UTC by Ye Luo
Modified: 2022-02-08 13:00 UTC (History)
2 users (show)

See Also:
Host:
Target: nvptx-none
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ye Luo 2022-01-29 20:34:41 UTC
x86_64-pc-linux-gnu-accel-nvptx-none-gcc needs both -misa and -mptx to select a specific target.

When I use OpenMP offload.
-foffload-options=nvptx-none="-misa=sm_80"
I got error
```
ptxas /tmp/ccW7wYQT.o, line 3; error   : PTX .version 3.1 does not support .target sm_80
ptxas /tmp/ccW7wYQT.o, line 2622; warning : Instruction 'shfl' without '.sync' may produce unpredictable results on sm_70 and later architectures
```

Then I have to get it through with
-foffload-options=nvptx-none="-misa=sm_80 -mptx=7.0"

I think GPU users know what sm_80 is but they rarely know PTX.
Can we -mptx default to highest -misa selection supports?

Or introduce something like -march=sm_80 and map it to appropriate -misa and -mptx.

Simplify the need of options is much appreciated.
Comment 1 GCC Commits 2022-02-08 12:57:14 UTC
The master branch has been updated by Tom de Vries <vries@gcc.gnu.org>:

https://gcc.gnu.org/g:decde11183bdccc46587d6614b75f3d56a2f2e4a

commit r12-7098-gdecde11183bdccc46587d6614b75f3d56a2f2e4a
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Feb 4 08:53:52 2022 +0100

    [nvptx] Choose -mptx default based on -misa
    
    While testing with driver version 390.147 I ran into the problem that it
    doesn't support ptx isa version 6.3 (the new default), only 6.1.
    
    Furthermore, using the -mptx option is a bit user-unfriendly.
    
    Say we want to compile for sm_80.  We can use -misa=sm_80 to specify that, but
    then run into errors because the default ptx version is 6.3, which doesn't
    support sm_80 yet.
    
    Address both these issues by:
    - picking a default -mptx based on the active -misa, and
    - ensuring that the default -mptx is at least 6.0 (instead
      of 6.3).
    
    Also add an error in case of incompatible options like
    "-misa=sm_80 -mptx=6.3":
    ...
    cc1: error: PTX version (-mptx) needs to be at least 7.0 to support \
      selected -misa (sm_80)
    ...
    
    Tested on x86_64-linux with nvptx accelerator.
    
    gcc/ChangeLog:
    
    2022-02-08  Tom de Vries  <tdevries@suse.de>
    
            PR target/104283
            * config/nvptx/nvptx-opts.h (enum ptx_version): Add PTX_VERSION_3_0
            and PTX_VERSION_4_2.
            * config/nvptx/nvptx.cc (first_ptx_version_supporting_sm)
            (default_ptx_version_option, ptx_version_to_string)
            (sm_version_to_string, handle_ptx_version_option): New function.
            (nvptx_option_override): Call handle_ptx_version_option.
            (nvptx_file_start): Use ptx_version_to_string and sm_version_to_string.
            * config/nvptx/nvptx.md (define_insn "nvptx_shuffle<mode>")
            (define_insn "nvptx_vote_ballot"): Use TARGET_PTX_6_0.
            * config/nvptx/nvptx.opt (mptx): Remove 'Init'.
Comment 2 Tom de Vries 2022-02-08 13:00:13 UTC
Fixed by commit "[nvptx] Choose -mptx default based on -misa".