diff options
author | Zhigang Gong <zhigang.gong@intel.com> | 2013-12-11 13:40:51 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2013-12-16 09:20:46 +0800 |
commit | 625d5aa18446206cd6a00a52d8a2094948fd9d93 (patch) | |
tree | d8e71909e55cd012591472b93e5e5825d97df21d /utests/compiler_abs_diff.cpp | |
parent | 4957110d5238b999c78b382bb1bf92092757447f (diff) | |
download | beignet-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/compiler_abs_diff.cpp')
-rw-r--r-- | utests/compiler_abs_diff.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/utests/compiler_abs_diff.cpp b/utests/compiler_abs_diff.cpp index 71881b17..15a1f90d 100644 --- a/utests/compiler_abs_diff.cpp +++ b/utests/compiler_abs_diff.cpp @@ -183,26 +183,29 @@ template <typename T, typename U> static void compiler_abs_diff_with_type(void) } -#define ABS_TEST_DIFF_TYPE_2(TYPE, CLTYPE, UTYPE) \ +#define ABS_TEST_DIFF_TYPE_2(TYPE, CLTYPE, UTYPE, KEEP_PROGRAM) \ static void compiler_abs_diff_##CLTYPE (void) \ { \ OCL_CALL (cl_kernel_init, "compiler_abs_diff.cl", "compiler_abs_diff_"#CLTYPE, SOURCE, NULL); \ compiler_abs_diff_with_type<TYPE, UTYPE>(); \ } \ - MAKE_UTEST_FROM_FUNCTION(compiler_abs_diff_##CLTYPE); + MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(compiler_abs_diff_##CLTYPE, KEEP_PROGRAM); + +#define ABS_TEST_DIFF_TYPE(TYPE, UTYPE) ABS_TEST_DIFF_TYPE_2(TYPE, TYPE, UTYPE, true) + +#define ABS_TEST_DIFF_TYPE_END(TYPE, UTYPE) ABS_TEST_DIFF_TYPE_2(TYPE, TYPE, UTYPE, false) -#define ABS_TEST_DIFF_TYPE(TYPE, UTYPE) ABS_TEST_DIFF_TYPE_2(TYPE, TYPE, UTYPE) typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; typedef uint64_t ulong64; ABS_TEST_DIFF_TYPE(int, uint) -ABS_TEST_DIFF_TYPE_2(int64_t, long, ulong64) +ABS_TEST_DIFF_TYPE_2(int64_t, long, ulong64, true) ABS_TEST_DIFF_TYPE(short, ushort) ABS_TEST_DIFF_TYPE(char, uchar) ABS_TEST_DIFF_TYPE(uint, uint) -ABS_TEST_DIFF_TYPE_2(ulong64, ulong, ulong64) +ABS_TEST_DIFF_TYPE_2(ulong64, ulong, ulong64, true) ABS_TEST_DIFF_TYPE(ushort, ushort) ABS_TEST_DIFF_TYPE(uchar, uchar) @@ -289,4 +292,4 @@ ABS_TEST_DIFF_TYPE(ushort2, ushort2) ABS_TEST_DIFF_TYPE(ushort3, ushort3) ABS_TEST_DIFF_TYPE(ushort4, ushort4) ABS_TEST_DIFF_TYPE(ushort8, ushort8) -ABS_TEST_DIFF_TYPE(ushort16, ushort16) +ABS_TEST_DIFF_TYPE_END(ushort16, ushort16) |