namhyung / uftrace

Function graph tracer for C/C++/Rust/Python
https://uftrace.github.io/slide/
GNU General Public License v2.0
3.06k stars 473 forks source link

demangling failure with __device_stub_ prefix #1938

Open honggyukim opened 4 months ago

honggyukim commented 4 months ago

There are some symbols begin with __device_stub_, but it makes our demangler fails demangling the symbol as follows.

$ ./misc/demangler __device_stub__Z13mul_mat_vec_qIL9ggml_type13ELi2EEvPKvS2_Pfiiii
__device_stub__Z13mul_mat_vec_qIL9ggml_type13ELi2EEvPKvS2_Pfiiii

If the __device_stub_ prefix is removed, then it can be demangled as follows.

$ ./misc/demangler _Z13mul_mat_vec_qIL9ggml_type13ELi2EEvPKvS2_Pfiiii
mul_mat_vec_q

So I would like to see treat the special prefix __device_stub_ and parse the rest of symbols. The final demangled output can be shown as follows.

$ ./misc/demangler __device_stub__Z13mul_mat_vec_qIL9ggml_type13ELi2EEvPKvS2_Pfiiii
__device_stub_mul_mat_vec_q
honggyukim commented 4 months ago

The same problem is shown in c++filt tool as well.

$ c++filt __device_stub__Z13mul_mat_vec_qIL9ggml_type13ELi2EEvPKvS2_Pfiiii
__device_stub__Z13mul_mat_vec_qIL9ggml_type13ELi2EEvPKvS2_Pfiiii

If the __device_stub_ prefix is removed, then it can be demangled as follows.

$ c++filt _Z13mul_mat_vec_qIL9ggml_type13ELi2EEvPKvS2_Pfiiii
void mul_mat_vec_q<(ggml_type)13, 2>(void const*, void const*, float*, int, int, int, int)
namhyung commented 4 months ago

Hmm.. do you know when it adds the __device_stub_ prefix?

honggyukim commented 4 months ago

It's added by nvcc cuda compiler.

namhyung commented 4 months ago

Ok, thanks. Do you know what else prefix it can add also? Preferably any documentation for that.

Anyway I think we can skip the prefix like we do with _GLOBAL__sub_I_.

honggyukim commented 4 months ago

Sure, I will try to list up for cuda compiler later.