Content-Type: multipart/mixed; boundary="===============4104109528242229743==" MIME-Version: 1.0 From: Li Zhang Subject: [Accel-config] [PATCH v1 04/11] accel-config/test: Add algorithm to do Zcompress16 Date: Tue, 17 May 2022 18:48:26 +0800 Message-ID: <20220517104833.1085245-5-li4.zhang@intel.com> In-Reply-To: 20220517104833.1085245-1-li4.zhang@intel.com To: accel-config@lists.01.org List-ID: --===============4104109528242229743== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add an algorithm to implement Zcompress16, it is used to generate a reference data for comparing with the result from IAA hardware. Signed-off-by: Li Zhang --- test/algorithms/iaa_zcompress.c | 50 +++++++++++++++++++++++++++++++++ test/algorithms/iaa_zcompress.h | 1 + 2 files changed, 51 insertions(+) diff --git a/test/algorithms/iaa_zcompress.c b/test/algorithms/iaa_zcompres= s.c index 5ee8ff7..a560918 100644 --- a/test/algorithms/iaa_zcompress.c +++ b/test/algorithms/iaa_zcompress.c @@ -6,6 +6,8 @@ #include #include "algorithms/iaa_zcompress.h" = +#define IAA_ZCOMPRESS_BLOCK_SIZE (128) + static int iaa_zcompress_get_random_value(void) { static int extra_seed; @@ -35,3 +37,51 @@ void iaa_zcompress16_randomize_input(void *dst, uint64_t= pattern, int len) ((uint16_t *)dst)[i] =3D 0; } } + +int iaa_do_zcompress16(void *dst, void *src, int src_len) +{ + int i, j, dst_len =3D 0; + uint16_t *tags; + int num_blocks =3D src_len / IAA_ZCOMPRESS_BLOCK_SIZE; + int remainder_bytes =3D src_len % IAA_ZCOMPRESS_BLOCK_SIZE; + uint16_t *src_ptr =3D (uint16_t *)src; + uint16_t *dst_ptr =3D (uint16_t *)dst; + + for (i =3D 0; i < num_blocks; i++) { + tags =3D dst_ptr; + dst_ptr +=3D 4; + dst_len +=3D 8; + for (j =3D 0; j < (IAA_ZCOMPRESS_BLOCK_SIZE / 2); j++) { + if (*src_ptr !=3D 0) { + tags[j / 16] |=3D ((uint16_t)1 << (j % 16)); + *dst_ptr++ =3D *src_ptr; + dst_len +=3D 2; + } + + src_ptr++; + } + } + + if (remainder_bytes) { + tags =3D dst_ptr; + tags[0] =3D 0xFFFF; + tags[1] =3D 0xFFFF; + tags[2] =3D 0xFFFF; + tags[3] =3D 0xFFFF; + dst_ptr +=3D 4; + dst_len +=3D 8; + + for (i =3D 0; i < (remainder_bytes / 2); i++) { + if (*src_ptr =3D=3D 0) { + tags[i / 16] &=3D ~((uint16_t)1 << (i % 16)); + } else { + *dst_ptr++ =3D *src_ptr; + dst_len +=3D 2; + } + + src_ptr++; + } + } + + return dst_len; +} diff --git a/test/algorithms/iaa_zcompress.h b/test/algorithms/iaa_zcompres= s.h index b567ac0..00b3685 100644 --- a/test/algorithms/iaa_zcompress.h +++ b/test/algorithms/iaa_zcompress.h @@ -6,5 +6,6 @@ #include = void iaa_zcompress16_randomize_input(void *dst, uint64_t pattern, int len); +int iaa_do_zcompress16(void *dst, void *src, int src_len); = #endif -- = 2.25.1 --===============4104109528242229743==--