From 598f761ba71da7b207c646359afbaadfec13c265 Mon Sep 17 00:00:00 2001 From: Payam Date: Mon, 6 Apr 2020 12:17:00 -0400 Subject: [PATCH] updated LOG_LEVEL prints to print pid and tid Change-Id: I8a9212b26bb7e312408a222823efcfd00344094b [ROCm/hip commit: 8c26e0b3b68dbf6ad3c9d62071b986884a823d1b] --- projects/hip/vdi/hip_internal.hpp | 15 ++++++++++++--- projects/hip/vdi/hip_memory.cpp | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/projects/hip/vdi/hip_internal.hpp b/projects/hip/vdi/hip_internal.hpp index 92397d1255..a2851fd978 100755 --- a/projects/hip/vdi/hip_internal.hpp +++ b/projects/hip/vdi/hip_internal.hpp @@ -31,7 +31,11 @@ #include #include #include - +#ifdef _WIN32 +#include +#else +#include +#endif /*! IHIP IPC MEMORY Structure */ #define IHIP_IPC_MEM_HANDLE_SIZE 32 @@ -43,6 +47,10 @@ typedef struct ihipIpcMemHandle_st { char reserved[IHIP_IPC_MEM_RESERVED_SIZE]; } ihipIpcMemHandle_t; +#ifdef _WIN32 + int getpid() { return _getpid();} +#endif + #define HIP_INIT() \ std::call_once(hip::g_ihipInitialized, hip::init); \ if (hip::g_device == nullptr && g_devices.size() > 0) { \ @@ -51,7 +59,7 @@ typedef struct ihipIpcMemHandle_st { // This macro should be called at the beginning of every HIP API. #define HIP_INIT_API(cid, ...) \ - ClPrint(amd::LOG_INFO, amd::LOG_API, "[%zx] %s ( %s )", std::this_thread::get_id(), __func__, ToString( __VA_ARGS__ ).c_str()); \ + ClPrint(amd::LOG_INFO, amd::LOG_API, "%-5d: [%zx] %s ( %s )", getpid(), std::this_thread::get_id(), __func__, ToString( __VA_ARGS__ ).c_str()); \ amd::Thread* thread = amd::Thread::current(); \ if (!VDI_CHECK_THREAD(thread)) { \ HIP_RETURN(hipErrorOutOfMemory); \ @@ -61,7 +69,7 @@ typedef struct ihipIpcMemHandle_st { #define HIP_RETURN(ret) \ hip::g_lastError = ret; \ - ClPrint(amd::LOG_INFO, amd::LOG_API, "[%zx] %s: Returned %s", std::this_thread::get_id(), __func__, hipGetErrorName(hip::g_lastError)); \ + ClPrint(amd::LOG_INFO, amd::LOG_API, "%-5d: [%zx] %s: Returned %s", getpid(), std::this_thread::get_id(), __func__, hipGetErrorName(hip::g_lastError)); \ return hip::g_lastError; namespace hc { @@ -274,6 +282,7 @@ public: void configureCall(dim3 gridDim, dim3 blockDim, size_t sharedMem, hipStream_t stream); void popExec(ihipExec_t& exec); + }; extern std::vector g_devices; diff --git a/projects/hip/vdi/hip_memory.cpp b/projects/hip/vdi/hip_memory.cpp index 1246f53fe8..1625f7703a 100644 --- a/projects/hip/vdi/hip_memory.cpp +++ b/projects/hip/vdi/hip_memory.cpp @@ -85,7 +85,7 @@ hipError_t ihipMalloc(void** ptr, size_t sizeBytes, unsigned int flags) if (*ptr == nullptr) { return hipErrorOutOfMemory; } - ClPrint(amd::LOG_INFO, amd::LOG_API, "ihipMalloc ptr=0x%zx", *ptr); + ClPrint(amd::LOG_INFO, amd::LOG_API, "%-5d: [%zx] ihipMalloc ptr=0x%zx", getpid(),std::this_thread::get_id(), *ptr); return hipSuccess; }