summaryrefslogtreecommitdiff
path: root/utests/compiler_basic_arithmetic.cpp
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/compiler_basic_arithmetic.cpp
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/compiler_basic_arithmetic.cpp')
-rw-r--r--utests/compiler_basic_arithmetic.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/utests/compiler_basic_arithmetic.cpp b/utests/compiler_basic_arithmetic.cpp
index dcdd0849..0e5ec41a 100644
--- a/utests/compiler_basic_arithmetic.cpp
+++ b/utests/compiler_basic_arithmetic.cpp
@@ -61,52 +61,56 @@ std::cout <<"kernel name: " << kernel_name << std::endl;
buf_data[0] = buf_data[1] = NULL;
}
-#define DECL_TEST_SUB(type, alias) \
+#define DECL_TEST_SUB(type, alias, keep_program) \
static void compiler_sub_ ##alias(void)\
{\
test_exec<type, TEST_OP_SUB>("compiler_sub_" # alias);\
}\
-MAKE_UTEST_FROM_FUNCTION(compiler_sub_ ## alias)
+MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(compiler_sub_ ## alias, keep_program)
-#define DECL_TEST_ADD(type, alias) \
+#define DECL_TEST_ADD(type, alias, keep_program) \
static void compiler_add_ ##alias(void)\
{\
test_exec<type, TEST_OP_ADD>("compiler_add_" # alias);\
}\
-MAKE_UTEST_FROM_FUNCTION(compiler_add_ ## alias)
+MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(compiler_add_ ## alias, keep_program)
-#define DECL_TEST_MUL(type, alias) \
+#define DECL_TEST_MUL(type, alias, keep_program) \
static void compiler_mul_ ##alias(void)\
{\
test_exec<type, TEST_OP_MUL>("compiler_mul_" # alias);\
}\
-MAKE_UTEST_FROM_FUNCTION(compiler_mul_ ## alias)
+MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(compiler_mul_ ## alias, keep_program)
-#define DECL_TEST_DIV(type, alias) \
+#define DECL_TEST_DIV(type, alias, keep_program) \
static void compiler_div_ ##alias(void)\
{\
test_exec<type, TEST_OP_DIV>("compiler_div_" # alias);\
}\
-MAKE_UTEST_FROM_FUNCTION(compiler_div_ ## alias)
+MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(compiler_div_ ## alias, keep_program)
-#define DECL_TEST_REM(type, alias) \
+#define DECL_TEST_REM(type, alias, keep_program) \
static void compiler_rem_ ##alias(void)\
{\
test_exec<type, TEST_OP_REM>("compiler_rem_" # alias);\
}\
-MAKE_UTEST_FROM_FUNCTION(compiler_rem_ ## alias)
+MAKE_UTEST_FROM_FUNCTION_KEEP_PROGRAM(compiler_rem_ ## alias, keep_program)
-#define DECL_TEST_FOR_ALL_TYPE(op)\
-DECL_TEST_##op(int8_t, char) \
-DECL_TEST_##op(uint8_t, uchar) \
-DECL_TEST_##op(int16_t, short) \
-DECL_TEST_##op(uint16_t, ushort) \
-DECL_TEST_##op(int32_t, int) \
-DECL_TEST_##op(uint32_t, uint)
+#define _DECL_TEST_FOR_ALL_TYPE(op, keep_program) \
+DECL_TEST_##op(int8_t, char, true) \
+DECL_TEST_##op(uint8_t, uchar, true) \
+DECL_TEST_##op(int16_t, short, true) \
+DECL_TEST_##op(uint16_t, ushort, true) \
+DECL_TEST_##op(int32_t, int, true) \
+DECL_TEST_##op(uint32_t, uint, keep_program)
+
+#define DECL_TEST_FOR_ALL_TYPE(op) _DECL_TEST_FOR_ALL_TYPE(op, true)
+
+#define DECL_TEST_FOR_ALL_TYPE_END(op) _DECL_TEST_FOR_ALL_TYPE(op, false)
DECL_TEST_FOR_ALL_TYPE(SUB)
DECL_TEST_FOR_ALL_TYPE(ADD)
DECL_TEST_FOR_ALL_TYPE(MUL)
DECL_TEST_FOR_ALL_TYPE(DIV)
-DECL_TEST_FOR_ALL_TYPE(REM)
+DECL_TEST_FOR_ALL_TYPE_END(REM)
#undef DECL_TEST_FOR_ALL_TYPE