0

When compiling CUDA device code, you may get the error (with line break for readability):

ptxas warning : Stack size for entry function '_ZN7kernels11print_stuffIiEEvv' 
cannot be statically determined

This can have several reasons, like dynamic memory allocation or use of recursion, but those don't matter right now. I want to disable the warning, within some function at least. The thing is, I don't know which token to use to do so. It's no use searching this list (following the suggestion here SO about disabling specific warnings) - because those are warnings in the C/C++ front-end of NVCC, not the assembler.

So how can I disable this warning?

talonmies
  • 70,661
  • 34
  • 192
  • 269
einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • Obviously what you linked to irrelevant, Those are for disabling C or C++ warnings from the CUDA front end. Your warning comes from the assembler...... – talonmies Dec 30 '19 at 14:11
  • @talonmies: Will edit to clarify that. – einpoklum Dec 30 '19 at 14:12
  • @talonmies: Are you sure? If so, make that an answer please. – einpoklum Dec 30 '19 at 15:19
  • 1
    what was the problem with the answer given to you [here](https://stackoverflow.com/questions/59328507/suppress-stack-size-cannot-be-dynamically-determined-warnings) ? Because you want something that works on a per-function basis, like a pragma? Or that you were concerned that it might suppress "other" stack size warnings (not sure what those would be)? Or something else? – Robert Crovella Dec 31 '19 at 00:30
  • 1
    @RobertCrovella: The edit history is informative here. Originally the question was insinuating that there would be a pragma or front end option to suppress this warning, which is obviously impossible. Still, when someone has asked over 350 questions on this tag, I guess it might be difficult to remember all the questions they have already asked and had answered.... – talonmies Dec 31 '19 at 12:01

1 Answers1

2

The important point to note is that this is an assembler warning, so none of the usual front end warning suppression options are relevant.

ptxas only supports a very limited number of warning control options. Prior to CUDA 9, only the following were supported:

--suppress-double-demote-warning                    (-suppress-double-demote-warning)
        Suppress the warning that is otherwise emitted when a double precision instruction
        is encountered in PTX that is targeted for an SM version that does not have
        double precision support

--disable-warnings                                  (-w)                        
        Inhibit all warning messages.

--warn-on-double-precision-use                      (-warn-double-usage)        
        Warning if double(s) are used in an instruction.

--warn-on-local-memory-usage                        (-warn-lmem-usage)          
        Warning if local memory is used.

--warn-on-spills                                    (-warn-spills)              
        Warning if registers are spilled to local memory.

--warning-as-error                                  (-Werror)                   
        Make all warnings into errors.

In your case the only option would be to suppress all warnings. Adding -Xptxas='-w' to any nvcc invocation should achieve that.

CUDA 9 and newer add another option ptxas which suppresses the warning you ask about:

--suppress-stack-size-warning                       (-suppress-stack-size-warning)
        Suppress the warning that otherwise is printed when stack size cannot be
        determined.

In this case, adding -Xptxas='-suppress-stack-size-warning' to any nvcc invocation should eliminate the warning.

talonmies
  • 70,661
  • 34
  • 192
  • 269
  • @einpoklum: I missed that `-suppress-stack-size-warning` was added to CUDA 9 (I was regression testing against CUDA 8 when I ran `ptxas -h`). So what you want already exists. But you should already know this from the almost identical question you asked a couple of weeks ago. – talonmies Dec 31 '19 at 12:03