[polly] r309682 - [GPUJIT] Call `cuProfilerStop` before destroying the context to flush profiler cache.

Siddharth Bhat via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 07:36:24 PDT 2017


Author: bollu
Date: Tue Aug  1 07:36:24 2017
New Revision: 309682

URL: http://llvm.org/viewvc/llvm-project?rev=309682&view=rev
Log:
[GPUJIT] Call `cuProfilerStop` before destroying the context to flush profiler cache.

This is necessary to get accurate traces from `nvprof` / `nvcc`.
Otherwise, we lose some profiling information.

Differential Revision: https://reviews.llvm.org/D35940

Modified:
    polly/trunk/tools/GPURuntime/GPUJIT.c

Modified: polly/trunk/tools/GPURuntime/GPUJIT.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/tools/GPURuntime/GPUJIT.c?rev=309682&r1=309681&r2=309682&view=diff
==============================================================================
--- polly/trunk/tools/GPURuntime/GPUJIT.c (original)
+++ polly/trunk/tools/GPURuntime/GPUJIT.c Tue Aug  1 07:36:24 2017
@@ -958,6 +958,9 @@ static CuMemFreeFcnTy *CuMemFreeFcnPtr;
 typedef CUresult CUDAAPI CuModuleUnloadFcnTy(CUmodule);
 static CuModuleUnloadFcnTy *CuModuleUnloadFcnPtr;
 
+typedef CUresult CUDAAPI CuProfilerStopFcnTy();
+static CuProfilerStopFcnTy *CuProfilerStopFcnPtr;
+
 typedef CUresult CUDAAPI CuCtxDestroyFcnTy(CUcontext);
 static CuCtxDestroyFcnTy *CuCtxDestroyFcnPtr;
 
@@ -1085,6 +1088,9 @@ static int initialDeviceAPIsCUDA() {
   CuModuleUnloadFcnPtr =
       (CuModuleUnloadFcnTy *)getAPIHandleCUDA(HandleCuda, "cuModuleUnload");
 
+  CuProfilerStopFcnPtr =
+      (CuProfilerStopFcnTy *)getAPIHandleCUDA(HandleCuda, "cuProfilerStop");
+
   CuCtxDestroyFcnPtr =
       (CuCtxDestroyFcnTy *)getAPIHandleCUDA(HandleCuda, "cuCtxDestroy");
 
@@ -1416,6 +1422,7 @@ static void freeContextCUDA(PollyGPUCont
 
   CUDAContext *Ctx = (CUDAContext *)Context->Context;
   if (Ctx->Cuda) {
+    CuProfilerStopFcnPtr();
     CuCtxDestroyFcnPtr(Ctx->Cuda);
     free(Ctx);
     free(Context);




More information about the llvm-commits mailing list