Content-Type: multipart/mixed; boundary="===============7541927801331832745==" MIME-Version: 1.0 From: Li Zhang Subject: [Accel-config] [PATCH RESEND v1 01/14] accel-config/test: Add algorithm to do Zcompress32 Date: Tue, 07 Jun 2022 10:58:21 +0800 Message-ID: <20220607025834.1740551-2-li4.zhang@intel.com> In-Reply-To: 20220607025834.1740551-1-li4.zhang@intel.com To: accel-config@lists.01.org List-ID: --===============7541927801331832745== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add an algorithm to implement Zcompress32, 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 | 45 +++++++++++++++++++++++++++++++++ test/algorithms/iaa_zcompress.h | 1 + 2 files changed, 46 insertions(+) diff --git a/test/algorithms/iaa_zcompress.c b/test/algorithms/iaa_zcompres= s.c index b58a6e6..1126466 100644 --- a/test/algorithms/iaa_zcompress.c +++ b/test/algorithms/iaa_zcompress.c @@ -86,6 +86,51 @@ int iaa_do_zcompress16(void *dst, void *src, int src_len) return dst_len; } = +int iaa_do_zcompress32(void *dst, void *src, int src_len) +{ + int i, j, dst_len =3D 0; + uint32_t *tags; + int num_blocks =3D src_len / IAA_ZCOMPRESS_BLOCK_SIZE; + int remainder_bytes =3D src_len % IAA_ZCOMPRESS_BLOCK_SIZE; + uint32_t *src_ptr =3D (uint32_t *)src; + uint32_t *dst_ptr =3D (uint32_t *)dst; + + for (i =3D 0; i < num_blocks; i++) { + tags =3D dst_ptr; + dst_ptr +=3D 1; + dst_len +=3D 4; + for (j =3D 0; j < (IAA_ZCOMPRESS_BLOCK_SIZE / 4); j++) { + if (*src_ptr !=3D 0) { + *tags |=3D ((uint32_t)1 << j); + *dst_ptr++ =3D *src_ptr; + dst_len +=3D 4; + } + + src_ptr++; + } + } + + if (remainder_bytes) { + tags =3D dst_ptr; + *tags =3D 0xFFFFFFFF; + dst_ptr +=3D 1; + dst_len +=3D 4; + + for (i =3D 0; i < (remainder_bytes / 4); i++) { + if (*src_ptr =3D=3D 0) { + *tags &=3D ~((uint32_t)1 << i); + } else { + *dst_ptr++ =3D *src_ptr; + dst_len +=3D 4; + } + + src_ptr++; + } + } + + return dst_len; +} + int iaa_do_zdecompress16(void *dst, void *src, int src_len) { int i, j, dst_len =3D 0; diff --git a/test/algorithms/iaa_zcompress.h b/test/algorithms/iaa_zcompres= s.h index eb47278..a2b37e9 100644 --- a/test/algorithms/iaa_zcompress.h +++ b/test/algorithms/iaa_zcompress.h @@ -8,5 +8,6 @@ void iaa_zcompress16_randomize_input(void *dst, uint64_t pattern, int len); int iaa_do_zcompress16(void *dst, void *src, int src_len); int iaa_do_zdecompress16(void *dst, void *src, int src_len); +int iaa_do_zcompress32(void *dst, void *src, int src_len); = #endif -- = 2.25.1 --===============7541927801331832745==--