Re: [PATCH v1] x86/lib: Optimize 8x loop and memory clobbers in csum_partial.c
From: Noah Goldstein
Date: Fri Nov 26 2021 - 15:41:04 EST
On Fri, Nov 26, 2021 at 2:07 PM Eric Dumazet <edumazet@xxxxxxxxxx> wrote:
>
> On Fri, Nov 26, 2021 at 11:50 AM Noah Goldstein <goldstein.w.n@xxxxxxxxx> wrote:
> >
> > Bright :) but it will need a BMI support check.
>
> Yes, probably not worth the pain.
Making a V2 for my patch with your optimization for the loop case. Do you think
1 or 2 accum for the 32 byte case?
>
> >
> > I actually get better performance in hyperthread benchmarks with 2 accum:
> >
> > Used:
> >
> > u64 res;
> > temp64 = (__force uint64_t)sum;
> > asm("movq 0*8(%[src]),%[res]\n\t"
> > "addq 1*8(%[src]),%[res]\n\t"
> > "adcq 2*8(%[src]),%[res]\n\t"
> > "adcq $0, %[res]\n"
> > "addq 3*8(%[src]),%[temp64]\n\t"
> > "adcq 4*8(%[src]),%[temp64]\n\t"
> > "adcq %[res], %[temp64]\n\t"
> > "mov %k[temp64],%k[res]\n\t"
> > "rorx $32,%[temp64],%[temp64]\n\t"
> > "adcl %k[temp64],%k[res]\n\t"
> > "adcl $0,%k[res]"
> > : [temp64] "+r"(temp64), [res] "=&r"(res)
> > : [src] "r"(buff)
> > : "memory");
> > return (__force __wsum)res;
> >
> > w/ hyperthread:
> > size, 2acc lat, 1acc lat, 2acc tput, 1acc tput
> > 40, 6.511, 7.863, 6.177, 6.157
> >
> > w/o hyperthread:
> > size, 2acc lat, 1acc lat, 2acc tput, 1acc tput
> > 40, 5.577, 6.764, 3.150, 3.210