From ecbb494a5861debf0bb1cc9ad8cd6197bfd81fef Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 28 Jul 2017 22:13:43 -0500 Subject: [PATCH] Some fixes to tracing. --- src/grid_launch.cpp | 4 ++-- src/hip_device.cpp | 6 ++++-- src/hip_hcc.cpp | 11 +++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/grid_launch.cpp b/src/grid_launch.cpp index f3b28c5f60..fd5c2a1573 100644 --- a/src/grid_launch.cpp +++ b/src/grid_launch.cpp @@ -72,8 +72,8 @@ namespace hip_impl } if (COMPILE_HIP_DB && HIP_TRACE_API) { - std::cerr << API_COLOR << os.str() << API_COLOR_END - << std::endl; + std::string fullStr; + recordApiTrace(&fullStr, os.str()); } } } diff --git a/src/hip_device.cpp b/src/hip_device.cpp index 7e59e37cad..5ff6dbf04d 100644 --- a/src/hip_device.cpp +++ b/src/hip_device.cpp @@ -358,7 +358,8 @@ hipError_t hipDeviceComputeCapability(int *major, int *minor, hipDevice_t device hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device) { - HIP_INIT_API(name,len, device); + // Cast to void* here to avoid printing garbage in debug modes. + HIP_INIT_API((void*)name,len, device); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(device); int nameLen = strlen(deviceHandle->_props.name); @@ -369,7 +370,8 @@ hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device) hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len, int device) { - HIP_INIT_API(pciBusId, len, device); + // Cast to void* here to avoid printing garbage in debug modes. + HIP_INIT_API((void*)pciBusId, len, device); hipError_t e = hipErrorInvalidValue; int deviceCount = 0; ihipGetDeviceCount( &deviceCount ); diff --git a/src/hip_hcc.cpp b/src/hip_hcc.cpp index d4f7723dbc..d080e34993 100644 --- a/src/hip_hcc.cpp +++ b/src/hip_hcc.cpp @@ -1424,9 +1424,7 @@ void ihipPrintKernelLaunch(const char *kernelName, const grid_launch_parm *lp, c { if ((HIP_TRACE_API & (1<grid_dim @@ -1434,6 +1432,11 @@ void ihipPrintKernelLaunch(const char *kernelName, const grid_launch_parm *lp, c << " sharedMem:+" << lp->dynamic_group_mem_bytes << " " << *stream; + if (COMPILE_HIP_DB && HIP_TRACE_API) { + std::string fullStr; + recordApiTrace(&fullStr, os.str()); + } + if (HIP_PROFILE_API == 0x1) { std::string shortAtpString("hipLaunchKernel:"); shortAtpString += kernelName; @@ -1441,10 +1444,6 @@ void ihipPrintKernelLaunch(const char *kernelName, const grid_launch_parm *lp, c } else if (HIP_PROFILE_API == 0x2) { MARKER_BEGIN(os.str().c_str(), "HIP"); } - - if (COMPILE_HIP_DB && HIP_TRACE_API) { - std::cerr << API_COLOR << os.str() << API_COLOR_END << std::endl; - } } }