summaryrefslogtreecommitdiff
path: root/utests/utest_helper.hpp
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@intel.com>2013-12-11 13:40:51 +0800
committerZhigang Gong <zhigang.gong@intel.com>2013-12-16 09:20:46 +0800
commit625d5aa18446206cd6a00a52d8a2094948fd9d93 (patch)
treed8e71909e55cd012591472b93e5e5825d97df21d /utests/utest_helper.hpp
parent4957110d5238b999c78b382bb1bf92092757447f (diff)
downloadbeignet-625d5aa18446206cd6a00a52d8a2094948fd9d93.tar.gz
Accelerate utest.
For some test cases which include more than one kernel, the current implementation always build the program for a new sub test case. That wastes a lot of time. This patch introduce a new macro MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM which has an extra parameter to specify whether to keep the previous program and avoid the extra build. The normal usage is: MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(fn1, true); MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(fn2, true); MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(fn3, true); MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(fn4, true); MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(fn5, false); The scenario is that the above fn1-5 are included in the same kernel file and we define the sub cases in the same cpp file. We already have some examples of this usage in the compiler_abs.cpp, compiler_abs_diff.cpp compiler_basic_arithmetic.cpp, compiler_vector_load_store.cpp, etc. This patch reduces 2/3 of the utests execution time. v2: should always destroy the program when run one specific test case. Signed-off-by: Zhigang Gong <zhigang.gong@intel.com> Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
Diffstat (limited to 'utests/utest_helper.hpp')
-rw-r--r--utests/utest_helper.hpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp
index 29a21d54..8da9dcbe 100644
--- a/utests/utest_helper.hpp
+++ b/utests/utest_helper.hpp
@@ -65,6 +65,11 @@ extern EGLSurface eglSurface;
OCL_CALL (cl_kernel_init, NAME".cl", NAME, SOURCE, NULL); \
} while (0)
+#define OCL_DESTROY_KERNEL_KEEP_PROGRAM(KEEP_PROGRAM) \
+ do { \
+ cl_kernel_destroy(!(KEEP_PROGRAM)); \
+ } while(0)
+
#define OCL_CREATE_KERNEL_FROM_FILE(FILE_NAME, KERNEL_NAME) \
do { \
OCL_CALL(cl_kernel_init, FILE_NAME".cl", KERNEL_NAME, SOURCE, NULL); \
@@ -199,7 +204,7 @@ extern void cl_buffer_destroy(void);
extern void cl_ocl_destroy(void);
/* Release kernel and program */
-extern void cl_kernel_destroy(void);
+extern void cl_kernel_destroy(bool needDestroyProgram = true);
/* Release everything allocated in cl_test_init */
extern void cl_test_destroy(void);