Clear atomic dst buffer to fix atomic random fail.
authorYang Rong <rong.r.yang@intel.com>
Mon, 1 Jul 2013 05:38:48 +0000 (13:38 +0800)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Mon, 1 Jul 2013 08:50:38 +0000 (16:50 +0800)
Because atomic's address used as src and dst, so need to clear this address.

Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
utests/compiler_atomic_functions.cpp

index 71e8384..571e0c6 100644 (file)
@@ -1,6 +1,7 @@
 #include "utest_helper.hpp"
 #include <cmath>
 #include <algorithm>
+#include <string.h>
 
 #define GROUP_NUM 16
 #define LOCAL_SIZE 64
@@ -71,6 +72,10 @@ static void compiler_atomic_functions(void)
   OCL_SET_ARG(1, 16 * sizeof(int), NULL);
   OCL_SET_ARG(2, sizeof(cl_mem), &buf[1]);
 
+  OCL_MAP_BUFFER(0);
+  memset(buf_data[0], 0, 16 * sizeof(int));
+  OCL_UNMAP_BUFFER(0);
+
   OCL_MAP_BUFFER(1);
   for (uint32_t i = 0; i < locals[0]; ++i)
       cpu_src[i] = ((int*)buf_data[1])[i] = rand() & 0xff;