Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions nvptx-as.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
72 changes: 72 additions & 0 deletions test/as/ptxas/invoke-1.test
Original file line number Diff line number Diff line change
Expand Up @@ -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