Content-Type: multipart/mixed; boundary="===============2910260215413374195==" MIME-Version: 1.0 From: Li Zhang Subject: [Accel-config] [PATCH v1 03/11] accel-config/test: Add algorithm to generate random data for Zcompress16 Date: Tue, 17 May 2022 18:48:25 +0800 Message-ID: <20220517104833.1085245-4-li4.zhang@intel.com> In-Reply-To: 20220517104833.1085245-1-li4.zhang@intel.com To: accel-config@lists.01.org List-ID: --===============2910260215413374195== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add new file iaa_zcompress.c and iaa_zcompress.h with an algorithm to generate random input data for operation Zcompress16, add new files into Makefile for compiling. Signed-off-by: Li Zhang --- test/Makefile.am | 2 +- test/algorithms/iaa_zcompress.c | 37 +++++++++++++++++++++++++++++++++ test/algorithms/iaa_zcompress.h | 10 +++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 test/algorithms/iaa_zcompress.c create mode 100644 test/algorithms/iaa_zcompress.h diff --git a/test/Makefile.am b/test/Makefile.am index 07f8d24..e9a7ddd 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -38,5 +38,5 @@ libaccfg_LDADD =3D $(LIBACCFG_LIB) $(UUID_LIBS) dsa_test_SOURCES =3D dsa_test.c dsa.c dsa_prep.c accel_test.c dsa_test_LDADD =3D $(LIBACCFG_LIB) $(UUID_LIBS) = -iaa_test_SOURCES =3D iaa_test.c iaa.c iaa_prep.c accel_test.c algorithms/i= aa_crc64.c algorithms/iaa_crc64.h +iaa_test_SOURCES =3D iaa_test.c iaa.c iaa_prep.c accel_test.c algorithms/i= aa_crc64.c algorithms/iaa_zcompress.c iaa_test_LDADD =3D $(LIBACCFG_LIB) $(UUID_LIBS) diff --git a/test/algorithms/iaa_zcompress.c b/test/algorithms/iaa_zcompres= s.c new file mode 100644 index 0000000..5ee8ff7 --- /dev/null +++ b/test/algorithms/iaa_zcompress.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2019 Intel Corporation. All rights reserved. */ +#include +#include +#include +#include +#include "algorithms/iaa_zcompress.h" + +static int iaa_zcompress_get_random_value(void) +{ + static int extra_seed; + + srand(time(NULL) + (extra_seed++)); + return rand(); +} + +static uint16_t iaa_zcompress16_get_word_pattern(uint64_t pattern) +{ + uint16_t word_pattern =3D 0; + int position =3D (iaa_zcompress_get_random_value() % 4); + + word_pattern =3D (uint16_t)((pattern & (0xFFFF << (16 * position))) >> (1= 6 * position)); + return word_pattern; +} + +void iaa_zcompress16_randomize_input(void *dst, uint64_t pattern, int len) +{ + int i; + int num_words =3D len / 2; + + for (i =3D 0; i < num_words; i++) { + if (iaa_zcompress_get_random_value() % 2) + ((uint16_t *)dst)[i] =3D iaa_zcompress16_get_word_pattern(pattern); + else + ((uint16_t *)dst)[i] =3D 0; + } +} diff --git a/test/algorithms/iaa_zcompress.h b/test/algorithms/iaa_zcompres= s.h new file mode 100644 index 0000000..b567ac0 --- /dev/null +++ b/test/algorithms/iaa_zcompress.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright(c) 2019 Intel Corporation. All rights reserved. */ +#ifndef _IAA_ZCOMPRESS_H_ +#define _IAA_ZCOMPRESS_H_ + +#include + +void iaa_zcompress16_randomize_input(void *dst, uint64_t pattern, int len); + +#endif -- = 2.25.1 --===============2910260215413374195==--