[Beignet] [PATCH] fix utest simd_any with 'export OCL_SIMD_WIDTH=8'

Zhigang Gong zhigang.gong at linux.intel.com
Tue Jun 10 19:50:02 PDT 2014


Use simd width in application level is not good.
I would suggest you to modify the cl kernel to make
it generate same result on both simd8 and simd16.

The __gen_ocl_simd_any()/__gen_ocl_simd_all() should be
used in such an scenario. One basic rule is that one
computing kernel should always get same result no matter
how many simd channels enabled. And this rule is the
fundamental reason why the backend may generate simd16 or
simd8 code for the same kernel.

All the official builtin functions and normal code will
not break the above rule generally. But the simd_any/simd_all
extension may break the rule easily, then if it is the case,
we can say that it is an incorrect usage of simd_any/simd_all.

On Wed, Jun 11, 2014 at 03:27:13AM +0800, Guo Yejun wrote:
> simd_any is a built-in function based on the simd width for the
> hardware instructions generated by the compiler, therefore, the
> utest has to check the result according to the simd width. But,
> currently there is no way to query it from driver, so use genenv
> to get the info in this patch.
> 
> Signed-off-by: Guo Yejun <yejun.guo at intel.com>
> ---
>  utests/compiler_simd_any.cpp | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/utests/compiler_simd_any.cpp b/utests/compiler_simd_any.cpp
> index dcc5ef1..d41cb54 100644
> --- a/utests/compiler_simd_any.cpp
> +++ b/utests/compiler_simd_any.cpp
> @@ -26,10 +26,16 @@ void compiler_simd_any(void)
>  
>    // Compare
>    OCL_MAP_BUFFER(1);
> +
> +  int32_t width = locals[0];
> +  const char* simd_width = getenv("OCL_SIMD_WIDTH");
> +  if (simd_width != NULL)
> +    width = atoi(simd_width);
> +
>    for (int32_t i = 0; i < (int32_t) n; ++i){
>      //printf("%d %d\n", i, ((int *)buf_data[1])[i]);
>      if (i % 2 == 1) {
> -      if (i < (int32_t)locals[0])
> +      if (i < (int32_t)width)
>          OCL_ASSERT(((int *)buf_data[1])[i] == 1);
>        else
>          OCL_ASSERT(((int *)buf_data[1])[i] == 2);
> -- 
> 1.8.3.2
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list