public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom de Vries <vries@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7422] [nvptx] Add nvptx-sm.def Date: Tue, 1 Mar 2022 07:59:51 +0000 (GMT) [thread overview] Message-ID: <20220301075951.577283858430@sourceware.org> (raw) https://gcc.gnu.org/g:7efe46935c5fce8db13e00aa6f4b0f1599b330e4 commit r12-7422-g7efe46935c5fce8db13e00aa6f4b0f1599b330e4 Author: Tom de Vries <tdevries@suse.de> Date: Fri Feb 25 11:47:12 2022 +0100 [nvptx] Add nvptx-sm.def Add a file gcc/config/nvptx/nvptx-sm.def that lists all sm_xx versions used in the port, like so: ... NVPTX_SM(30, NVPTX_SM_SEP) NVPTX_SM(35, NVPTX_SM_SEP) NVPTX_SM(53, NVPTX_SM_SEP) NVPTX_SM(70, NVPTX_SM_SEP) NVPTX_SM(75, NVPTX_SM_SEP) NVPTX_SM(80,) ... and use it in various places using a pattern: ... #define NVPTX_SM(XX, SEP) { ... } #include "nvptx-sm.def" #undef NVPTX_SM ... Tested on nvptx. gcc/ChangeLog: 2022-02-25 Tom de Vries <tdevries@suse.de> * config/nvptx/nvptx-sm.def: New file. * config/nvptx/nvptx-c.cc (nvptx_cpu_cpp_builtins): Use nvptx-sm.def. * config/nvptx/nvptx-opts.h (enum ptx_isa): Same. * config/nvptx/nvptx.cc (sm_version_to_string) (nvptx_omp_device_kind_arch_isa): Same. Diff: --- gcc/config/nvptx/nvptx-c.cc | 22 ++++++++++------------ gcc/config/nvptx/nvptx-opts.h | 11 +++++------ gcc/config/nvptx/nvptx-sm.def | 30 ++++++++++++++++++++++++++++++ gcc/config/nvptx/nvptx.cc | 36 ++++++++++++------------------------ 4 files changed, 57 insertions(+), 42 deletions(-) diff --git a/gcc/config/nvptx/nvptx-c.cc b/gcc/config/nvptx/nvptx-c.cc index b2375fb5b16..02f75625064 100644 --- a/gcc/config/nvptx/nvptx-c.cc +++ b/gcc/config/nvptx/nvptx-c.cc @@ -39,17 +39,15 @@ nvptx_cpu_cpp_builtins (void) cpp_define (parse_in, "__nvptx_softstack__"); if (TARGET_UNIFORM_SIMT) cpp_define (parse_in,"__nvptx_unisimt__"); - if (TARGET_SM80) - cpp_define (parse_in, "__PTX_SM__=800"); - else if (TARGET_SM75) - cpp_define (parse_in, "__PTX_SM__=750"); - else if (TARGET_SM70) - cpp_define (parse_in, "__PTX_SM__=700"); - else if (TARGET_SM53) - cpp_define (parse_in, "__PTX_SM__=530"); - else if (TARGET_SM35) - cpp_define (parse_in, "__PTX_SM__=350"); - else - cpp_define (parse_in,"__PTX_SM__=300"); + + const char *ptx_sm = NULL; +#define NVPTX_SM(XX, SEP) \ + { \ + if (TARGET_SM ## XX) \ + ptx_sm = "__PTX_SM__=" #XX "0"; \ + } +#include "nvptx-sm.def" +#undef NVPTX_SM + cpp_define (parse_in, ptx_sm); } diff --git a/gcc/config/nvptx/nvptx-opts.h b/gcc/config/nvptx/nvptx-opts.h index 30852b6992c..86b433caae8 100644 --- a/gcc/config/nvptx/nvptx-opts.h +++ b/gcc/config/nvptx/nvptx-opts.h @@ -22,12 +22,11 @@ enum ptx_isa { - PTX_ISA_SM30, - PTX_ISA_SM35, - PTX_ISA_SM53, - PTX_ISA_SM70, - PTX_ISA_SM75, - PTX_ISA_SM80 +#define NVPTX_SM(XX, SEP) PTX_ISA_SM ## XX SEP +#define NVPTX_SM_SEP , +#include "nvptx-sm.def" +#undef NVPTX_SM_SEP +#undef NVPTX_SM }; enum ptx_version diff --git a/gcc/config/nvptx/nvptx-sm.def b/gcc/config/nvptx/nvptx-sm.def new file mode 100644 index 00000000000..c552eb0c88b --- /dev/null +++ b/gcc/config/nvptx/nvptx-sm.def @@ -0,0 +1,30 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + <http://www.gnu.org/licenses/>. */ + +#ifndef NVPTX_SM_SEP +#define NVPTX_SM_SEP +#endif + +NVPTX_SM (30, NVPTX_SM_SEP) +NVPTX_SM (35, NVPTX_SM_SEP) +NVPTX_SM (53, NVPTX_SM_SEP) +NVPTX_SM (70, NVPTX_SM_SEP) +NVPTX_SM (75, NVPTX_SM_SEP) +NVPTX_SM (80,) + +#undef NVPTX_SM_SEP diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index 7862a90a65a..f3179efa8d6 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -276,18 +276,11 @@ sm_version_to_string (enum ptx_isa sm) { switch (sm) { - case PTX_ISA_SM30: - return "30"; - case PTX_ISA_SM35: - return "35"; - case PTX_ISA_SM53: - return "53"; - case PTX_ISA_SM70: - return "70"; - case PTX_ISA_SM75: - return "75"; - case PTX_ISA_SM80: - return "80"; +#define NVPTX_SM(XX, SEP) \ + case PTX_ISA_SM ## XX: \ + return #XX; +#include "nvptx-sm.def" +#undef NVPTX_SM default: gcc_unreachable (); } @@ -6177,18 +6170,13 @@ nvptx_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait, case omp_device_arch: return strcmp (name, "nvptx") == 0; case omp_device_isa: - if (strcmp (name, "sm_30") == 0) - return !TARGET_SM35; - if (strcmp (name, "sm_35") == 0) - return TARGET_SM35 && !TARGET_SM53; - if (strcmp (name, "sm_53") == 0) - return TARGET_SM53 && !TARGET_SM70; - if (strcmp (name, "sm_70") == 0) - return TARGET_SM70 && !TARGET_SM75; - if (strcmp (name, "sm_75") == 0) - return TARGET_SM75 && !TARGET_SM80; - if (strcmp (name, "sm_80") == 0) - return TARGET_SM80; +#define NVPTX_SM(XX, SEP) \ + { \ + if (strcmp (name, "sm_" #XX) == 0) \ + return ptx_isa_option == PTX_ISA_SM ## XX; \ + } +#include "nvptx-sm.def" +#undef NVPTX_SM return 0; default: gcc_unreachable ();
reply other threads:[~2022-03-01 7:59 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220301075951.577283858430@sourceware.org \ --to=vries@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).