From 321fc0490a686190b7eb10849d1f3f96e389c5cf Mon Sep 17 00:00:00 2001 From: foreman Date: Mon, 19 Sep 2016 12:13:23 -0400 Subject: [PATCH] P4 to Git Change 1315824 by asalmanp@asalmanp-opencl-stg on 2016/09/19 12:04:15 SWDEV-102417 - Forum [205433] : Memory leak with printf statement inside kernel code A memory leak can occur if a printf statement is inside the .cl source code but it is not used inside the __kernel code (e.g., a function inside .cl code that uses printf but never called by the __kernel). In this case compiler generates the printf metadata but printf is not used by the __kernel (i.e., the printf buffer is empty). To fix this issue, release the transfer buffer object before returning false in PrintfDbgHSA::output function. ReviewBoardURL = http://ocltc.amd.com/reviews/r/11394/ Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprintf.cpp#42 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprintf.cpp#3 edit [ROCm/clr commit: 0dd7a03954602d78f6cd1af43576cc0f03819fa9] --- projects/clr/rocclr/runtime/device/gpu/gpuprintf.cpp | 1 + projects/clr/rocclr/runtime/device/pal/palprintf.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuprintf.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuprintf.cpp index ee4d41bf02..03cafde33b 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuprintf.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuprintf.cpp @@ -659,6 +659,7 @@ PrintfDbgHSA::output( if (offsetSize == 0) { LogError("\n The printf buffer is empty!"); + dev().xferRead().release(gpu, *xferBufRead_); return false; } diff --git a/projects/clr/rocclr/runtime/device/pal/palprintf.cpp b/projects/clr/rocclr/runtime/device/pal/palprintf.cpp index 1d81036668..3b0f1d4b14 100644 --- a/projects/clr/rocclr/runtime/device/pal/palprintf.cpp +++ b/projects/clr/rocclr/runtime/device/pal/palprintf.cpp @@ -652,6 +652,7 @@ PrintfDbgHSA::output( if (offsetSize == 0) { LogError("\n The printf buffer is empty!"); + dev().xferRead().release(gpu, *xferBufRead_); return false; }