ARM NEON Salsa20/12 in build and selftest. Almost 2X speedup on a Raspberry Pi.

This commit is contained in:
Adam Ierymenko 2017-04-19 23:49:26 +00:00
parent 8e1ac9fb0c
commit a376bcc654
3 changed files with 42 additions and 2 deletions

View file

@ -57,6 +57,9 @@
#ifdef ZT_USE_X64_ASM_SALSA2012
#include "ext/x64-salsa2012-asm/salsa2012.h"
#endif
#ifdef ZT_USE_ARM32_NEON_ASM_SALSA2012
#include "ext/arm32-neon-salsa2012-asm/salsa2012.h"
#endif
#ifdef __WINDOWS__
#include <tchar.h>
@ -215,7 +218,7 @@ static int testCrypto()
double bytes = 0.0;
uint64_t start = OSUtils::now();
for(unsigned int i=0;i<200;++i) {
zt_salsa2012_amd64_xmm6(bb, 1234567, s20TV0Iv, s20TV0Key);
zt_salsa2012_amd64_xmm6(bb,1234567,s20TV0Iv,s20TV0Key);
bytes += 1234567.0;
}
uint64_t end = OSUtils::now();
@ -224,6 +227,24 @@ static int testCrypto()
}
#endif
#ifdef ZT_USE_ARM32_NEON_ASM_SALSA2012
if (zt_arm_has_neon()) {
std::cout << "[crypto] Benchmarking Salsa20/12 fast arm32/neon ASM... "; std::cout.flush();
{
unsigned char *bb = (unsigned char *)::malloc(1234567);
double bytes = 0.0;
uint64_t start = OSUtils::now();
for(unsigned int i=0;i<200;++i) {
zt_salsa2012_armneon3_xor(bb,(const unsigned char *)0,1234567,s20TV0Iv,s20TV0Key);
bytes += 1234567.0;
}
uint64_t end = OSUtils::now();
std::cout << ((bytes / 1048576.0) / ((double)(end - start) / 1024.0)) << " MiB/second" << std::endl;
::free((void *)bb);
}
}
#endif
std::cout << "[crypto] Benchmarking Salsa20/20... "; std::cout.flush();
{
unsigned char *bb = (unsigned char *)::malloc(1234567);