crypto/sha256.c crypto/sha512.c
PATCH 1/1 crypto/sha256.c crypto/sha512.c
Optimized the choice and majority fuctions a bit.
Patch:
http://jlcooke.ca/lkml/faster_sha2.patch
Test suite:
http://jlcooke.ca/lkml/faster_sha2.c
build with:
gcc -O3 -s faster_sha2.c -o faster_sha2
JLC
Signature · 4 lines
http://www.certainkey.com Suite 4560 CTTC 1125 Colonel By Dr. Ottawa ON, K1S 5B6
Quoted 10 lines · Jean-Luc Cooke
Optimized the choice and majority fuctions a bit.
Patch:
http://jlcooke.ca/lkml/faster_sha2.patchTest suite:
http://jlcooke.ca/lkml/faster_sha2.c
build with:
gcc -O3 -sfaster_sha2.c-ofaster_sha2
What kind of performance improvement does this provide?
- James
Signature · 2 lines
James Morris <[email protected]>
If you take a peek in your/Plumb's crypto/md5.c you've reduced the F1() macro to the identical operation as the new Ch() inline function.
It reduces gcc's tenancy to re-load values in functions such like:
(x & y) ^ (~x & z)
(x & y) ^ (x & z) ^ (y & z)
This works out much nicer:
z ^ (x & (y ^ z))
(x & y) | (z & (x | y))
I've seen this in a few .c files (gcc -S blah.c; vim blah.s)
The Ch() and Maj() operations are used a lot in sha256/512.
JLC
Quoted 14 lines · James Morris
Quoted 10 lines · Jean-Luc Cooke
Optimized the choice and majority fuctions a bit.
Patch:
http://jlcooke.ca/lkml/faster_sha2.patchTest suite:
http://jlcooke.ca/lkml/faster_sha2.c
build with:
gcc -O3 -sfaster_sha2.c-ofaster_sha2What kind of performance improvement does this provide?
Signature · 4 lines
http://www.certainkey.com Suite 4560 CTTC 1125 Colonel By Dr. Ottawa ON, K1S 5B6
Quoted 1 line · On Tue, 27 Jan 2004 15:22:25 -0500 Jean-Luc Cooke <[email protected]>…
The
Ch()andMaj()operations are used a lot in sha256/512.
Your analysis is great, but James was really asking for numbers :-)
I updated the faster_sha2.c to include a quick performance test, same URL.
The Ch/sec and Maj/sec can't be easily compared, however instruction count can to some extent.
http://jlcooke.ca/lkml/faster_sha2_x86.s
http://jlcooke.ca/lkml/faster_sha2_ppc.s
http://jlcooke.ca/lkml/faster_sha2_alpha.s
http://jlcooke.ca/lkml/faster_sha2_sparc.s
Hope this helps, I'll know better next time I ask for patch-blessing. :)
JLC
Quoted 11 lines · David S. Miller
Quoted 1 line · On Tue, 27 Jan 2004 15:22:25 -0500 Jean-Luc Cooke <[email protected]>…
The
Ch()andMaj()operations are used a lot in sha256/512.Your analysis is great, but James was really asking for numbers :-) -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 4 lines
http://www.certainkey.com Suite 4560 CTTC 1125 Colonel By Dr. Ottawa ON, K1S 5B6
Humm,
Pardon my ignorance, but does silence mean "yes"?
Didn't see any changes to http://samba.org/~jamesm/crypto/
JLC
Quoted 38 lines · Jean-Luc Cooke
I updated the
faster_sha2.cto include a quick performance test, same URL.The Ch/sec and Maj/sec can't be easily compared, however instruction count can to some extent.
http://jlcooke.ca/lkml/faster_sha2_x86.s
http://jlcooke.ca/lkml/faster_sha2_ppc.s
http://jlcooke.ca/lkml/faster_sha2_alpha.s
http://jlcooke.ca/lkml/faster_sha2_sparc.sHope this helps, I'll know better next time I ask for patch-blessing. :)
JLC
Quoted 11 lines · David S. Miller
Quoted 1 line · On Tue, 27 Jan 2004 15:22:25 -0500 Jean-Luc Cooke <[email protected]>…
The
Ch()andMaj()operations are used a lot in sha256/512.Your analysis is great, but James was really asking for numbers :-) -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/Signature · 9 lines
http://www.certainkey.com Suite 4560 CTTC 1125 Colonel By Dr. Ottawa ON, K1S 5B6 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Signature · 4 lines
http://www.certainkey.com Suite 4560 CTTC 1125 Colonel By Dr. Ottawa ON, K1S 5B6
Quoted 1 line · Jean-Luc Cooke
Pardon my ignorance, but does silence mean "yes"?
No, but the patch looks fine to me and passes the test vectors.
Dave, I've included it below.
- James
Signature · 39 lines
James Morris <[email protected]> diff -Naur linux-2.6.1/crypto/sha256.c linux-2.6.1-patched/crypto/sha256.c --- linux-2.6.1/crypto/sha256.c 2004-01-09 01:59:26.000000000 -0500 +++ linux-2.6.1-patched/crypto/sha256.c 2004-01-27 14:22:00.000000000 -0500 @@ -34,12 +34,12 @@ static inline u32 Ch(u32 x, u32 y, u32 z) { - return ((x & y) ^ (~x & z)); + return z ^ (x & (y ^ z)); } static inline u32 Maj(u32 x, u32 y, u32 z) { - return ((x & y) ^ (x & z) ^ (y & z)); + return (x & y) | (z & (x | y)); } static inline u32 RORu32(u32 x, u32 y) diff -Naur linux-2.6.1/crypto/sha512.c linux-2.6.1-patched/crypto/sha512.c --- linux-2.6.1/crypto/sha512.c 2004-01-09 02:00:03.000000000 -0500 +++ linux-2.6.1-patched/crypto/sha512.c 2004-01-27 14:22:26.000000000 -0500 @@ -34,12 +34,12 @@ static inline u64 Ch(u64 x, u64 y, u64 z) { - return ((x & y) ^ (~x & z)); + return z ^ (x & (y ^ z)); } static inline u64 Maj(u64 x, u64 y, u64 z) { - return ((x & y) ^ (x & z) ^ (y & z)); + return (x & y) | (z & (x | y)); } static inline u64 RORu64(u64 x, u64 y)
David S. Miller
AppliedQuoted 7 lines · On Wed, 28 Jan 2004 17:08:58 -0500 (EST) James Morris <[email protected]>…
Quoted 1 line · Jean-Luc Cooke
Pardon my ignorance, but does silence mean "yes"?
No, but the patch looks fine to me and passes the test vectors.
Dave, I've included it below.
Applied, thanks guys.