fix assertion when two kernels exist in cl file
authorLu Guanqun <guanqun.lu@intel.com>
Tue, 25 Dec 2012 05:26:55 +0000 (13:26 +0800)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Fri, 29 Mar 2013 11:35:17 +0000 (19:35 +0800)
The root cause is that it fails to increment `currID` when traversing hash map.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
backend/src/backend/program.hpp
kernels/compiler_multiple_kernels.cl [new file with mode: 0644]
utests/CMakeLists.txt
utests/compiler_multiple_kernels.cpp [new file with mode: 0644]
utests/utest_helper.hpp

index 646469b..e0f7dba 100644 (file)
@@ -134,6 +134,7 @@ namespace gbe {
           kernel = pair.second;
           break;
         }
+        currID++;
       }
       return kernel;
     }
diff --git a/kernels/compiler_multiple_kernels.cl b/kernels/compiler_multiple_kernels.cl
new file mode 100644 (file)
index 0000000..d5cea68
--- /dev/null
@@ -0,0 +1,7 @@
+__kernel void first_kernel(void)
+{
+}
+
+__kernel void second_kernel(void)
+{
+}
\ No newline at end of file
index 96409cb..2b52994 100644 (file)
@@ -26,6 +26,12 @@ compiler_shader_toy.cpp
   compiler_lower_return0.cpp
   compiler_lower_return1.cpp
   compiler_lower_return2.cpp
+  compiler_multiple_kernels.cpp
+  compiler_obread.cpp
+  compiler_obwrite.cpp
+  compiler_region.cpp
+  compiler_region0.cpp
+  compiler_region1.cpp
   compiler_short_scatter.cpp
   compiler_sub_bytes.cpp
   compiler_sub_shorts.cpp
diff --git a/utests/compiler_multiple_kernels.cpp b/utests/compiler_multiple_kernels.cpp
new file mode 100644 (file)
index 0000000..09b4349
--- /dev/null
@@ -0,0 +1,8 @@
+#include "utest_helper.hpp"
+
+static void compiler_multiple_kernels(void)
+{
+       OCL_CREATE_KERNEL_FROM_FILE("compiler_multiple_kernels", "first_kernel");
+}
+
+MAKE_UTEST_FROM_FUNCTION(compiler_multiple_kernels);
\ No newline at end of file
index 5018433..e1f2395 100644 (file)
     OCL_CALL (cl_kernel_init, NAME".cl", NAME, SOURCE); \
   } while (0)
 
+#define OCL_CREATE_KERNEL_FROM_FILE(FILE_NAME, KERNEL_NAME) \
+  do { \
+    OCL_CALL(cl_kernel_init, FILE_NAME".cl", KERNEL_NAME, SOURCE); \
+  } while (0)
+
 #define OCL_CREATE_BUFFER(BUFFER, FLAGS, SIZE, DATA) \
   do { \
     cl_int status; \