Thread (11 messages) 11 messages, 6 authors, 2021-11-15

RE: [RFC] x86/csum: rewrite csum_partial()

From: David Laight <hidden>
Date: 2021-11-14 14:12:38

From: David Laight
Sent: 14 November 2021 13:07
..
If you aren't worried (too much) about cpu before Bradwell then IIRC
this loop gets close to 8 bytes/clock:

+               "10:    jecxz 20f\n"
+               "       adc   (%[buff], %[len]), %[sum]\n"
+               "       adc   8(%[buff], %[len]), %[sum]\n"
+               "       lea   16(%[len]), %[tmp]\n"
+               "       jmp   10b\n"
+               " 20:"
It is even possible a loop based on:
	10:	adc	(%[buff], %[len], 8), %sum
		inc	%[len]
		jnz	10b
will run at 8 bytes per clock on very recent Intel cpu.
The 'adc' needs P06 and P23, the 'inc' P0156 and the
'jnz' P6 (predicted taken) (on Broadwell and probably later).
(The 'inc' and 'jnz' might alse be fusable to a single P6 u-op.)

Using 'lea' instead of 'inc' constrains it to P15.
That might actually generate better scheduling since it
is guaranteed to 'miss' the 'adc'.

So if the right ports are selected it is possible to
execute all the instructions in parallel.

It certainly isn't necessary to unroll the loop any more
than two reads for Bradwell onwards.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help