Hi!
On 2024-09-24T18:09:48+0200, I wrote:
> [...] build sm_30 multilib variants (either
> (3a) by default or (3b) upon 'configure'-time request via an additional
> option: '--with-multilib-list=default,sm_30' or similar), and the user
> builds with '-foffload-options=nvptx-none=-march=sm_30': [...]
>
> [...] I'll be happy to
> implement (3b) if people think that's still helpful.
>
> In fact, (3b) can then generally support 'configure'-time selection of
> further multilib variants to be built (for example,
> '--with-multilib-list=default,sm_30,sm_89') -- but not use them as
> default '-march=[...]', in contrast to what '--with-arch=sm_30' or
> '--with-arch=sm_89' does, for example. I'll look into that.
Pushed to trunk branch commit 86b3a7532d56f74fcd1c362f2da7f95e8cc4e4a6
"nvptx: Support '--with-multilib-list'", see attached.
Grüße
Thomas
>From 86b3a7532d56f74fcd1c362f2da7f95e8cc4e4a6 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge
Date: Fri, 27 Sep 2024 17:44:16 +0200
Subject: [PATCH] nvptx: Support '--with-multilib-list'
No change in behavior unless specifying it.
gcc/
* config.gcc: nvptx: Support '--with-multilib-list'.
* config/nvptx/gen-multilib-matches.sh: Adjust.
* configure.ac: Likewise.
* configure: Regenerate.
* doc/install.texi: Update.
* doc/invoke.texi: Align.
* config/nvptx/gen-multilib-matches-tests: Extend.
---
gcc/config.gcc | 69 +--
gcc/config/nvptx/gen-multilib-matches-tests | 121 +++-
gcc/config/nvptx/gen-multilib-matches.sh| 29 -
gcc/configure | 4 +-
gcc/configure.ac| 2 +-
gcc/doc/install.texi| 42 ++-
gcc/doc/invoke.texi | 10 +-
7 files changed, 242 insertions(+), 35 deletions(-)
diff --git a/gcc/config.gcc b/gcc/config.gcc
index f4ae14c6db2a..6381a5793194 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -5595,21 +5595,70 @@ case "${target}" in
;;
nvptx-*)
supported_defaults=arch
- TM_MULTILIB_CONFIG=$with_arch
- #TODO 'sm_[...]' list per 'nvptx-sm.def'.
- case $with_arch in
- sm_30 )
-# OK; default.
+
+ nvptx_multilibs_default=sm_30
+
+ case "x${with_multilib_list}" in
+ x | xno)
+ nvptx_multilibs=
+ ;;
+ xdefault | xyes)
+ nvptx_multilibs=default
+ ;;
+ *)
+ nvptx_multilibs=$with_multilib_list
+ ;;
+ esac
+ nvptx_multilibs=`echo $nvptx_multilibs | sed -e 's/,/ /g'`
+ # Expand 'default'.
+ nvptx_multilibs_expanded=
+ for nvptx_multilib in $nvptx_multilibs; do
+ case $nvptx_multilib in
+ default )
+nvptx_multilibs_expanded="$nvptx_multilibs_expanded $nvptx_multilibs_default"
+;;
+ * )
+nvptx_multilibs_expanded="$nvptx_multilibs_expanded $nvptx_multilib"
;;
- sm_35 | sm_53 | sm_70 | sm_75 | sm_80 )
-# OK, but we'd like 'sm_30', too.
-TM_MULTILIB_CONFIG="$TM_MULTILIB_CONFIG sm_30"
+ esac
+ done
+ # The '--with-arch=[...]' one comes first.
+ nvptx_multilibs=$with_arch$nvptx_multilibs_expanded
+ # Filter out any duplicates.
+ nvptx_multilibs_filtered=
+ for nvptx_multilib in $nvptx_multilibs; do
+ case " $nvptx_multilibs_filtered " in
+ *" $nvptx_multilib "* )
+:
+;;
+ * )
+nvptx_multilibs_filtered="$nvptx_multilibs_filtered $nvptx_multilib"
+;;
+ esac
+ done
+ nvptx_multilibs=$nvptx_multilibs_filtered
+ # Verify, and build 'TM_MULTILIB_CONFIG'.
+ TM_MULTILIB_CONFIG=
+ for nvptx_multilib in $nvptx_multilibs; do
+ case $nvptx_multilib in
+ #TODO 'sm_[...]' list per 'nvptx-sm.def'.
+ sm_30 | sm_35 \
+ | sm_53 \
+ | sm_70 | sm_75 \
+ | sm_80 )
+TM_MULTILIB_CONFIG="$TM_MULTILIB_CONFIG $nvptx_multilib"
+;;
+ $with_arch )
+echo "Unknown arch used in --with-arch=$nvptx_multilib" 1>&2
+exit 1
;;
* )
-echo "Unknown arch used in --with-arch=$with_arch" 1>&2
+echo "Unknown arch used in --with-multilib-list: $nvptx_multilib" 1>&2
exit 1
;;
- esac
+ esac
+ done
+ TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^ //'`
;;
powerpc*-*-* | rs6000-*-*)
diff --git a/gcc/config/nvptx/gen-multilib-matches-tests b/gcc/config/nvptx/gen-multilib-matches-tests
index c2775f268354..b93369149465 100644
--- a/gcc/config/nvptx/gen-multilib-matches-tests
+++ b/gcc/config/nvptx/gen-multilib-matches-tests
@@ -10,7 +10,7 @@
# 'CMMC': compute "multilib matches" per the current settings, and compare to the expected.
-BEGIN '--with-arch=sm_30'
+BEGIN '--with-arch=sm_30', '--with-multilib-list=sm_30'
SMOID sm_30
SMOIL sm_30
AEMM .=misa?sm_30
@@ -21,8 +21,35 @@ AEMM .=misa?sm_75
AEMM .=misa?sm_80
CMMC
+BEGIN '--with-arch=sm_30', '--with-multilib-list=sm_30,sm_80'
+SMOID sm_30
+SMOIL sm_30 sm_80
+AEMM .=misa?sm_30
+AEMM .=misa?sm_35
+AEMM .=misa?sm_53
+AEMM .=misa?sm_70
+AEMM .=misa?sm_75
+CMMC
+
+BEGIN '--with-arch=sm_30', '--with-multilib-list=sm_30,sm_35,sm_53,sm_70,sm_75,sm_80'
+SMOID sm_30
+SMOIL sm_30 sm_35 sm_53 sm_70 sm_75 sm