Skip to content

cuda-gdb doesn't demangle variable names in device code #32

@Saitama10000

Description

@Saitama10000

Cuda-gdb doesn't demangle variable names in device code. It only does this in host code. This is troublesome for writing custom pretty printers.

#include <iostream>
#include "cooperative_groups.h"
namespace cg = cooperative_groups;

template <typename _value_type, int _size>
class Array
{
public:
    using value_type = _value_type;
    __device__ __host__ constexpr Array(std::initializer_list<_value_type> l) { int i = 0; for (auto x : l) (*this)[i++] = x; }
    __device__ __host__ constexpr auto operator[](int i) const { return data[i]; }
    __device__ __host__ constexpr auto operator[](int i) -> auto& { return data[i]; }
    __device__ __host__ constexpr auto size() const { return _size; }
private:
    value_type data[_size]{};
};

template <typename T, int size>
__device__ __host__ void iota(Array<T, size>& arr, T start)
{
    for (int i = 0; i < arr.size(); i++)
        arr[i] = start++;
};

__global__ void kernel()
{
    Array<int, 8> arr{};
    iota(arr, 0);
}

int main()
{
    Array<int, 8> arr{};
    iota(arr, 0);

    kernel<<<1, 8>>>();
    cudaDeviceSynchronize();
}

image

If I remove @local and just do demangle _Z5ArrayIiLi8EE I get Array<int, 8> so cuda-gdb knows how to demangle, it just doesn't want to do it for some reason.

I don't know whether this is a bug or a known limitation or whether I'm doing something wrong on my end. I'm using cuda toolkit 12.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions