summaryrefslogtreecommitdiff
path: root/utests/compiler_if_else.cpp
diff options
context:
space:
mode:
authorRuiling Song <ruiling.song@intel.com>2017-04-06 19:46:35 +0800
committerYang Rong <rong.r.yang@intel.com>2017-05-04 19:08:54 +0800
commitb88e76f0508503110cae6456a92383d2e1a42617 (patch)
tree961e0171482badb08f1e094095f89cf86047f4dd /utests/compiler_if_else.cpp
parent75c6b5e8883a5825a77be26899f9a1f002604307 (diff)
downloadbeignet-b88e76f0508503110cae6456a92383d2e1a42617.tar.gz
utest: modify compiler_if_else to not rely on compiler behaviour.
the test case modify src as well as dst. and it introduce cross workitem memory dependency in dst[id] = src[id+1]; The compiler may order 'then' and 'else' block not as written. If compiler order the else block first. src[3+1] will be modified in else part. And the utest will get wrong result. If user want to get the old behaviour, It should use two if-then and order them as required. Signed-off-by: Ruiling Song <ruiling.song@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'utests/compiler_if_else.cpp')
-rw-r--r--utests/compiler_if_else.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/utests/compiler_if_else.cpp b/utests/compiler_if_else.cpp
index e38b23ff..d65ecd37 100644
--- a/utests/compiler_if_else.cpp
+++ b/utests/compiler_if_else.cpp
@@ -21,43 +21,38 @@ static void compiler_if_else(void)
OCL_NDRANGE(1);
// First control flow
- OCL_MAP_BUFFER(0);
OCL_MAP_BUFFER(1);
for (uint32_t i = 0; i < 16; ++i) {
OCL_ASSERT(((int32_t*)buf_data[1])[i] == 2);
- OCL_ASSERT(((int32_t*)buf_data[0])[i] == 1);
}
+ OCL_UNMAP_BUFFER(1);
// Second control flow
+ OCL_MAP_BUFFER(0);
for (uint32_t i = 0; i < n; ++i) ((int32_t*)buf_data[0])[i] = -1;
OCL_UNMAP_BUFFER(0);
- OCL_UNMAP_BUFFER(1);
OCL_NDRANGE(1);
- OCL_MAP_BUFFER(0);
OCL_MAP_BUFFER(1);
for (uint32_t i = 0; i < 16; ++i) {
OCL_ASSERT(((int32_t*)buf_data[1])[i] == -2);
- OCL_ASSERT(((int32_t*)buf_data[0])[i] == 2);
}
+ OCL_UNMAP_BUFFER(1);
// Third control flow
+ OCL_MAP_BUFFER(0);
for (uint32_t i = 0; i < 4; ++i) ((int32_t*)buf_data[0])[i] = 2;
for (uint32_t i = 4; i < n; ++i) ((int32_t*)buf_data[0])[i] = -1;
OCL_UNMAP_BUFFER(0);
- OCL_UNMAP_BUFFER(1);
OCL_NDRANGE(1);
- OCL_MAP_BUFFER(0);
OCL_MAP_BUFFER(1);
for (uint32_t i = 0; i < 3; ++i) {
OCL_ASSERT(((int32_t*)buf_data[1])[i] == 2);
- OCL_ASSERT(((int32_t*)buf_data[0])[i] == 1);
}
OCL_ASSERT(((int32_t*)buf_data[1])[3] == -1);
- OCL_ASSERT(((int32_t*)buf_data[0])[3] == 1);
for (uint32_t i = 4; i < 16; ++i) {
OCL_ASSERT(((int32_t*)buf_data[1])[i] == -2);
- OCL_ASSERT(((int32_t*)buf_data[0])[i] == 2);
}
+ OCL_UNMAP_BUFFER(1);
}
MAKE_UTEST_FROM_FUNCTION(compiler_if_else);