Skip to content

Commit

Permalink
Refactor kernel name retrieval in Interceptor.cc
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pvelesko committed Dec 10, 2024
1 parent 1375789 commit a598904
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
14 changes: 1 addition & 13 deletions HIP-Intercept-Layer/Interceptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<void*, AllocationInfo*> findContainingAllocation(void* ptr) {
for (auto& [base_ptr, info] : gpu_allocations) {
Expand Down Expand Up @@ -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);

Check warning on line 516 in HIP-Intercept-Layer/Interceptor.cc

View workflow job for this annotation

GitHub Actions / cpp-linter

HIP-Intercept-Layer/Interceptor.cc:516:17 [readability-identifier-naming]

invalid case style for local variable 'kernelName'
Tracer::instance().printKernelArgs(args, kernelName, function_address);

// Create execution record
Expand Down
2 changes: 0 additions & 2 deletions HIP-Intercept-Layer/Interceptor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public:
extern std::unordered_map<void*, AllocationInfo> 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<void*, AllocationInfo*> findContainingAllocation(void* ptr);
Expand Down

0 comments on commit a598904

Please sign in to comment.