[Beignet] [PATCH newRT] Fix some resource leak point in utests.

junyan.he at inbox.com junyan.he at inbox.com
Thu Mar 23 08:03:56 UTC 2017


From: Junyan He <junyan.he at intel.com>

Signed-off-by: Junyan He <junyan.he at intel.com>
---
 utests/compiler_copy_image_1d.cpp   | 1 +
 utests/enqueue_built_in_kernels.cpp | 1 +
 utests/sub_buffer.cpp               | 2 +-
 utests/vload_bench.cpp              | 2 ++
 4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/utests/compiler_copy_image_1d.cpp b/utests/compiler_copy_image_1d.cpp
index 6599d30..e8666ca 100644
--- a/utests/compiler_copy_image_1d.cpp
+++ b/utests/compiler_copy_image_1d.cpp
@@ -47,6 +47,7 @@ static void compiler_copy_image_1d(void)
   }
   OCL_UNMAP_BUFFER_GTT(0);
   OCL_UNMAP_BUFFER_GTT(1);
+  OCL_CALL(clReleaseSampler, sampler);
 }
 
 MAKE_UTEST_FROM_FUNCTION(compiler_copy_image_1d);
diff --git a/utests/enqueue_built_in_kernels.cpp b/utests/enqueue_built_in_kernels.cpp
index 52b8848..2afbabd 100644
--- a/utests/enqueue_built_in_kernels.cpp
+++ b/utests/enqueue_built_in_kernels.cpp
@@ -14,6 +14,7 @@ void enqueue_built_in_kernels(void)
   OCL_ASSERT(ret_sz == built_in_kernels_size);
   cl_program built_in_prog = clCreateProgramWithBuiltInKernels(ctx, 1, &device, built_in_kernel_names, &err);
   OCL_ASSERT(built_in_prog != NULL);
+  clReleaseProgram(built_in_prog);
 }
 
 MAKE_UTEST_FROM_FUNCTION(enqueue_built_in_kernels);
diff --git a/utests/sub_buffer.cpp b/utests/sub_buffer.cpp
index 04cfee7..2bb78f2 100644
--- a/utests/sub_buffer.cpp
+++ b/utests/sub_buffer.cpp
@@ -67,7 +67,7 @@ void sub_buffer_check(void)
                     OCL_ASSERT(0);
                 }
             }
-
+            clReleaseMemObject(sub_buf);
         }
     }
 
diff --git a/utests/vload_bench.cpp b/utests/vload_bench.cpp
index 44c1dba..654c838 100644
--- a/utests/vload_bench.cpp
+++ b/utests/vload_bench.cpp
@@ -36,6 +36,7 @@ static double vload_bench(const char *kernelFunc, uint32_t N, uint32_t offset, b
     double elapsed = (end.tv_sec - start.tv_sec) * 1e6 + (end.tv_usec - start.tv_usec);
     double bandwidth = (globals[0] * (N_ITERATIONS) * sizeof(T) * N) / (elapsed * 1000.);
     printf("\t%2.1fGB/S\n", bandwidth);
+    cl_buffer_destroy();
     return bandwidth;
   } else {
     // Check result
@@ -44,6 +45,7 @@ static double vload_bench(const char *kernelFunc, uint32_t N, uint32_t offset, b
     for (uint32_t i = 0; i < globals[0]; ++i) {
       OCL_ASSERT((uint32_t)(((T*)buf_data[0])[i + offset]) == ((uint32_t*)buf_data[1])[i]);
     }
+    cl_buffer_destroy();
     return 0;
   }
 }
-- 
2.7.4



More information about the Beignet mailing list