From 1f5db2b2154e1d10655e4d5d5cd0faa4842f171a Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 7 Apr 2022 14:24:46 +0200 Subject: [PATCH] as: Deal with CUDA 11.0, "Support for Kepler 'sm_30' and 'sm_32' architecture based products is dropped" This resolves #30 "[RFC] Handle sm_* which is no longer supported by CUDA / ptxas exec check or configure check?". Suggested-by: Tom de Vries --- nvptx-as.c | 38 ++++++++++++++++---- test/as/ptxas/invoke-1.test | 72 +++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 6 deletions(-) diff --git a/nvptx-as.c b/nvptx-as.c index dd0b7f6..5007de3 100644 --- a/nvptx-as.c +++ b/nvptx-as.c @@ -1191,18 +1191,44 @@ This program has absolutely no warranty.\n", if (verify > 0) { - /* We override the default '--gpu-name' of 'ptxas': its default may not - be sufficient for what is requested in the '.target' directive in the - input's preamble ("SM version specified by .target is higher than - default SM version assumed"). */ const char *target_arg; if (target_arg_force) target_arg = target_arg_force; else { assert (tok_preamble_target_arg); - target_arg = strndup (tok_preamble_target_arg->ptr, - tok_preamble_target_arg->len); + + /* Override the default '--gpu-name' of 'ptxas': its default may not + be sufficient for what is requested in the '.target' directive in + the input's preamble: + + ptxas fatal : SM version specified by .target is higher than default SM version assumed + + In this case, use the '.target' we found in the preamble. */ + target_arg = xstrndup (tok_preamble_target_arg->ptr, + tok_preamble_target_arg->len); + + if ((strcmp ("sm_30", target_arg) == 0) + || (strcmp ("sm_32", target_arg) == 0)) + { + /* Starting with CUDA 11.0, "Support for Kepler 'sm_30' and + 'sm_32' architecture based products is dropped", and these may + no longer be specified in '--gpu-name' of 'ptxas': + + ptxas fatal : Value 'sm_30' is not defined for option 'gpu-name' + + ptxas fatal : Value 'sm_32' is not defined for option 'gpu-name' + + ..., but we need to continue supporting GCC emitting + '.target sm_30' code, for example. + + Detecting the CUDA/'ptxas' version and the supported + '--gpu-name' options is clumsy, so in this case, just use + 'sm_35', which is the baseline supported by all current CUDA + versions down to CUDA 6.5, at least. */ + free ((void *) target_arg); + target_arg = "sm_35"; + } } struct obstack argv_obstack; diff --git a/test/as/ptxas/invoke-1.test b/test/as/ptxas/invoke-1.test index 9137383..b00caab 100644 --- a/test/as/ptxas/invoke-1.test +++ b/test/as/ptxas/invoke-1.test @@ -49,3 +49,75 @@ RUN: rm -f %t* RUN: %dummy_ptxas_path DUMMY_PTXAS_LOG=%t.dummy_ptxas_log %target_as_cmd -o /dev/null %S/../bare-1.s -m sm_2020 RUN: sed -e 's|sm_35|sm_2020|g' < %S/dummy_ptxas_log.golden > %t.dummy_ptxas_log.golden RUN: cmp %t.dummy_ptxas_log.golden %t.dummy_ptxas_log + + +Implicit '--verify', preamble '.target sm_2022' + +RUN: rm -f %t* +RUN: sed -e 's|sm_35|sm_2022|g' < %S/../bare-1.s > %t.bare-1.s +RUN: %dummy_ptxas_path DUMMY_PTXAS_LOG=%t.dummy_ptxas_log %target_as_cmd -o /dev/null %t.bare-1.s +RUN: sed -e 's|sm_35|sm_2022|g' < %S/dummy_ptxas_log.golden > %t.dummy_ptxas_log.golden +RUN: cmp %t.dummy_ptxas_log.golden %t.dummy_ptxas_log + + +Special handling re CUDA 11.0, "Support for Kepler 'sm_30' and 'sm_32' architecture based products is dropped" + +Preamble '.target sm_3': doesn't exist; not special-cased. + +RUN: rm -f %t* +RUN: sed -e 's|sm_35|sm_3|g' < %S/../bare-1.s > %t.bare-1.s +RUN: %dummy_ptxas_path DUMMY_PTXAS_LOG=%t.dummy_ptxas_log %target_as_cmd -o /dev/null %t.bare-1.s +RUN: sed -e 's|sm_35|sm_3|g' < %S/dummy_ptxas_log.golden > %t.dummy_ptxas_log.golden +RUN: cmp %t.dummy_ptxas_log.golden %t.dummy_ptxas_log + +Preamble '.target sm_30': special-cased to '--gpu-name sm_35'. + +RUN: rm -f %t* +RUN: sed -e 's|sm_35|sm_30|g' < %S/../bare-1.s > %t.bare-1.s +RUN: %dummy_ptxas_path DUMMY_PTXAS_LOG=%t.dummy_ptxas_log %target_as_cmd -o /dev/null %t.bare-1.s +RUN: cmp %S/dummy_ptxas_log.golden %t.dummy_ptxas_log + +Preamble '.target sm_31': doesn't exist; not special-cased. + +RUN: rm -f %t* +RUN: sed -e 's|sm_35|sm_31|g' < %S/../bare-1.s > %t.bare-1.s +RUN: %dummy_ptxas_path DUMMY_PTXAS_LOG=%t.dummy_ptxas_log %target_as_cmd -o /dev/null %t.bare-1.s +RUN: sed -e 's|sm_35|sm_31|g' < %S/dummy_ptxas_log.golden > %t.dummy_ptxas_log.golden +RUN: cmp %t.dummy_ptxas_log.golden %t.dummy_ptxas_log + +Preamble '.target sm_32': special-cased to '--gpu-name sm_35'. + +RUN: rm -f %t* +RUN: sed -e 's|sm_35|sm_32|g' < %S/../bare-1.s > %t.bare-1.s +RUN: %dummy_ptxas_path DUMMY_PTXAS_LOG=%t.dummy_ptxas_log %target_as_cmd -o /dev/null %t.bare-1.s +RUN: cmp %S/dummy_ptxas_log.golden %t.dummy_ptxas_log + +Preamble '.target sm_35': not special-cased. + +RUN: rm -f %t* +RUN: %dummy_ptxas_path DUMMY_PTXAS_LOG=%t.dummy_ptxas_log %target_as_cmd -o /dev/null %S/../bare-1.s +RUN: cmp %S/dummy_ptxas_log.golden %t.dummy_ptxas_log + +Preamble '.target sm_37': not special-cased. + +RUN: rm -f %t* +RUN: sed -e 's|sm_35|sm_37|g' < %S/../bare-1.s > %t.bare-1.s +RUN: %dummy_ptxas_path DUMMY_PTXAS_LOG=%t.dummy_ptxas_log %target_as_cmd -o /dev/null %t.bare-1.s +RUN: sed -e 's|sm_35|sm_37|g' < %S/dummy_ptxas_log.golden > %t.dummy_ptxas_log.golden +RUN: cmp %t.dummy_ptxas_log.golden %t.dummy_ptxas_log + +Preamble '.target sm_30x': doesn't exist; not special-cased. + +RUN: rm -f %t* +RUN: sed -e 's|sm_35|sm_30x|g' < %S/../bare-1.s > %t.bare-1.s +RUN: %dummy_ptxas_path DUMMY_PTXAS_LOG=%t.dummy_ptxas_log %target_as_cmd -o /dev/null %t.bare-1.s +RUN: sed -e 's|sm_35|sm_30x|g' < %S/dummy_ptxas_log.golden > %t.dummy_ptxas_log.golden +RUN: cmp %t.dummy_ptxas_log.golden %t.dummy_ptxas_log + +Preamble '.target sm_32x': doesn't exist; not special-cased. + +RUN: rm -f %t* +RUN: sed -e 's|sm_35|sm_32x|g' < %S/../bare-1.s > %t.bare-1.s +RUN: %dummy_ptxas_path DUMMY_PTXAS_LOG=%t.dummy_ptxas_log %target_as_cmd -o /dev/null %t.bare-1.s +RUN: sed -e 's|sm_35|sm_32x|g' < %S/dummy_ptxas_log.golden > %t.dummy_ptxas_log.golden +RUN: cmp %t.dummy_ptxas_log.golden %t.dummy_ptxas_log