diff --git a/projects/hip/include/hcc_detail/hip_hcc.h b/projects/hip/include/hcc_detail/hip_hcc.h index 449d9bc522..01c36afde4 100644 --- a/projects/hip/include/hcc_detail/hip_hcc.h +++ b/projects/hip/include/hcc_detail/hip_hcc.h @@ -160,13 +160,17 @@ class ihipCtx_t; #endif +// Just initialize the HIP runtime, but don't log any trace information. +#define HIP_INIT()\ + std::call_once(hip_initialized, ihipInit);\ + ihipCtxStackUpdate(); + // This macro should be called at the beginning of every HIP API. // It initialies the hip runtime (exactly once), and // generate trace string that can be output to stderr or to ATP file. #define HIP_INIT_API(...) \ - std::call_once(hip_initialized, ihipInit);\ - ihipCtxStackUpdate();\ + HIP_INIT()\ API_TRACE(__VA_ARGS__); #define ihipLogStatus(hipStatus) \ diff --git a/projects/hip/include/hcc_detail/hip_runtime.h b/projects/hip/include/hcc_detail/hip_runtime.h index 740e60d0eb..727604d8d8 100644 --- a/projects/hip/include/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hcc_detail/hip_runtime.h @@ -622,11 +622,12 @@ __device__ static inline void* memset(void* ptr, uint8_t val, size_t size) #define HIP_KERNEL_NAME(...) __VA_ARGS__ #ifdef __HCC_CPP__ -hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, dim3 block, grid_launch_parm *lp); -hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, size_t block, grid_launch_parm *lp); -hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, dim3 block, grid_launch_parm *lp); -hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, size_t block, grid_launch_parm *lp); -void ihipPostLaunchKernel(hipStream_t stream, grid_launch_parm &lp); +extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, dim3 block, grid_launch_parm *lp); +extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, size_t block, grid_launch_parm *lp); +extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, dim3 block, grid_launch_parm *lp); +extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, size_t block, grid_launch_parm *lp); +extern void ihipPrintKernelLaunch(const char *kernelName, const grid_launch_parm *lp, const hipStream_t stream); +extern void ihipPostLaunchKernel(hipStream_t stream, grid_launch_parm &lp); // TODO - move to common header file. #define KNRM "\x1B[0m" @@ -638,10 +639,9 @@ do {\ grid_launch_parm lp;\ lp.dynamic_group_mem_bytes = _groupMemBytes; \ hipStream_t trueStream = (ihipPreLaunchKernel(_stream, _numBlocks3D, _blockDim3D, &lp)); \ - if (HIP_TRACE_API) {\ - fprintf(stderr, KGRN "<grid_dim.x, lp->grid_dim.y, lp->grid_dim.z, lp->group_dim.x, lp->group_dim.y, lp->group_dim.z, + lp->dynamic_group_mem_bytes, streamString.c_str());\ +} // TODO - data-up to data-down: // Called just before a kernel is launched from hipLaunchKernel. // Allows runtime to track some information about the stream. hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, dim3 block, grid_launch_parm *lp) { - HIP_INIT_API(stream, grid, block, lp); + HIP_INIT(); stream = ihipSyncAndResolveStream(stream); #if USE_GRID_LAUNCH_20 lp->grid_dim.x = grid.x;