linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Danny Tsen' <dtsen@linux.ibm.com>,
	"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>
Cc: "herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>,
	"dtsen@us.ibm.com" <dtsen@us.ibm.com>,
	"nayna@linux.ibm.com" <nayna@linux.ibm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"appro@cryptogams.org" <appro@cryptogams.org>,
	"ltcgcw@linux.vnet.ibm.com" <ltcgcw@linux.vnet.ibm.com>,
	"leitao@debian.org" <leitao@debian.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: RE: [PATCH 1/5] An optimized Chacha20 implementation with 8-way unrolling for ppc64le.
Date: Wed, 26 Apr 2023 08:19:17 +0000	[thread overview]
Message-ID: <0bb5f98165c3408fb191488f3cf0f76c@AcuMS.aculab.com> (raw)
In-Reply-To: <20230424184726.2091-2-dtsen@linux.ibm.com>

From: Danny Tsen
> Sent: 24 April 2023 19:47
> 
> Improve overall performance of chacha20 encrypt and decrypt operations
> for Power10 or later CPU.
> 
> Signed-off-by: Danny Tsen <dtsen@linux.ibm.com>
> ---
>  arch/powerpc/crypto/chacha-p10le-8x.S | 842 ++++++++++++++++++++++++++
>  1 file changed, 842 insertions(+)
>  create mode 100644 arch/powerpc/crypto/chacha-p10le-8x.S
...
> +.macro QT_loop_8x
> +	# QR(v0, v4,  v8, v12, v1, v5,  v9, v13, v2, v6, v10, v14, v3, v7, v11, v15)
> +	xxlor	0, 32+25, 32+25
> +	xxlor	32+25, 20, 20
> +	vadduwm 0, 0, 4
> +	vadduwm 1, 1, 5
> +	vadduwm 2, 2, 6
> +	vadduwm 3, 3, 7
> +	  vadduwm 16, 16, 20
> +	  vadduwm 17, 17, 21
> +	  vadduwm 18, 18, 22
> +	  vadduwm 19, 19, 23
> +
> +	  vpermxor 12, 12, 0, 25
> +	  vpermxor 13, 13, 1, 25
> +	  vpermxor 14, 14, 2, 25
> +	  vpermxor 15, 15, 3, 25
> +	  vpermxor 28, 28, 16, 25
> +	  vpermxor 29, 29, 17, 25
> +	  vpermxor 30, 30, 18, 25
> +	  vpermxor 31, 31, 19, 25
> +	xxlor	32+25, 0, 0
> +	vadduwm 8, 8, 12
> +	vadduwm 9, 9, 13
> +	vadduwm 10, 10, 14
> +	vadduwm 11, 11, 15
...

Is it just me or is all this code just complete jibberish?

There really ought to be enough comments so that it is possible
to check that the code is doing something that looks like chacha20
without spending all day tracking register numbers through
hundreds of lines of assembler.

I also wonder how much faster the 8-way unroll is?
On modern cpu with 'out of order' execute (etc) it is
not impossible to get the loop operations 'for free'
because they use execution units that are otherwise idle.

Massive loop unrolling is so 1980's.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


  parent reply	other threads:[~2023-04-26  8:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 18:47 [PATCH 0/5] crypto: Accelerated Chacha20/Poly1305 implementation Danny Tsen
2023-04-24 18:47 ` [PATCH 1/5] An optimized Chacha20 implementation with 8-way unrolling for ppc64le Danny Tsen
2023-04-24 20:40   ` Elliott, Robert (Servers)
2023-04-24 23:07     ` Danny Tsen
2023-04-25 12:02       ` Michael Ellerman
2023-04-25 12:08         ` Danny Tsen
2023-04-26  8:19   ` David Laight [this message]
2023-04-24 18:47 ` [PATCH 2/5] Glue code for optmized Chacha20 implementation " Danny Tsen
2023-04-25  5:37   ` Herbert Xu
2023-04-25  5:40     ` Herbert Xu
2023-04-25  5:41   ` Herbert Xu
2023-04-25 11:53     ` Danny Tsen
2023-04-24 18:47 ` [PATCH 3/5] An optimized Poly1305 implementation with 4-way unrolling " Danny Tsen
2023-04-24 18:47 ` [PATCH 4/5] Glue code for optmized Poly1305 implementation " Danny Tsen
2023-04-25  5:44   ` Herbert Xu
2023-04-25 11:58     ` Danny Tsen
2023-04-24 18:47 ` [PATCH 5/5] Update Kconfig and Makefile Danny Tsen
2023-04-25  5:46   ` Herbert Xu
2023-04-25 12:04     ` Danny Tsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0bb5f98165c3408fb191488f3cf0f76c@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=appro@cryptogams.org \
    --cc=dtsen@linux.ibm.com \
    --cc=dtsen@us.ibm.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=leitao@debian.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=ltcgcw@linux.vnet.ibm.com \
    --cc=nayna@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).