SWDEV-535490 - Improve logging (#441)

- Include HIP version/githash in the logs
- Add a new method to print library path

[ROCm/clr commit: 5d53c83806]
This commit is contained in:
Kudchadker, Saleel
2025-06-24 13:00:00 -07:00
committed by GitHub
orang tua 4383a50bd9
melakukan 3c9f80b4e4
6 mengubah file dengan 34 tambahan dan 4 penghapusan
+6 -1
Melihat File
@@ -24,6 +24,7 @@
#include "platform/runtime.hpp"
#include "rocclr/utils/flags.hpp"
#include "rocclr/utils/versions.hpp"
#include "rocclr/os/os.hpp"
#include <hip/amd_detail/hip_api_trace.hpp>
namespace hip {
@@ -51,8 +52,12 @@ void init(bool* status) {
*status = false;
return;
}
ClPrint(amd::LOG_INFO, amd::LOG_INIT, "Direct Dispatch: %d", AMD_DIRECT_DISPATCH);
ClPrint(amd::LOG_INFO, amd::LOG_INIT, "HIP Version: %d.%d.%d.%s, Direct Dispatch: %d",
HIP_VERSION_MAJOR, HIP_VERSION_MINOR, HIP_VERSION_PATCH, HIP_VERSION_GITHASH,
AMD_DIRECT_DISPATCH);
// Print the current path of the library
amd::Os::PrintLibraryLocation();
const std::vector<amd::Device*>& devices = amd::Device::getDevices(CL_DEVICE_TYPE_GPU, false);
const size_t deviceCount = devices.size();
g_devices.reserve(deviceCount); // Pre-allocate space for better performance
@@ -30,7 +30,6 @@ bool Comgr::is_ready_ = false;
bool Comgr::LoadLib(bool is_versioned) {
#if defined(COMGR_DYN_DLL)
ClPrint(amd::LOG_INFO, amd::LOG_CODE, "Loading COMGR library.");
if (is_versioned) {
#if defined(HIP_MAJOR_VERSION) && defined(HIP_MAJOR_VERSION)
@@ -390,7 +390,6 @@ hsa_status_t Device::loaderQueryHostAddress(const void* device, const void** hos
// ================================================================================================
bool Device::init() {
ClPrint(amd::LOG_INFO, amd::LOG_INIT, "Initializing HSA stack.");
hsa_status_t status = HSA_STATUS_SUCCESS;
// Initialize the compiler
if (!initCompiler(offlineDevice_)) {
@@ -476,7 +475,7 @@ bool Device::init() {
gpu_agents_ = valid_agents;
}
LogPrintfInfo("Enumerated GPU agents = %lu", gpu_agents_.size());
LogPrintfInfo("Initalizing runtime stack, Enumerated GPU agents = %lu", gpu_agents_.size());
for (auto agent : gpu_agents_) {
std::unique_ptr<Device> roc_device(new Device(agent));
+3
Melihat File
@@ -328,6 +328,9 @@ class Os : AllStatic {
//! Return the current process id
static int getProcessId();
// Prints the location of the currently loaded library (shared object or DLL)
static void PrintLibraryLocation();
};
/*@}*/
+9
Melihat File
@@ -960,6 +960,15 @@ void Os::CloseIpcMemory(const FileDesc desc, const void* ptr, size_t size) {
}
}
void Os::PrintLibraryLocation() {
Dl_info dl_info;
if (dladdr(reinterpret_cast<void*>(Os::loadLibrary), &dl_info) && dl_info.dli_fname) {
ClPrint(amd::LOG_INFO, amd::LOG_INIT, "HIP Library Path: %s", dl_info.dli_fname);
} else {
ClPrint(amd::LOG_INFO, amd::LOG_INIT, "HIP Library Path: <unknown>");
}
}
} // namespace amd
#endif // !defined(_WIN32) && !defined(__CYGWIN__)
+15
Melihat File
@@ -732,6 +732,21 @@ void Os::CloseIpcMemory(const FileDesc desc, const void* ptr, size_t size) {
}
}
void Os::PrintLibraryLocation() {
HMODULE hm = NULL;
if (GetModuleHandleExA(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCSTR)&Os::loadLibrary, &hm)) {
char cszDllPath[1024] = {0};
if (GetModuleFileNameA(hm, cszDllPath, sizeof(cszDllPath))) {
printf("HIP Library Path: %s\n", cszDllPath);
ClPrint(amd::LOG_INFO, amd::LOG_INIT, "HIP Library Path: %s", cszDllPath);
return;
}
}
ClPrint(amd::LOG_INFO, amd::LOG_INIT, "HIP Library Path: <unknown>");
}
} // namespace amd
#endif // _WIN32 || __CYGWIN__