From a598904b8650d279a7971f5596671b5a41bac36c Mon Sep 17 00:00:00 2001 From: Paulius Velesko Date: Mon, 9 Dec 2024 18:14:11 +0200 Subject: [PATCH] Refactor kernel name retrieval in Interceptor.cc Removed the local helper function for getting the kernel name and replaced it with a call to the hip_intercept namespace's getKernelName function. This change streamlines the code and improves maintainability by utilizing a centralized function for kernel name retrieval. --- HIP-Intercept-Layer/Interceptor.cc | 14 +------------- HIP-Intercept-Layer/Interceptor.hh | 2 -- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/HIP-Intercept-Layer/Interceptor.cc b/HIP-Intercept-Layer/Interceptor.cc index f3194a141..0c03b8d00 100644 --- a/HIP-Intercept-Layer/Interceptor.cc +++ b/HIP-Intercept-Layer/Interceptor.cc @@ -277,18 +277,6 @@ static void printKernelArgs(void** args, const std::string& kernelName, const vo } } -// Add this helper function to get kernel name from function address -static std::string getKernelName(const void* function_address) { - Dl_info info; - if (dladdr(function_address, &info) && info.dli_sname) { - return info.dli_sname; - } - // If we can't get the name, return the address as hex - std::stringstream ss; - ss << "kernel_" << std::hex << (uintptr_t)function_address; - return ss.str(); -} - // Helper to find which allocation a pointer belongs to static std::pair findContainingAllocation(void* ptr) { for (auto& [base_ptr, info] : gpu_allocations) { @@ -525,7 +513,7 @@ static hipError_t hipLaunchKernel_impl(const void *function_address, dim3 numBlo << "\n stream=" << (void*)stream << "\n"; // Get kernel name and print args using Tracer - std::string kernelName = getKernelName(function_address); + std::string kernelName = hip_intercept::getKernelName(function_address); Tracer::instance().printKernelArgs(args, kernelName, function_address); // Create execution record diff --git a/HIP-Intercept-Layer/Interceptor.hh b/HIP-Intercept-Layer/Interceptor.hh index 1725b27c5..79bc350a8 100644 --- a/HIP-Intercept-Layer/Interceptor.hh +++ b/HIP-Intercept-Layer/Interceptor.hh @@ -34,8 +34,6 @@ public: extern std::unordered_map gpu_allocations; // Helper function declarations -std::string getKernelSignature(const void* function_address); -std::string getKernelName(const void* function_address); size_t countKernelArgs(void** args); std::string getArgTypeFromSignature(const std::string& signature, size_t arg_index); std::pair findContainingAllocation(void* ptr);