From e4641c7e507431444bfab63d7b2acc76c84d97aa Mon Sep 17 00:00:00 2001 From: Eyal Rozenberg Date: Tue, 10 Sep 2024 23:00:05 +0300 Subject: [PATCH] Regards #674: The `kernel_t::name()` metod renamed to `mangled_name()`, to clarify to the user what they're actually getting; this doesn't fully resolve the issue though. --- examples/by_api_module/execution_control.cu | 9 ++++++--- src/cuda/api/kernel.hpp | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/by_api_module/execution_control.cu b/examples/by_api_module/execution_control.cu index ff6fcc0b..e2d57031 100644 --- a/examples/by_api_module/execution_control.cu +++ b/examples/by_api_module/execution_control.cu @@ -56,13 +56,16 @@ int main(int argc, char **argv) #if CUDA_VERSION >= 12030 cuda::kernel_t const& base_ref = kernel; - auto name_from_kernel = base_ref.name(); - if (strcmp(name_from_kernel, kernel_name) != 0) { + auto mangled_name_from_kernel = base_ref.mangled_name(); +#ifdef __GNUC__ + auto demangled_name = demangle(mangled_name_from_kernel); + if (strcmp(demangled_name.c_str(), kernel_name) != 0) { std::cout << "CUDA reports a different name for kernel \"" << kernel_name - << "\" via its handle: \"" << name_from_kernel << "\"" << std::endl; + << "\" via its handle: \"" << demangled_name << "\"" << std::endl; return EXIT_FAILURE; } +#endif #endif // ------------------------------------------ diff --git a/src/cuda/api/kernel.hpp b/src/cuda/api/kernel.hpp index 5575cce5..e632e3db 100644 --- a/src/cuda/api/kernel.hpp +++ b/src/cuda/api/kernel.hpp @@ -191,7 +191,9 @@ class kernel_t { #endif #if CUDA_VERSION >= 12030 - const char *name() const { return cuda::kernel::detail_::get_name(context_handle_, handle_); } + /// Return the mangled name of the kernel (representing the original name, and, + /// possibly, the parameter types) + const char *mangled_name() const { return cuda::kernel::detail_::get_name(context_handle_, handle_); } module_t module() const; #endif