qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [v3 1/3] cutils: add avx2 instruction optimization


From: Richard Henderson
Subject: Re: [Qemu-devel] [v3 1/3] cutils: add avx2 instruction optimization
Date: Tue, 8 Dec 2015 08:09:46 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0

On 12/08/2015 04:08 AM, Liang Li wrote:
> +++ b/util/buffer-zero-avx2.c
> @@ -0,0 +1,54 @@
> +#include "qemu-common.h"
> +
> +#if defined CONFIG_IFUNC && defined CONFIG_AVX2
> +#include <immintrin.h>
> +#define AVX2_VECTYPE        __m256i
> +#define AVX2_SPLAT(p)       _mm256_set1_epi8(*(p))
> +#define AVX2_ALL_EQ(v1, v2) \
> +    (_mm256_movemask_epi8(_mm256_cmpeq_epi8(v1, v2)) == 0xFFFFFFFF)
> +#define AVX2_VEC_OR(v1, v2) (_mm256_or_si256(v1, v2))
> +
> +inline bool
> +can_use_buffer_find_nonzero_offset_avx2(const void *buf, size_t len)
> +{
> +    return (len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR
> +                   * sizeof(AVX2_VECTYPE)) == 0
> +            && ((uintptr_t) buf) % sizeof(AVX2_VECTYPE) == 0);
> +}

I'm not keen on adding a new file for this.  You ought to be able to use
__attribute__((target("-mavx2"))) on any compiler that supports the
command-line option.  Which means you can do this all in one file with static
functions.

Nor am I keen on marking a function inline when we know it must be out-of-line
because of the ifunc usage.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]