1

I'm filtering my compiled PTX through c++filt, but it only demangles some of the names/labels and leaves some as-is. For example, this:

func  (.param .b32 func_retval0) _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii(
        .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii_param_0,
        .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii_param_1,
        .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii_param_2
)

is demangled as this:

.func  (.param .b32 func_retval0) _INTERNAL_19_gather_bits_cpp1_ii_56538e7c::__shfl(int, int, int)(
        .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii_param_0,
        .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii_param_1,
        .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c6__shflEiii_param_2
)

rather than at least this:

.func  (.param .b32 func_retval0) _INTERNAL_19_gather_bits_cpp1_ii_56538e7c::__shfl(int, int, int)(
        .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c::__shfl(int, int, int)_param_0,
        .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c::__shfl(int, int, int)_param_1,
        .param .b32 _ZN41_INTERNAL_19_gather_bits_cpp1_ii_56538e7c::__shfl(int, int, int)_param_2
)

I realize c++filt does not have explicit support for CUDA PTX; but note that the undemangled names differ from the demangled ones in the example merely by an addition _param_0, _param_1 etc. suffix (there's also the question of how the prefix of those names should be demangled, but let's forget about that).

  • Is there something I can do force c++filt to also apply to the parameter names/labels as well? And more generally, to all of the mangled C++ names in the PTX file?
  • Is it possible/easy to augment c++filt with awareness of the the CUDA "format", in additional to the "formats" it has already ([-s|--format {none,auto,gnu,lucid,arm,hp,edg,gnu-v3,java,gnat,dlang}])?
  • If c++filt can't be used or adapted for use in this case, how should I go about doing the demangling?
einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • 1
    Those are not demangled because they are not valid gnu style C++ mangled names – talonmies Aug 31 '16 at 12:16
  • @talonmies: Indeed... see edit. – einpoklum Aug 31 '16 at 12:29
  • So your question is really "Does c++filt support the CUDA ABI?", and the answer is clearly no, from the look of things – talonmies Aug 31 '16 at 12:33
  • @talonmies: My question is can I get to it to demangle more than it does by default, e.g. with its command-line parameters, or even by defining an additional format for it. And if the answer is "not really without rewriting it", then - what are my other options. – einpoklum Aug 31 '16 at 12:37
  • I believe the answer provided by @talonmies is a good one and I have upvoted it. Some CUDA tools have demangling capability built in. I don't know specifically for this case if it would help for these symbols, and unfortunately the question does not provide a convenient test case for me. However with a simple test case, it might be worth while to see what output may be available from some of the CUDA binary utilities. It's possible of course that they won't help, so in that case I would refer back to the answer already given below. – Robert Crovella Aug 31 '16 at 15:23
  • 1
    a [mcve] is often useful in a SO question. Yes, many such questions can be converted to hypothetical ones which appear to obviate the need for an MCVE, but in so doing you make the question harder to work on for others who might try to help you. Yes, if I happen to know the answer to your exact question, I don't need an MCVE, and if you only want help from people like that, fair enough. I don't know the answer to every question, but I am often willing to work on well documented ones that enable me to do so without having to create my own test case and wonder if it is reflective of yours – Robert Crovella Aug 31 '16 at 15:28
  • @RobertCrovella: See edit. – einpoklum Aug 31 '16 at 15:40

1 Answers1

3

Quoting from the documentation

The C++ implementation for device functions follows the Itanium C++ ABI.

c++filt implements demangling of Itanium C++ ABI symbols, therefore, it can demangle kernel names and device function names from PTX source or ELF objects.

However, the other symbols you have posted are CUDA ABI symbols. c++filt doesn't support those because it doesn't support the CUDA ABI. Whether they might look similar or not is irrelevant. If you really need this, then petition NVIDIA to add a demangler for CUDA ABI symbols to the toolchain, as they have done with ELF utilities and other internals.

talonmies
  • 70,661
  • 34
  • 192
  • 269