From 9bb323ca3447421ee30ef26d1e48896d2d80b742 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Wed, 19 Aug 2020 00:13:28 -0500 Subject: arm64: Re-add arm crc32c hw acceleration Use the .arch_extension directive so that a config options and special cflags aren't required. Add a few tests for both the software and hardware implementations --- testapp.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'testapp.c') diff --git a/testapp.c b/testapp.c index f8bd493..47cb103 100644 --- a/testapp.c +++ b/testapp.c @@ -20,6 +20,7 @@ #include "config.h" #include "cache.h" +#include "crc32c.h" #include "hash.h" #include "jenkins_hash.h" #include "stats_prefix.h" @@ -898,6 +899,34 @@ static enum test_return test_issue_92(void) { return TEST_PASS; } +static enum test_return test_crc32c(void) { + uint32_t crc_hw, crc_sw; + + char buffer[256]; + for (int x = 0; x < 256; x++) + buffer[x] = x; + + /* Compare harware to software implementaiton */ + crc_hw = crc32c(0, buffer, 256); + crc_sw = crc32c_sw(0, buffer, 256); + assert(crc_hw == 0x9c44184b); + assert(crc_sw == 0x9c44184b); + + /* Test that passing a CRC in also works */ + crc_hw = crc32c(crc_hw, buffer, 256); + crc_sw = crc32c_sw(crc_sw, buffer, 256); + assert(crc_hw == 0xae10ee5a); + assert(crc_sw == 0xae10ee5a); + + /* Test odd offsets/sizes */ + crc_hw = crc32c(crc_hw, buffer + 1, 256 - 2); + crc_sw = crc32c_sw(crc_sw, buffer + 1, 256 - 2); + assert(crc_hw == 0xed37b906); + assert(crc_sw == 0xed37b906); + + return TEST_PASS; +} + static enum test_return test_issue_102(void) { char buffer[4096]; memset(buffer, ' ', sizeof(buffer)); @@ -2297,6 +2326,7 @@ struct testcase testcases[] = { { "issue_44", test_issue_44 }, { "vperror", test_vperror }, { "issue_101", test_issue_101 }, + { "crc32c", test_crc32c }, /* The following tests all run towards the same server */ { "start_server", start_memcached_server }, { "issue_92", test_issue_92 }, @@ -2363,6 +2393,8 @@ int main(int argc, char **argv) hash = jenkins_hash; stats_prefix_init(':'); + crc32c_init(); + for (num_cases = 0; testcases[num_cases].description; num_cases++) { /* Just counting */ } -- cgit v1.2.1