support __gen_ocl_simd_any and __gen_ocl_simd_all
authorGuo Yejun <yejun.guo@intel.com>
Fri, 18 Apr 2014 05:42:16 +0000 (13:42 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Tue, 22 Apr 2014 03:22:07 +0000 (11:22 +0800)
commitbe73d25fc4bd3e68b94a37e524f7edf4aca53ce3
tree66061a5755266d7e8f83c4ea59d5360fa15cf7b5
parent8f0015e349c1428496a19236c1dd4132ef4554e5
support __gen_ocl_simd_any and __gen_ocl_simd_all

short __gen_ocl_simd_any(short x):
if x in any of the active threads in the same SIMD is not zero,
the return value for all these threads is not zero, otherwise, zero returned.

short __gen_ocl_simd_all(short x):
only if x in all of the active threads in the same SIMD is not zero,
the return value for all these threads is not zero, otherwise, zero returned.

for example:
to check if a special value exists in a global buffer, use one SIMD
to do the searching parallelly, the whole SIMD can stop the task
once the value is found. The key kernel code looks like:

for(; ; ) {
  ...
  if (__gen_ocl_simd_any(...))
    break;   //the whole SIMD stop the searching
}

Signed-off-by: Guo Yejun <yejun.guo@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
backend/src/backend/gen_insn_selection.cpp
backend/src/ir/instruction.hpp
backend/src/ir/instruction.hxx
backend/src/llvm/llvm_gen_backend.cpp
backend/src/llvm/llvm_gen_ocl_function.hxx
backend/src/ocl_stdlib.tmpl.h