mirror of
https://github.com/intel/isa-l.git
synced 2024-12-12 09:23:50 +01:00
include: reformat using new code style
Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>
This commit is contained in:
parent
55fbfabfc6
commit
fa5b8baf84
@ -3,16 +3,16 @@
|
||||
|
||||
#ifdef __USER_LABEL_PREFIX__
|
||||
#define CONCAT1(a, b) CONCAT2(a, b)
|
||||
#define CONCAT2(a, b) a ## b
|
||||
#define cdecl(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
|
||||
#define CONCAT2(a, b) a##b
|
||||
#define cdecl(x) CONCAT1(__USER_LABEL_PREFIX__, x)
|
||||
#else
|
||||
#define cdecl(x) x
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define ASM_DEF_RODATA .section __TEXT,__const
|
||||
#define ASM_DEF_RODATA .section __TEXT, __const
|
||||
#else
|
||||
#define ASM_DEF_RODATA .section .rodata
|
||||
#define ASM_DEF_RODATA .section.rodata
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -27,13 +27,11 @@
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* @file crc.h
|
||||
* @brief CRC functions.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _CRC_H_
|
||||
#define _CRC_H_
|
||||
|
||||
@ -43,7 +41,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Multi-binary functions */
|
||||
|
||||
/**
|
||||
@ -54,12 +51,11 @@ extern "C" {
|
||||
*
|
||||
* @returns 16 bit CRC
|
||||
*/
|
||||
uint16_t crc16_t10dif(
|
||||
uint16_t init_crc, //!< initial CRC value, 16 bits
|
||||
uint16_t
|
||||
crc16_t10dif(uint16_t init_crc, //!< initial CRC value, 16 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC and copy T10 standard, runs appropriate version.
|
||||
@ -68,13 +64,12 @@ uint16_t crc16_t10dif(
|
||||
*
|
||||
* @returns 16 bit CRC
|
||||
*/
|
||||
uint16_t crc16_t10dif_copy(
|
||||
uint16_t init_crc, //!< initial CRC value, 16 bits
|
||||
uint16_t
|
||||
crc16_t10dif_copy(uint16_t init_crc, //!< initial CRC value, 16 bits
|
||||
uint8_t *dst, //!< buffer destination for copy
|
||||
uint8_t *src, //!< buffer source to crc + copy
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from the IEEE standard, runs appropriate version.
|
||||
@ -96,11 +91,11 @@ uint16_t crc16_t10dif_copy(
|
||||
* @returns 32 bit CRC
|
||||
*/
|
||||
|
||||
uint32_t crc32_ieee(
|
||||
uint32_t init_crc, //!< initial CRC value, 32 bits
|
||||
uint32_t
|
||||
crc32_ieee(uint32_t init_crc, //!< initial CRC value, 32 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate the customized CRC
|
||||
@ -124,12 +119,11 @@ uint32_t crc32_ieee(
|
||||
*
|
||||
* @returns 32 bit CRC
|
||||
*/
|
||||
uint32_t crc32_gzip_refl(
|
||||
uint32_t init_crc, //!< initial CRC value, 32 bits
|
||||
uint32_t
|
||||
crc32_gzip_refl(uint32_t init_crc, //!< initial CRC value, 32 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief ISCSI CRC function, runs appropriate version.
|
||||
@ -139,12 +133,11 @@ uint32_t crc32_gzip_refl(
|
||||
*
|
||||
* @returns 32 bit CRC
|
||||
*/
|
||||
unsigned int crc32_iscsi(
|
||||
unsigned char *buffer, //!< buffer to calculate CRC on
|
||||
unsigned int
|
||||
crc32_iscsi(unsigned char *buffer, //!< buffer to calculate CRC on
|
||||
int len, //!< buffer length in bytes
|
||||
unsigned int init_crc //!< initial CRC value
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
/* Base functions */
|
||||
|
||||
@ -152,45 +145,42 @@ unsigned int crc32_iscsi(
|
||||
* @brief ISCSI CRC function, baseline version
|
||||
* @returns 32 bit CRC
|
||||
*/
|
||||
unsigned int crc32_iscsi_base(
|
||||
unsigned char *buffer, //!< buffer to calculate CRC on
|
||||
unsigned int
|
||||
crc32_iscsi_base(unsigned char *buffer, //!< buffer to calculate CRC on
|
||||
int len, //!< buffer length in bytes
|
||||
unsigned int crc_init //!< initial CRC value
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from the T10 standard, runs baseline version
|
||||
* @returns 16 bit CRC
|
||||
*/
|
||||
uint16_t crc16_t10dif_base(
|
||||
uint16_t seed, //!< initial CRC value, 16 bits
|
||||
uint16_t
|
||||
crc16_t10dif_base(uint16_t seed, //!< initial CRC value, 16 bits
|
||||
uint8_t *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC and copy T10 standard, runs baseline version.
|
||||
* @returns 16 bit CRC
|
||||
*/
|
||||
uint16_t crc16_t10dif_copy_base(
|
||||
uint16_t init_crc, //!< initial CRC value, 16 bits
|
||||
uint16_t
|
||||
crc16_t10dif_copy_base(uint16_t init_crc, //!< initial CRC value, 16 bits
|
||||
uint8_t *dst, //!< buffer destination for copy
|
||||
uint8_t *src, //!< buffer source to crc + copy
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from the IEEE standard, runs baseline version
|
||||
* @returns 32 bit CRC
|
||||
*/
|
||||
uint32_t crc32_ieee_base(
|
||||
uint32_t seed, //!< initial CRC value, 32 bits
|
||||
uint32_t
|
||||
crc32_ieee_base(uint32_t seed, //!< initial CRC value, 32 bits
|
||||
uint8_t *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate the customized CRC
|
||||
@ -198,12 +188,11 @@ uint32_t crc32_ieee_base(
|
||||
* runs baseline version
|
||||
* @returns 32 bit CRC
|
||||
*/
|
||||
uint32_t crc32_gzip_refl_base(
|
||||
uint32_t seed, //!< initial CRC value, 32 bits
|
||||
uint32_t
|
||||
crc32_gzip_refl_base(uint32_t seed, //!< initial CRC value, 32 bits
|
||||
uint8_t *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
147
include/crc64.h
147
include/crc64.h
@ -27,13 +27,11 @@
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* @file crc64.h
|
||||
* @brief CRC64 functions.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _CRC64_H_
|
||||
#define _CRC64_H_
|
||||
|
||||
@ -43,7 +41,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Multi-binary functions */
|
||||
|
||||
/**
|
||||
@ -54,11 +51,11 @@ extern "C" {
|
||||
* selects the appropriate version at runtime.
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_ecma_refl(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_ecma_refl(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from ECMA-182 standard in normal format, runs
|
||||
@ -68,11 +65,11 @@ uint64_t crc64_ecma_refl(
|
||||
* selects the appropriate version at runtime.
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_ecma_norm(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_ecma_norm(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from ISO standard in reflected format, runs
|
||||
@ -82,11 +79,11 @@ uint64_t crc64_ecma_norm(
|
||||
* selects the appropriate version at runtime.
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_iso_refl(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_iso_refl(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from ISO standard in normal format, runs
|
||||
@ -96,11 +93,11 @@ uint64_t crc64_iso_refl(
|
||||
* selects the appropriate version at runtime.
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_iso_norm(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_iso_norm(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Jones" coefficients in reflected format, runs
|
||||
@ -110,11 +107,11 @@ uint64_t crc64_iso_norm(
|
||||
* selects the appropriate version at runtime.
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_jones_refl(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_jones_refl(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Jones" coefficients in normal format, runs
|
||||
@ -124,11 +121,11 @@ uint64_t crc64_jones_refl(
|
||||
* selects the appropriate version at runtime.
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_jones_norm(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_jones_norm(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Rocksoft" coefficients in reflected format, runs
|
||||
@ -138,11 +135,11 @@ uint64_t crc64_jones_norm(
|
||||
* selects the appropriate version at runtime.
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_rocksoft_refl(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_rocksoft_refl(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Rocksoft" coefficients in normal format, runs
|
||||
@ -152,11 +149,11 @@ uint64_t crc64_rocksoft_refl(
|
||||
* selects the appropriate version at runtime.
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_rocksoft_norm(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_rocksoft_norm(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/* Arch specific versions */
|
||||
|
||||
@ -167,11 +164,11 @@ uint64_t crc64_rocksoft_norm(
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
|
||||
uint64_t crc64_ecma_refl_by8(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_ecma_refl_by8(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from ECMA-182 standard in normal format.
|
||||
@ -180,31 +177,31 @@ uint64_t crc64_ecma_refl_by8(
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
|
||||
uint64_t crc64_ecma_norm_by8(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_ecma_norm_by8(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from ECMA-182 standard in reflected format, runs baseline version
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_ecma_refl_base(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_ecma_refl_base(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from ECMA-182 standard in normal format, runs baseline version
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_ecma_norm_base(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_ecma_norm_base(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from ISO standard in reflected format.
|
||||
@ -213,11 +210,11 @@ uint64_t crc64_ecma_norm_base(
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
|
||||
uint64_t crc64_iso_refl_by8(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_iso_refl_by8(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from ISO standard in normal format.
|
||||
@ -226,31 +223,31 @@ uint64_t crc64_iso_refl_by8(
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
|
||||
uint64_t crc64_iso_norm_by8(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_iso_norm_by8(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from ISO standard in reflected format, runs baseline version
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_iso_refl_base(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_iso_refl_base(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from ISO standard in normal format, runs baseline version
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_iso_norm_base(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_iso_norm_base(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Jones" coefficients in reflected format.
|
||||
@ -259,11 +256,11 @@ uint64_t crc64_iso_norm_base(
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
|
||||
uint64_t crc64_jones_refl_by8(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_jones_refl_by8(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Jones" coefficients in normal format.
|
||||
@ -272,31 +269,31 @@ uint64_t crc64_jones_refl_by8(
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
|
||||
uint64_t crc64_jones_norm_by8(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_jones_norm_by8(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Jones" coefficients in reflected format, runs baseline version
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_jones_refl_base(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_jones_refl_base(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Jones" coefficients in normal format, runs baseline version
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_jones_norm_base(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_jones_norm_base(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Rocksoft" coefficients in reflected format.
|
||||
@ -305,21 +302,21 @@ uint64_t crc64_jones_norm_base(
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
|
||||
uint64_t crc64_rocksoft_refl_by8(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_rocksoft_refl_by8(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Rocksoft" coefficients in reflected format, runs baseline version
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_rocksoft_refl_base(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_rocksoft_refl_base(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Rocksoft" coefficients in normal format.
|
||||
@ -328,21 +325,21 @@ uint64_t crc64_rocksoft_refl_base(
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
|
||||
uint64_t crc64_rocksoft_norm_by8(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_rocksoft_norm_by8(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Generate CRC from "Rocksoft" coefficients in normal format, runs baseline version
|
||||
* @returns 64 bit CRC
|
||||
*/
|
||||
uint64_t crc64_rocksoft_norm_base(
|
||||
uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
uint64_t
|
||||
crc64_rocksoft_norm_base(uint64_t init_crc, //!< initial CRC value, 64 bits
|
||||
const unsigned char *buf, //!< buffer to calculate CRC on
|
||||
uint64_t len //!< buffer length in bytes (64-bit data)
|
||||
);
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -27,7 +27,6 @@
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
#ifndef _ERASURE_CODE_H_
|
||||
#define _ERASURE_CODE_H_
|
||||
|
||||
@ -71,7 +70,8 @@ extern "C" {
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void ec_init_tables(int k, int rows, unsigned char* a, unsigned char* gftbls);
|
||||
void
|
||||
ec_init_tables(int k, int rows, unsigned char *a, unsigned char *gftbls);
|
||||
|
||||
/**
|
||||
* @brief Initialize tables for fast Erasure Code encode and decode, runs baseline version.
|
||||
@ -79,7 +79,8 @@ void ec_init_tables(int k, int rows, unsigned char* a, unsigned char* gftbls);
|
||||
* Baseline version of ec_encode_data() with same parameters.
|
||||
*/
|
||||
|
||||
void ec_init_tables_base(int k, int rows, unsigned char* a, unsigned char* gftbls);
|
||||
void
|
||||
ec_init_tables_base(int k, int rows, unsigned char *a, unsigned char *gftbls);
|
||||
|
||||
/**
|
||||
* @brief Generate or decode erasure codes on blocks of data, runs appropriate version.
|
||||
@ -103,7 +104,8 @@ void ec_init_tables_base(int k, int rows, unsigned char* a, unsigned char* gftbl
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void ec_encode_data(int len, int k, int rows, unsigned char *gftbls, unsigned char **data,
|
||||
void
|
||||
ec_encode_data(int len, int k, int rows, unsigned char *gftbls, unsigned char **data,
|
||||
unsigned char **coding);
|
||||
|
||||
/**
|
||||
@ -111,11 +113,13 @@ void ec_encode_data(int len, int k, int rows, unsigned char *gftbls, unsigned ch
|
||||
*
|
||||
* Baseline version of ec_encode_data() with same parameters.
|
||||
*/
|
||||
void ec_encode_data_base(int len, int srcs, int dests, unsigned char *v, unsigned char **src,
|
||||
void
|
||||
ec_encode_data_base(int len, int srcs, int dests, unsigned char *v, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief Generate update for encode or decode of erasure codes from single source, runs appropriate version.
|
||||
* @brief Generate update for encode or decode of erasure codes from single source, runs appropriate
|
||||
* version.
|
||||
*
|
||||
* Given one source data block, update one or multiple blocks of encoded data as
|
||||
* specified by a matrix of GF(2^8) coefficients. When given a suitable set of
|
||||
@ -136,7 +140,8 @@ void ec_encode_data_base(int len, int srcs, int dests, unsigned char *v, unsigne
|
||||
* @param coding Array of pointers to coded output buffers.
|
||||
* @returns none
|
||||
*/
|
||||
void ec_encode_data_update(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
|
||||
void
|
||||
ec_encode_data_update(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
|
||||
unsigned char *data, unsigned char **coding);
|
||||
|
||||
/**
|
||||
@ -145,7 +150,8 @@ void ec_encode_data_update(int len, int k, int rows, int vec_i, unsigned char *g
|
||||
* Baseline version of ec_encode_data_update().
|
||||
*/
|
||||
|
||||
void ec_encode_data_update_base(int len, int k, int rows, int vec_i, unsigned char *v,
|
||||
void
|
||||
ec_encode_data_update_base(int len, int k, int rows, int vec_i, unsigned char *v,
|
||||
unsigned char *data, unsigned char **dest);
|
||||
|
||||
/**
|
||||
@ -168,9 +174,9 @@ void ec_encode_data_update_base(int len, int k, int rows, int vec_i, unsigned ch
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
|
||||
void gf_vect_dot_prod_base(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char *dest);
|
||||
void
|
||||
gf_vect_dot_prod_base(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char *dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product, runs appropriate version.
|
||||
@ -192,8 +198,9 @@ void gf_vect_dot_prod_base(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_vect_dot_prod(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char *dest);
|
||||
void
|
||||
gf_vect_dot_prod(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char *dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply accumulate, runs appropriate version.
|
||||
@ -218,7 +225,8 @@ void gf_vect_dot_prod(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_vect_mad(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_vect_mad(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char *dest);
|
||||
|
||||
/**
|
||||
@ -227,7 +235,8 @@ void gf_vect_mad(int len, int vec, int vec_i, unsigned char *gftbls, unsigned ch
|
||||
* Baseline version of gf_vect_mad() with same parameters.
|
||||
*/
|
||||
|
||||
void gf_vect_mad_base(int len, int vec, int vec_i, unsigned char *v, unsigned char *src,
|
||||
void
|
||||
gf_vect_mad_base(int len, int vec, int vec_i, unsigned char *v, unsigned char *src,
|
||||
unsigned char *dest);
|
||||
|
||||
// x86 only
|
||||
@ -239,7 +248,8 @@ void gf_vect_mad_base(int len, int vec, int vec_i, unsigned char *v, unsigned ch
|
||||
* Arch specific version of ec_encode_data() with same parameters.
|
||||
* @requires SSE4.1
|
||||
*/
|
||||
void ec_encode_data_sse(int len, int k, int rows, unsigned char *gftbls, unsigned char **data,
|
||||
void
|
||||
ec_encode_data_sse(int len, int k, int rows, unsigned char *gftbls, unsigned char **data,
|
||||
unsigned char **coding);
|
||||
|
||||
/**
|
||||
@ -248,7 +258,8 @@ void ec_encode_data_sse(int len, int k, int rows, unsigned char *gftbls, unsigne
|
||||
* Arch specific version of ec_encode_data() with same parameters.
|
||||
* @requires AVX
|
||||
*/
|
||||
void ec_encode_data_avx(int len, int k, int rows, unsigned char *gftbls, unsigned char **data,
|
||||
void
|
||||
ec_encode_data_avx(int len, int k, int rows, unsigned char *gftbls, unsigned char **data,
|
||||
unsigned char **coding);
|
||||
|
||||
/**
|
||||
@ -257,7 +268,8 @@ void ec_encode_data_avx(int len, int k, int rows, unsigned char *gftbls, unsigne
|
||||
* Arch specific version of ec_encode_data() with same parameters.
|
||||
* @requires AVX2
|
||||
*/
|
||||
void ec_encode_data_avx2(int len, int k, int rows, unsigned char *gftbls, unsigned char **data,
|
||||
void
|
||||
ec_encode_data_avx2(int len, int k, int rows, unsigned char *gftbls, unsigned char **data,
|
||||
unsigned char **coding);
|
||||
|
||||
/**
|
||||
@ -267,7 +279,8 @@ void ec_encode_data_avx2(int len, int k, int rows, unsigned char *gftbls, unsign
|
||||
* @requires SSE4.1
|
||||
*/
|
||||
|
||||
void ec_encode_data_update_sse(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
|
||||
void
|
||||
ec_encode_data_update_sse(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
|
||||
unsigned char *data, unsigned char **coding);
|
||||
|
||||
/**
|
||||
@ -277,7 +290,8 @@ void ec_encode_data_update_sse(int len, int k, int rows, int vec_i, unsigned cha
|
||||
* @requires AVX
|
||||
*/
|
||||
|
||||
void ec_encode_data_update_avx(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
|
||||
void
|
||||
ec_encode_data_update_avx(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
|
||||
unsigned char *data, unsigned char **coding);
|
||||
|
||||
/**
|
||||
@ -287,7 +301,8 @@ void ec_encode_data_update_avx(int len, int k, int rows, int vec_i, unsigned cha
|
||||
* @requires AVX2
|
||||
*/
|
||||
|
||||
void ec_encode_data_update_avx2(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
|
||||
void
|
||||
ec_encode_data_update_avx2(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
|
||||
unsigned char *data, unsigned char **coding);
|
||||
|
||||
/**
|
||||
@ -308,8 +323,9 @@ void ec_encode_data_update_avx2(int len, int k, int rows, int vec_i, unsigned ch
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char *dest);
|
||||
void
|
||||
gf_vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char *dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product.
|
||||
@ -329,8 +345,9 @@ void gf_vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char *dest);
|
||||
void
|
||||
gf_vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char *dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product.
|
||||
@ -350,8 +367,9 @@ void gf_vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char *dest);
|
||||
void
|
||||
gf_vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char *dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with two outputs.
|
||||
@ -372,8 +390,9 @@ void gf_vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_2vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_2vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with two outputs.
|
||||
@ -394,8 +413,9 @@ void gf_2vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_2vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_2vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with two outputs.
|
||||
@ -416,8 +436,9 @@ void gf_2vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_2vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_2vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with three outputs.
|
||||
@ -438,8 +459,9 @@ void gf_2vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_3vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_3vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with three outputs.
|
||||
@ -460,8 +482,9 @@ void gf_3vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_3vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_3vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with three outputs.
|
||||
@ -482,8 +505,9 @@ void gf_3vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_3vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_3vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with four outputs.
|
||||
@ -504,8 +528,9 @@ void gf_3vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_4vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_4vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with four outputs.
|
||||
@ -526,8 +551,9 @@ void gf_4vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_4vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_4vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with four outputs.
|
||||
@ -548,8 +574,9 @@ void gf_4vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_4vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_4vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with five outputs.
|
||||
@ -570,8 +597,9 @@ void gf_4vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_5vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_5vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with five outputs.
|
||||
@ -592,8 +620,9 @@ void gf_5vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_5vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_5vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with five outputs.
|
||||
@ -614,8 +643,9 @@ void gf_5vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_5vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_5vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with six outputs.
|
||||
@ -636,8 +666,9 @@ void gf_5vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_6vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_6vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with six outputs.
|
||||
@ -658,8 +689,9 @@ void gf_6vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_6vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_6vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with six outputs.
|
||||
@ -680,8 +712,9 @@ void gf_6vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_6vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void
|
||||
gf_6vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls, unsigned char **src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply accumulate, arch specific version.
|
||||
@ -690,7 +723,8 @@ void gf_6vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @requires SSE4.1
|
||||
*/
|
||||
|
||||
void gf_vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char *dest);
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply accumulate, arch specific version.
|
||||
@ -699,7 +733,8 @@ void gf_vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigne
|
||||
* @requires AVX
|
||||
*/
|
||||
|
||||
void gf_vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char *dest);
|
||||
|
||||
/**
|
||||
@ -709,10 +744,10 @@ void gf_vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigne
|
||||
* @requires AVX2
|
||||
*/
|
||||
|
||||
void gf_vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char *dest);
|
||||
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 2 accumulate. SSE version.
|
||||
*
|
||||
@ -734,20 +769,23 @@ void gf_vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsign
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_2vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_2vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 2 accumulate. AVX version of gf_2vect_mad_sse().
|
||||
* @requires AVX
|
||||
*/
|
||||
void gf_2vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_2vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 2 accumulate. AVX2 version of gf_2vect_mad_sse().
|
||||
* @requires AVX2
|
||||
*/
|
||||
void gf_2vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_2vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
@ -771,21 +809,24 @@ void gf_2vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsig
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_3vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_3vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 3 accumulate. AVX version of gf_3vect_mad_sse().
|
||||
* @requires AVX
|
||||
*/
|
||||
void gf_3vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_3vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 3 accumulate. AVX2 version of gf_3vect_mad_sse().
|
||||
* @requires AVX2
|
||||
*/
|
||||
void gf_3vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_3vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
@ -809,60 +850,69 @@ void gf_3vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsig
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_4vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_4vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 4 accumulate. AVX version of gf_4vect_mad_sse().
|
||||
* @requires AVX
|
||||
*/
|
||||
void gf_4vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_4vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 4 accumulate. AVX2 version of gf_4vect_mad_sse().
|
||||
* @requires AVX2
|
||||
*/
|
||||
void gf_4vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_4vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 5 accumulate. SSE version.
|
||||
* @requires SSE4.1
|
||||
*/
|
||||
void gf_5vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_5vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 5 accumulate. AVX version.
|
||||
* @requires AVX
|
||||
*/
|
||||
void gf_5vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_5vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 5 accumulate. AVX2 version.
|
||||
* @requires AVX2
|
||||
*/
|
||||
void gf_5vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_5vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 6 accumulate. SSE version.
|
||||
* @requires SSE4.1
|
||||
*/
|
||||
void gf_6vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_6vect_mad_sse(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 6 accumulate. AVX version.
|
||||
* @requires AVX
|
||||
*/
|
||||
void gf_6vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_6vect_mad_avx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply with 6 accumulate. AVX2 version.
|
||||
* @requires AVX2
|
||||
*/
|
||||
void gf_6vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
void
|
||||
gf_6vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
|
||||
unsigned char **dest);
|
||||
|
||||
#endif
|
||||
@ -879,7 +929,8 @@ void gf_6vect_mad_avx2(int len, int vec, int vec_i, unsigned char *gftbls, unsig
|
||||
* @returns Product of a and b in GF(2^8)
|
||||
*/
|
||||
|
||||
unsigned char gf_mul(unsigned char a, unsigned char b);
|
||||
unsigned char
|
||||
gf_mul(unsigned char a, unsigned char b);
|
||||
|
||||
/**
|
||||
* @brief Single element GF(2^8) inverse.
|
||||
@ -888,7 +939,8 @@ unsigned char gf_mul(unsigned char a, unsigned char b);
|
||||
* @returns Field element b such that a x b = {1}
|
||||
*/
|
||||
|
||||
unsigned char gf_inv(unsigned char a);
|
||||
unsigned char
|
||||
gf_inv(unsigned char a);
|
||||
|
||||
/**
|
||||
* @brief Generate a matrix of coefficients to be used for encoding.
|
||||
@ -914,7 +966,8 @@ unsigned char gf_inv(unsigned char a);
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_gen_rs_matrix(unsigned char *a, int m, int k);
|
||||
void
|
||||
gf_gen_rs_matrix(unsigned char *a, int m, int k);
|
||||
|
||||
/**
|
||||
* @brief Generate a Cauchy matrix of coefficients to be used for encoding.
|
||||
@ -929,7 +982,8 @@ void gf_gen_rs_matrix(unsigned char *a, int m, int k);
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_gen_cauchy1_matrix(unsigned char *a, int m, int k);
|
||||
void
|
||||
gf_gen_cauchy1_matrix(unsigned char *a, int m, int k);
|
||||
|
||||
/**
|
||||
* @brief Invert a matrix in GF(2^8)
|
||||
@ -943,8 +997,8 @@ void gf_gen_cauchy1_matrix(unsigned char *a, int m, int k);
|
||||
* @returns 0 successful, other fail on singular input matrix
|
||||
*/
|
||||
|
||||
int gf_invert_matrix(unsigned char *in, unsigned char *out, const int n);
|
||||
|
||||
int
|
||||
gf_invert_matrix(unsigned char *in, unsigned char *out, const int n);
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
#ifndef _GF_VECT_MUL_H
|
||||
#define _GF_VECT_MUL_H
|
||||
|
||||
@ -46,7 +45,7 @@ extern "C" {
|
||||
// x86 only
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply by constant.
|
||||
*
|
||||
* Does a GF(2^8) vector multiply b = Ca where a and b are arrays and C
|
||||
@ -64,10 +63,10 @@ extern "C" {
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int gf_vect_mul_sse(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
int
|
||||
gf_vect_mul_sse(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply by constant.
|
||||
*
|
||||
* Does a GF(2^8) vector multiply b = Ca where a and b are arrays and C
|
||||
@ -85,7 +84,8 @@ int gf_vect_mul_sse(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int gf_vect_mul_avx(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
int
|
||||
gf_vect_mul_avx(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
|
||||
#endif
|
||||
|
||||
@ -109,8 +109,8 @@ int gf_vect_mul_avx(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int gf_vect_mul(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
|
||||
int
|
||||
gf_vect_mul(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
|
||||
/**
|
||||
* @brief Initialize 32-byte constant array for GF(2^8) vector multiply
|
||||
@ -122,8 +122,8 @@ int gf_vect_mul(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
* @param gftbl Table output.
|
||||
*/
|
||||
|
||||
void gf_vect_mul_init(unsigned char c, unsigned char* gftbl);
|
||||
|
||||
void
|
||||
gf_vect_mul_init(unsigned char c, unsigned char *gftbl);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector multiply by constant, runs baseline version.
|
||||
@ -143,8 +143,8 @@ void gf_vect_mul_init(unsigned char c, unsigned char* gftbl);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int gf_vect_mul_base(int len, unsigned char *a, unsigned char *src,
|
||||
unsigned char *dest);
|
||||
int
|
||||
gf_vect_mul_base(int len, unsigned char *a, unsigned char *src, unsigned char *dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ extern "C" {
|
||||
#define IGZIP_K 1024
|
||||
#define ISAL_DEF_MAX_HDR_SIZE 328
|
||||
#define ISAL_DEF_MAX_CODE_LEN 15
|
||||
#define ISAL_DEF_HIST_SIZE (32*IGZIP_K)
|
||||
#define ISAL_DEF_HIST_SIZE (32 * IGZIP_K)
|
||||
#define ISAL_DEF_MAX_HIST_BITS 15
|
||||
#define ISAL_DEF_MAX_MATCH 258
|
||||
#define ISAL_DEF_MIN_MATCH 3
|
||||
@ -128,17 +128,17 @@ extern "C" {
|
||||
#define IGZIP_LVL3_HASH_SIZE IGZIP_HASH_MAP_HASH_SIZE
|
||||
|
||||
#ifdef LONGER_HUFFTABLE
|
||||
enum {IGZIP_DIST_TABLE_SIZE = 8*1024};
|
||||
enum { IGZIP_DIST_TABLE_SIZE = 8 * 1024 };
|
||||
|
||||
/* DECODE_OFFSET is dist code index corresponding to DIST_TABLE_SIZE + 1 */
|
||||
enum { IGZIP_DECODE_OFFSET = 26 };
|
||||
#else
|
||||
enum {IGZIP_DIST_TABLE_SIZE = 2};
|
||||
enum { IGZIP_DIST_TABLE_SIZE = 2 };
|
||||
/* DECODE_OFFSET is dist code index corresponding to DIST_TABLE_SIZE + 1 */
|
||||
enum { IGZIP_DECODE_OFFSET = 0 };
|
||||
#endif
|
||||
enum {IGZIP_LEN_TABLE_SIZE = 256};
|
||||
enum {IGZIP_LIT_TABLE_SIZE = ISAL_DEF_LIT_SYMBOLS};
|
||||
enum { IGZIP_LEN_TABLE_SIZE = 256 };
|
||||
enum { IGZIP_LIT_TABLE_SIZE = ISAL_DEF_LIT_SYMBOLS };
|
||||
|
||||
#define IGZIP_HUFFTABLE_CUSTOM 0
|
||||
#define IGZIP_HUFFTABLE_DEFAULT 1
|
||||
@ -172,7 +172,6 @@ enum {IGZIP_LIT_TABLE_SIZE = ISAL_DEF_LIT_SYMBOLS};
|
||||
* @brief Compression State please note ZSTATE_TRL only applies for GZIP compression
|
||||
*/
|
||||
|
||||
|
||||
/* When the state is set to ZSTATE_NEW_HDR or TMP_ZSTATE_NEW_HEADER, the
|
||||
* hufftable being used for compression may be swapped
|
||||
*/
|
||||
@ -219,7 +218,8 @@ enum isal_block_state {
|
||||
ISAL_BLOCK_TYPE0, /* Decoding a type 0 block */
|
||||
ISAL_BLOCK_CODED, /* Decoding a huffman coded block */
|
||||
ISAL_BLOCK_INPUT_DONE, /* Decompression of input is completed */
|
||||
ISAL_BLOCK_FINISH, /* Decompression of input is completed and all data has been flushed to output */
|
||||
ISAL_BLOCK_FINISH, /* Decompression of input is completed and all data has been flushed to
|
||||
output */
|
||||
ISAL_GZIP_EXTRA_LEN,
|
||||
ISAL_GZIP_EXTRA,
|
||||
ISAL_GZIP_NAME,
|
||||
@ -229,7 +229,6 @@ enum isal_block_state {
|
||||
ISAL_CHECKSUM_CHECK,
|
||||
};
|
||||
|
||||
|
||||
/* Inflate Flags */
|
||||
#define ISAL_DEFLATE 0 /* Default */
|
||||
#define ISAL_GZIP 1
|
||||
@ -259,7 +258,8 @@ enum isal_block_state {
|
||||
/******************************************************************************/
|
||||
/** @brief Holds histogram of deflate symbols*/
|
||||
struct isal_huff_histogram {
|
||||
uint64_t lit_len_histogram[ISAL_DEF_LIT_LEN_SYMBOLS]; //!< Histogram of Literal/Len symbols seen
|
||||
uint64_t lit_len_histogram[ISAL_DEF_LIT_LEN_SYMBOLS]; //!< Histogram of Literal/Len symbols
|
||||
//!< seen
|
||||
uint64_t dist_histogram[ISAL_DEF_DIST_SYMBOLS]; //!< Histogram of Distance Symbols seen
|
||||
uint16_t hash_table[IGZIP_LVL0_HASH_SIZE]; //!< Tmp space used as a hash table
|
||||
};
|
||||
@ -370,7 +370,8 @@ struct isal_zstate {
|
||||
uint8_t has_eob_hdr; //!< keeps track of eob hdr (with BFINAL set)
|
||||
uint8_t has_eob; //!< keeps track of eob on the last deflate block
|
||||
uint8_t has_hist; //!< flag to track if there is match history
|
||||
uint16_t has_level_buf_init; //!< flag to track if user supplied memory has been initialized.
|
||||
uint16_t
|
||||
has_level_buf_init; //!< flag to track if user supplied memory has been initialized.
|
||||
uint32_t count; //!< used for partial header/trailer writes
|
||||
uint8_t tmp_out_buff[16]; //!< temporary array
|
||||
uint32_t tmp_out_start; //!< temporary variable
|
||||
@ -389,13 +390,14 @@ struct isal_hufftables {
|
||||
uint8_t deflate_hdr[ISAL_DEF_MAX_HDR_SIZE]; //!< deflate huffman tree header
|
||||
uint32_t deflate_hdr_count; //!< Number of whole bytes in deflate_huff_hdr
|
||||
uint32_t deflate_hdr_extra_bits; //!< Number of bits in the partial byte in header
|
||||
uint32_t dist_table[IGZIP_DIST_TABLE_SIZE]; //!< bits 4:0 are the code length, bits 31:5 are the code
|
||||
uint32_t len_table[IGZIP_LEN_TABLE_SIZE]; //!< bits 4:0 are the code length, bits 31:5 are the code
|
||||
uint32_t dist_table[IGZIP_DIST_TABLE_SIZE]; //!< bits 4:0 are the code length, bits 31:5 are
|
||||
//!< the code
|
||||
uint32_t len_table[IGZIP_LEN_TABLE_SIZE]; //!< bits 4:0 are the code length, bits 31:5 are
|
||||
//!< the code
|
||||
uint16_t lit_table[IGZIP_LIT_TABLE_SIZE]; //!< literal code
|
||||
uint8_t lit_table_sizes[IGZIP_LIT_TABLE_SIZE]; //!< literal code length
|
||||
uint16_t dcodes[30 - IGZIP_DECODE_OFFSET]; //!< distance code
|
||||
uint8_t dcodes_sizes[30 - IGZIP_DECODE_OFFSET]; //!< distance code length
|
||||
|
||||
};
|
||||
|
||||
/** @brief Holds stream information*/
|
||||
@ -411,7 +413,7 @@ struct isal_zstream {
|
||||
struct isal_hufftables *hufftables; //!< Huffman encoding used when compressing
|
||||
uint32_t level; //!< Compression level to use
|
||||
uint32_t level_buf_size; //!< Size of level_buf
|
||||
uint8_t * level_buf; //!< User allocated buffer required for different compression levels
|
||||
uint8_t *level_buf; //!< User allocated buffer required for different compression levels
|
||||
uint16_t end_of_stream; //!< non-zero if this is the last input buffer
|
||||
uint16_t flush; //!< Flush type can be NO_FLUSH, SYNC_FLUSH or FULL_FLUSH
|
||||
uint16_t gzip_flag; //!< Indicate if gzip compression is to be performed
|
||||
@ -482,8 +484,10 @@ struct isal_zstream {
|
||||
#define ISAL_L_DUP ((1 << ISAL_L_REM) - (ISAL_L_REM + 1))
|
||||
#define ISAL_S_DUP ((1 << ISAL_S_REM) - (ISAL_S_REM + 1))
|
||||
|
||||
#define ISAL_L_UNUSED ((1 << ISAL_L_REM) - (1 << ((ISAL_L_REM)/2)) - (1 << ((ISAL_L_REM + 1)/2)) + 1)
|
||||
#define ISAL_S_UNUSED ((1 << ISAL_S_REM) - (1 << ((ISAL_S_REM)/2)) - (1 << ((ISAL_S_REM + 1)/2)) + 1)
|
||||
#define ISAL_L_UNUSED \
|
||||
((1 << ISAL_L_REM) - (1 << ((ISAL_L_REM) / 2)) - (1 << ((ISAL_L_REM + 1) / 2)) + 1)
|
||||
#define ISAL_S_UNUSED \
|
||||
((1 << ISAL_S_REM) - (1 << ((ISAL_S_REM) / 2)) - (1 << ((ISAL_S_REM + 1) / 2)) + 1)
|
||||
|
||||
#define ISAL_L_SIZE (ISAL_DEF_LIT_LEN_SYMBOLS + ISAL_L_DUP + ISAL_L_UNUSED)
|
||||
#define ISAL_S_SIZE (ISAL_DEF_DIST_SYMBOLS + ISAL_S_DUP + ISAL_S_UNUSED)
|
||||
@ -499,7 +503,7 @@ struct inflate_huff_code_large {
|
||||
|
||||
/** @brief Small lookup table for decoding huffman codes */
|
||||
struct inflate_huff_code_small {
|
||||
uint16_t short_code_lookup[1 << (ISAL_DECODE_SHORT_BITS)]; //!<Short code lookup table
|
||||
uint16_t short_code_lookup[1 << (ISAL_DECODE_SHORT_BITS)]; //!< Short code lookup table
|
||||
uint16_t long_code_lookup[ISAL_HUFF_CODE_SMALL_LONG_ALIGNED]; //!< Long code lookup table
|
||||
};
|
||||
|
||||
@ -521,7 +525,8 @@ struct inflate_state {
|
||||
uint32_t crc; //!< Contains crc or adler32 of output if crc_flag is set
|
||||
uint32_t hist_bits; //!< Log base 2 of maximum lookback distance
|
||||
union {
|
||||
int32_t type0_block_len; //!< Length left to read of type 0 block when outbuffer overflow occurred
|
||||
int32_t type0_block_len; //!< Length left to read of type 0 block when outbuffer
|
||||
//!< overflow occurred
|
||||
int32_t count; //!< Count of bytes remaining to be parsed
|
||||
uint32_t dict_id;
|
||||
};
|
||||
@ -533,8 +538,11 @@ struct inflate_state {
|
||||
int16_t tmp_in_size; //!< Number of bytes in tmp_in_buffer
|
||||
int32_t tmp_out_valid; //!< Number of bytes in tmp_out_buffer
|
||||
int32_t tmp_out_processed; //!< Number of bytes processed in tmp_out_buffer
|
||||
uint8_t tmp_in_buffer[ISAL_DEF_MAX_HDR_SIZE]; //!< Temporary buffer containing data from the input stream
|
||||
uint8_t tmp_out_buffer[2 * ISAL_DEF_HIST_SIZE + ISAL_LOOK_AHEAD]; //!< Temporary buffer containing data from the output stream
|
||||
uint8_t tmp_in_buffer[ISAL_DEF_MAX_HDR_SIZE]; //!< Temporary buffer containing data from the
|
||||
//!< input stream
|
||||
uint8_t tmp_out_buffer[2 * ISAL_DEF_HIST_SIZE +
|
||||
ISAL_LOOK_AHEAD]; //!< Temporary buffer containing data from the
|
||||
//!< output stream
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
@ -551,8 +559,8 @@ struct inflate_state {
|
||||
* @param length: The length of start_stream.
|
||||
* @param histogram: The returned histogram of lit/len/dist symbols.
|
||||
*/
|
||||
void isal_update_histogram(uint8_t * in_stream, int length, struct isal_huff_histogram * histogram);
|
||||
|
||||
void
|
||||
isal_update_histogram(uint8_t *in_stream, int length, struct isal_huff_histogram *histogram);
|
||||
|
||||
/**
|
||||
* @brief Creates a custom huffman code for the given histograms in which
|
||||
@ -564,8 +572,8 @@ void isal_update_histogram(uint8_t * in_stream, int length, struct isal_huff_his
|
||||
* repeat lengths and lookback distances
|
||||
* @returns Returns a non zero value if an invalid huffman code was created.
|
||||
*/
|
||||
int isal_create_hufftables(struct isal_hufftables * hufftables,
|
||||
struct isal_huff_histogram * histogram);
|
||||
int
|
||||
isal_create_hufftables(struct isal_hufftables *hufftables, struct isal_huff_histogram *histogram);
|
||||
|
||||
/**
|
||||
* @brief Creates a custom huffman code for the given histograms like
|
||||
@ -577,8 +585,9 @@ int isal_create_hufftables(struct isal_hufftables * hufftables,
|
||||
* repeat lengths and lookback distances
|
||||
* @returns Returns a non zero value if an invalid huffman code was created.
|
||||
*/
|
||||
int isal_create_hufftables_subset(struct isal_hufftables * hufftables,
|
||||
struct isal_huff_histogram * histogram);
|
||||
int
|
||||
isal_create_hufftables_subset(struct isal_hufftables *hufftables,
|
||||
struct isal_huff_histogram *histogram);
|
||||
|
||||
/**
|
||||
* @brief Initialize compression stream data structure
|
||||
@ -586,7 +595,8 @@ int isal_create_hufftables_subset(struct isal_hufftables * hufftables,
|
||||
* @param stream Structure holding state information on the compression streams.
|
||||
* @returns none
|
||||
*/
|
||||
void isal_deflate_init(struct isal_zstream *stream);
|
||||
void
|
||||
isal_deflate_init(struct isal_zstream *stream);
|
||||
|
||||
/**
|
||||
* @brief Reinitialize compression stream data structure. Performs the same
|
||||
@ -597,22 +607,24 @@ void isal_deflate_init(struct isal_zstream *stream);
|
||||
* @param stream Structure holding state information on the compression streams.
|
||||
* @returns none
|
||||
*/
|
||||
void isal_deflate_reset(struct isal_zstream *stream);
|
||||
|
||||
void
|
||||
isal_deflate_reset(struct isal_zstream *stream);
|
||||
|
||||
/**
|
||||
* @brief Set gzip header default values
|
||||
*
|
||||
* @param gz_hdr: Gzip header to initialize.
|
||||
*/
|
||||
void isal_gzip_header_init(struct isal_gzip_header *gz_hdr);
|
||||
void
|
||||
isal_gzip_header_init(struct isal_gzip_header *gz_hdr);
|
||||
|
||||
/**
|
||||
* @brief Set zlib header default values
|
||||
*
|
||||
* @param z_hdr: zlib header to initialize.
|
||||
*/
|
||||
void isal_zlib_header_init(struct isal_zlib_header *z_hdr);
|
||||
void
|
||||
isal_zlib_header_init(struct isal_zlib_header *z_hdr);
|
||||
|
||||
/**
|
||||
* @brief Write gzip header to output stream
|
||||
@ -629,7 +641,8 @@ void isal_zlib_header_init(struct isal_zlib_header *z_hdr);
|
||||
* the minimum size required to successfully write the gzip header to the output
|
||||
* buffer.
|
||||
*/
|
||||
uint32_t isal_write_gzip_header(struct isal_zstream * stream, struct isal_gzip_header *gz_hdr);
|
||||
uint32_t
|
||||
isal_write_gzip_header(struct isal_zstream *stream, struct isal_gzip_header *gz_hdr);
|
||||
|
||||
/**
|
||||
* @brief Write zlib header to output stream
|
||||
@ -646,7 +659,8 @@ uint32_t isal_write_gzip_header(struct isal_zstream * stream, struct isal_gzip_h
|
||||
* the minimum size required to successfully write the zlib header to the output
|
||||
* buffer.
|
||||
*/
|
||||
uint32_t isal_write_zlib_header(struct isal_zstream * stream, struct isal_zlib_header *z_hdr);
|
||||
uint32_t
|
||||
isal_write_zlib_header(struct isal_zstream *stream, struct isal_zlib_header *z_hdr);
|
||||
|
||||
/**
|
||||
* @brief Set stream to use a new Huffman code
|
||||
@ -668,8 +682,9 @@ uint32_t isal_write_zlib_header(struct isal_zstream * stream, struct isal_zlib_h
|
||||
* due to the stream being in a state where changing the huffman code is not
|
||||
* allowed or an invalid input is provided.
|
||||
*/
|
||||
int isal_deflate_set_hufftables(struct isal_zstream *stream,
|
||||
struct isal_hufftables *hufftables, int type);
|
||||
int
|
||||
isal_deflate_set_hufftables(struct isal_zstream *stream, struct isal_hufftables *hufftables,
|
||||
int type);
|
||||
|
||||
/**
|
||||
* @brief Initialize compression stream data structure
|
||||
@ -677,8 +692,8 @@ int isal_deflate_set_hufftables(struct isal_zstream *stream,
|
||||
* @param stream Structure holding state information on the compression streams.
|
||||
* @returns none
|
||||
*/
|
||||
void isal_deflate_stateless_init(struct isal_zstream *stream);
|
||||
|
||||
void
|
||||
isal_deflate_stateless_init(struct isal_zstream *stream);
|
||||
|
||||
/**
|
||||
* @brief Set compression dictionary to use
|
||||
@ -694,7 +709,8 @@ void isal_deflate_stateless_init(struct isal_zstream *stream);
|
||||
* @returns COMP_OK,
|
||||
* ISAL_INVALID_STATE (dictionary could not be set)
|
||||
*/
|
||||
int isal_deflate_set_dict(struct isal_zstream *stream, uint8_t *dict, uint32_t dict_len);
|
||||
int
|
||||
isal_deflate_set_dict(struct isal_zstream *stream, uint8_t *dict, uint32_t dict_len);
|
||||
|
||||
/** @brief Structure for holding processed dictionary information */
|
||||
|
||||
@ -725,8 +741,9 @@ struct isal_dict {
|
||||
* @returns COMP_OK,
|
||||
* ISAL_INVALID_STATE (dictionary could not be processed)
|
||||
*/
|
||||
int isal_deflate_process_dict(struct isal_zstream *stream, struct isal_dict *dict_str,
|
||||
uint8_t *dict, uint32_t dict_len);
|
||||
int
|
||||
isal_deflate_process_dict(struct isal_zstream *stream, struct isal_dict *dict_str, uint8_t *dict,
|
||||
uint32_t dict_len);
|
||||
|
||||
/**
|
||||
* @brief Reset compression dictionary to use
|
||||
@ -745,8 +762,8 @@ int isal_deflate_process_dict(struct isal_zstream *stream, struct isal_dict *dic
|
||||
* @returns COMP_OK,
|
||||
* ISAL_INVALID_STATE or other (dictionary could not be reset)
|
||||
*/
|
||||
int isal_deflate_reset_dict(struct isal_zstream *stream, struct isal_dict *dict_str);
|
||||
|
||||
int
|
||||
isal_deflate_reset_dict(struct isal_zstream *stream, struct isal_dict *dict_str);
|
||||
|
||||
/**
|
||||
* @brief Fast data (deflate) compression for storage applications.
|
||||
@ -802,8 +819,8 @@ int isal_deflate_reset_dict(struct isal_zstream *stream, struct isal_dict *dict_
|
||||
* ISAL_INVALID_LEVEL (if an invalid compression level is selected),
|
||||
* ISAL_INVALID_LEVEL_BUF (if the level buffer is not large enough).
|
||||
*/
|
||||
int isal_deflate(struct isal_zstream *stream);
|
||||
|
||||
int
|
||||
isal_deflate(struct isal_zstream *stream);
|
||||
|
||||
/**
|
||||
* @brief Fast data (deflate) stateless compression for storage applications.
|
||||
@ -832,8 +849,8 @@ int isal_deflate(struct isal_zstream *stream);
|
||||
* ISAL_INVALID_LEVEL_BUF (if the level buffer is not large enough),
|
||||
* STATELESS_OVERFLOW (if output buffer will not fit output).
|
||||
*/
|
||||
int isal_deflate_stateless(struct isal_zstream *stream);
|
||||
|
||||
int
|
||||
isal_deflate_stateless(struct isal_zstream *stream);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Inflate functions */
|
||||
@ -844,7 +861,8 @@ int isal_deflate_stateless(struct isal_zstream *stream);
|
||||
* @param state Structure holding state information on the compression streams.
|
||||
* @returns none
|
||||
*/
|
||||
void isal_inflate_init(struct inflate_state *state);
|
||||
void
|
||||
isal_inflate_init(struct inflate_state *state);
|
||||
|
||||
/**
|
||||
* @brief Reinitialize decompression state data structure
|
||||
@ -852,7 +870,8 @@ void isal_inflate_init(struct inflate_state *state);
|
||||
* @param state Structure holding state information on the compression streams.
|
||||
* @returns none
|
||||
*/
|
||||
void isal_inflate_reset(struct inflate_state *state);
|
||||
void
|
||||
isal_inflate_reset(struct inflate_state *state);
|
||||
|
||||
/**
|
||||
* @brief Set decompression dictionary to use
|
||||
@ -867,7 +886,8 @@ void isal_inflate_reset(struct inflate_state *state);
|
||||
* @returns COMP_OK,
|
||||
* ISAL_INVALID_STATE (dictionary could not be set)
|
||||
*/
|
||||
int isal_inflate_set_dict(struct inflate_state *state, uint8_t *dict, uint32_t dict_len);
|
||||
int
|
||||
isal_inflate_set_dict(struct inflate_state *state, uint8_t *dict, uint32_t dict_len);
|
||||
|
||||
/**
|
||||
* @brief Read and return gzip header information
|
||||
@ -890,7 +910,8 @@ int isal_inflate_set_dict(struct inflate_state *state, uint8_t *dict, uint32_t d
|
||||
* ISAL_UNSUPPORTED_METHOD (deflate is not the compression method),
|
||||
* ISAL_INCORRECT_CHECKSUM (gzip header checksum was incorrect)
|
||||
*/
|
||||
int isal_read_gzip_header (struct inflate_state *state, struct isal_gzip_header *gz_hdr);
|
||||
int
|
||||
isal_read_gzip_header(struct inflate_state *state, struct isal_gzip_header *gz_hdr);
|
||||
|
||||
/**
|
||||
* @brief Read and return zlib header information
|
||||
@ -905,7 +926,8 @@ int isal_read_gzip_header (struct inflate_state *state, struct isal_gzip_header
|
||||
* ISAL_UNSUPPORTED_METHOD (deflate is not the compression method),
|
||||
* ISAL_INCORRECT_CHECKSUM (zlib header checksum was incorrect)
|
||||
*/
|
||||
int isal_read_zlib_header (struct inflate_state *state, struct isal_zlib_header *zlib_hdr);
|
||||
int
|
||||
isal_read_zlib_header(struct inflate_state *state, struct isal_zlib_header *zlib_hdr);
|
||||
|
||||
/**
|
||||
* @brief Fast data (deflate) decompression for storage applications.
|
||||
@ -953,7 +975,8 @@ int isal_read_zlib_header (struct inflate_state *state, struct isal_zlib_header
|
||||
* ISAL_INCORRECT_CHECKSUM.
|
||||
*/
|
||||
|
||||
int isal_inflate(struct inflate_state *state);
|
||||
int
|
||||
isal_inflate(struct inflate_state *state);
|
||||
|
||||
/**
|
||||
* @brief Fast data (deflate) stateless decompression for storage applications.
|
||||
@ -975,7 +998,8 @@ int isal_inflate(struct inflate_state *state);
|
||||
* ISAL_UNSUPPORTED_METHOD,
|
||||
* ISAL_INCORRECT_CHECKSUM.
|
||||
*/
|
||||
int isal_inflate_stateless(struct inflate_state *state);
|
||||
int
|
||||
isal_inflate_stateless(struct inflate_state *state);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Other functions */
|
||||
@ -992,7 +1016,8 @@ int isal_inflate_stateless(struct inflate_state *state);
|
||||
*
|
||||
* @returns 32-bit Adler-32 checksum
|
||||
*/
|
||||
uint32_t isal_adler32(uint32_t init, const unsigned char *buf, uint64_t len);
|
||||
uint32_t
|
||||
isal_adler32(uint32_t init, const unsigned char *buf, uint64_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -36,7 +36,6 @@
|
||||
* Defines the interface for vector versions of common memory functions.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _MEM_ROUTINES_H_
|
||||
#define _MEM_ROUTINES_H_
|
||||
|
||||
@ -54,11 +53,11 @@ extern "C" {
|
||||
* @returns 0 - region is all zeros
|
||||
* other - region has non zero bytes
|
||||
*/
|
||||
int isal_zero_detect(void *mem, size_t len);
|
||||
int
|
||||
isal_zero_detect(void *mem, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _MEM_ROUTINES_H_
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
#ifndef _RAID_H_
|
||||
#define _RAID_H_
|
||||
|
||||
@ -61,8 +60,8 @@ extern "C" {
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int xor_gen(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
xor_gen(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Checks that array has XOR parity sum of 0 across all vectors, runs appropriate version.
|
||||
@ -78,8 +77,8 @@ int xor_gen(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int xor_check(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
xor_check(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Generate P+Q parity vectors from N sources, runs appropriate version.
|
||||
@ -98,11 +97,12 @@ int xor_check(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int pq_gen(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
pq_gen(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Checks that array of N sources, P and Q are consistent across all vectors, runs appropriate version.
|
||||
* @brief Checks that array of N sources, P and Q are consistent across all vectors, runs
|
||||
* appropriate version.
|
||||
*
|
||||
* This function determines what instruction sets are enabled and
|
||||
* selects the appropriate version at runtime.
|
||||
@ -116,8 +116,8 @@ int pq_gen(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int pq_check(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
pq_check(int vects, int len, void **array);
|
||||
|
||||
/* Arch specific versions */
|
||||
// x86 only
|
||||
@ -136,8 +136,8 @@ int pq_check(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int xor_gen_sse(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
xor_gen_sse(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Generate XOR parity vector from N sources.
|
||||
@ -152,8 +152,8 @@ int xor_gen_sse(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int xor_gen_avx(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
xor_gen_avx(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Checks that array has XOR parity sum of 0 across all vectors.
|
||||
@ -167,8 +167,8 @@ int xor_gen_avx(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int xor_check_sse(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
xor_check_sse(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Generate P+Q parity vectors from N sources.
|
||||
@ -185,8 +185,8 @@ int xor_check_sse(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int pq_gen_sse(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
pq_gen_sse(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Generate P+Q parity vectors from N sources.
|
||||
@ -203,8 +203,8 @@ int pq_gen_sse(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int pq_gen_avx(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
pq_gen_avx(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Generate P+Q parity vectors from N sources.
|
||||
@ -221,8 +221,8 @@ int pq_gen_avx(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int pq_gen_avx2(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
pq_gen_avx2(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Checks that array of N sources, P and Q are consistent across all vectors.
|
||||
@ -236,7 +236,8 @@ int pq_gen_avx2(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int pq_check_sse(int vects, int len, void **array);
|
||||
int
|
||||
pq_check_sse(int vects, int len, void **array);
|
||||
|
||||
#endif
|
||||
|
||||
@ -253,8 +254,8 @@ int pq_check_sse(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int pq_gen_base(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
pq_gen_base(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Generate XOR parity vector from N sources, runs baseline version.
|
||||
@ -267,8 +268,8 @@ int pq_gen_base(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int xor_gen_base(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
xor_gen_base(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Checks that array has XOR parity sum of 0 across all vectors, runs baseline version.
|
||||
@ -281,11 +282,12 @@ int xor_gen_base(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int xor_check_base(int vects, int len, void **array);
|
||||
|
||||
int
|
||||
xor_check_base(int vects, int len, void **array);
|
||||
|
||||
/**
|
||||
* @brief Checks that array of N sources, P and Q are consistent across all vectors, runs baseline version.
|
||||
* @brief Checks that array of N sources, P and Q are consistent across all vectors, runs baseline
|
||||
* version.
|
||||
*
|
||||
* @param vects Number of vectors in array including P&Q. Must be > 3.
|
||||
* @param len Length of each vector in bytes. Must be 16B aligned.
|
||||
@ -296,7 +298,8 @@ int xor_check_base(int vects, int len, void **array);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int pq_check_base(int vects, int len, void **array);
|
||||
int
|
||||
pq_check_base(int vects, int len, void **array);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
174
include/test.h
174
include/test.h
@ -47,30 +47,34 @@ extern "C" {
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define inline __inline
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
/* Make os-independent alignment attribute, alloc and free. */
|
||||
#if defined __unix__ || defined __APPLE__
|
||||
# define DECLARE_ALIGNED(decl, alignval) decl __attribute__((aligned(alignval)))
|
||||
# define __forceinline static inline
|
||||
# define aligned_free(x) free(x)
|
||||
#define DECLARE_ALIGNED(decl, alignval) decl __attribute__((aligned(alignval)))
|
||||
#define __forceinline static inline
|
||||
#define aligned_free(x) free(x)
|
||||
#else
|
||||
# ifdef __MINGW32__
|
||||
# define DECLARE_ALIGNED(decl, alignval) decl __attribute__((aligned(alignval)))
|
||||
# define posix_memalign(p, algn, len) (NULL == (*((char**)(p)) = (void*) _aligned_malloc(len, algn)))
|
||||
# define aligned_free(x) _aligned_free(x)
|
||||
# else
|
||||
# define DECLARE_ALIGNED(decl, alignval) __declspec(align(alignval)) decl
|
||||
# define posix_memalign(p, algn, len) (NULL == (*((char**)(p)) = (void*) _aligned_malloc(len, algn)))
|
||||
# define aligned_free(x) _aligned_free(x)
|
||||
# endif
|
||||
#ifdef __MINGW32__
|
||||
#define DECLARE_ALIGNED(decl, alignval) decl __attribute__((aligned(alignval)))
|
||||
#define posix_memalign(p, algn, len) \
|
||||
(NULL == (*((char **) (p)) = (void *) _aligned_malloc(len, algn)))
|
||||
#define aligned_free(x) _aligned_free(x)
|
||||
#else
|
||||
#define DECLARE_ALIGNED(decl, alignval) __declspec(align(alignval)) decl
|
||||
#define posix_memalign(p, algn, len) \
|
||||
(NULL == (*((char **) (p)) = (void *) _aligned_malloc(len, algn)))
|
||||
#define aligned_free(x) _aligned_free(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
# define DEBUG_PRINT(x) printf x
|
||||
#define DEBUG_PRINT(x) printf x
|
||||
#else
|
||||
# define DEBUG_PRINT(x) do {} while (0)
|
||||
#define DEBUG_PRINT(x) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/* Decide whether to use benchmark time as an approximation or a minimum. Fewer
|
||||
@ -86,58 +90,68 @@ extern "C" {
|
||||
* standardized clock source. To obtain a meaningful result it may be
|
||||
* necessary to fix the CPU clock to match the rtdsc tick rate.
|
||||
*/
|
||||
# include <inttypes.h>
|
||||
# include <x86intrin.h>
|
||||
# define USE_CYCLES
|
||||
#include <inttypes.h>
|
||||
#include <x86intrin.h>
|
||||
#define USE_CYCLES
|
||||
#else
|
||||
# include <time.h>
|
||||
#include <time.h>
|
||||
#define USE_SECONDS
|
||||
#endif
|
||||
|
||||
#ifdef USE_RDTSC
|
||||
#ifndef BENCHMARK_TIME
|
||||
# define BENCHMARK_TIME 6
|
||||
#define BENCHMARK_TIME 6
|
||||
#endif
|
||||
# define GHZ 1000000000
|
||||
# define UNIT_SCALE (GHZ)
|
||||
# define CALIBRATE_TIME (UNIT_SCALE / 2)
|
||||
static inline long long get_time(void) {
|
||||
#define GHZ 1000000000
|
||||
#define UNIT_SCALE (GHZ)
|
||||
#define CALIBRATE_TIME (UNIT_SCALE / 2)
|
||||
static inline long long
|
||||
get_time(void)
|
||||
{
|
||||
unsigned int dummy;
|
||||
return __rdtscp(&dummy);
|
||||
}
|
||||
|
||||
static inline long long get_res(void) {
|
||||
static inline long long
|
||||
get_res(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
#ifndef BENCHMARK_TIME
|
||||
# define BENCHMARK_TIME 3
|
||||
#define BENCHMARK_TIME 3
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#define UNIT_SCALE get_res()
|
||||
#define CALIBRATE_TIME (UNIT_SCALE / 4)
|
||||
static inline long long get_time(void) {
|
||||
static inline long long
|
||||
get_time(void)
|
||||
{
|
||||
long long ret = 0;
|
||||
QueryPerformanceCounter(&ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline long long get_res(void) {
|
||||
static inline long long
|
||||
get_res(void)
|
||||
{
|
||||
long long ret = 0;
|
||||
QueryPerformanceFrequency(&ret);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
# define NANO_SCALE 1000000000
|
||||
# define UNIT_SCALE NANO_SCALE
|
||||
# define CALIBRATE_TIME (UNIT_SCALE / 4)
|
||||
#define NANO_SCALE 1000000000
|
||||
#define UNIT_SCALE NANO_SCALE
|
||||
#define CALIBRATE_TIME (UNIT_SCALE / 4)
|
||||
#ifdef __FreeBSD__
|
||||
# define CLOCK_ID CLOCK_MONOTONIC_PRECISE
|
||||
#define CLOCK_ID CLOCK_MONOTONIC_PRECISE
|
||||
#else
|
||||
# define CLOCK_ID CLOCK_MONOTONIC
|
||||
#define CLOCK_ID CLOCK_MONOTONIC
|
||||
#endif
|
||||
|
||||
static inline long long get_time(void) {
|
||||
static inline long long
|
||||
get_time(void)
|
||||
{
|
||||
struct timespec time;
|
||||
long long nano_total;
|
||||
clock_gettime(CLOCK_ID, &time);
|
||||
@ -147,7 +161,9 @@ static inline long long get_time(void) {
|
||||
return nano_total;
|
||||
}
|
||||
|
||||
static inline long long get_res(void) {
|
||||
static inline long long
|
||||
get_res(void)
|
||||
{
|
||||
struct timespec time;
|
||||
long long nano_total;
|
||||
clock_getres(CLOCK_ID, &time);
|
||||
@ -165,42 +181,56 @@ struct perf {
|
||||
long long iterations;
|
||||
};
|
||||
|
||||
static inline void perf_init(struct perf *p) {
|
||||
static inline void
|
||||
perf_init(struct perf *p)
|
||||
{
|
||||
p->start = 0;
|
||||
p->stop = 0;
|
||||
p->run_total = 0;
|
||||
}
|
||||
|
||||
static inline void perf_continue(struct perf *p) {
|
||||
static inline void
|
||||
perf_continue(struct perf *p)
|
||||
{
|
||||
p->start = get_time();
|
||||
}
|
||||
|
||||
static inline void perf_pause(struct perf *p) {
|
||||
static inline void
|
||||
perf_pause(struct perf *p)
|
||||
{
|
||||
p->stop = get_time();
|
||||
p->run_total = p->run_total + p->stop - p->start;
|
||||
p->start = p->stop;
|
||||
}
|
||||
|
||||
static inline void perf_start(struct perf *p) {
|
||||
static inline void
|
||||
perf_start(struct perf *p)
|
||||
{
|
||||
perf_init(p);
|
||||
perf_continue(p);
|
||||
}
|
||||
|
||||
static inline void perf_stop(struct perf *p) {
|
||||
static inline void
|
||||
perf_stop(struct perf *p)
|
||||
{
|
||||
perf_pause(p);
|
||||
}
|
||||
|
||||
static inline double get_time_elapsed(struct perf *p) {
|
||||
static inline double
|
||||
get_time_elapsed(struct perf *p)
|
||||
{
|
||||
return 1.0 * p->run_total / UNIT_SCALE;
|
||||
}
|
||||
|
||||
static inline long long get_base_elapsed(struct perf *p) {
|
||||
static inline long long
|
||||
get_base_elapsed(struct perf *p)
|
||||
{
|
||||
return p->run_total;
|
||||
}
|
||||
|
||||
static inline unsigned long long estimate_perf_iterations(struct perf *p,
|
||||
unsigned long long runs,
|
||||
unsigned long long total) {
|
||||
static inline unsigned long long
|
||||
estimate_perf_iterations(struct perf *p, unsigned long long runs, unsigned long long total)
|
||||
{
|
||||
total = total * runs;
|
||||
if (get_base_elapsed(p) > 0)
|
||||
return (total + get_base_elapsed(p) - 1) / get_base_elapsed(p);
|
||||
@ -208,29 +238,30 @@ static inline unsigned long long estimate_perf_iterations(struct perf *p,
|
||||
return (total + get_res() - 1) / get_res();
|
||||
}
|
||||
|
||||
#define CALIBRATE(PERF, FUNC_CALL) { \
|
||||
#define CALIBRATE(PERF, FUNC_CALL) \
|
||||
{ \
|
||||
unsigned long long _i, _iter = 1; \
|
||||
perf_start(PERF); \
|
||||
FUNC_CALL; \
|
||||
perf_pause(PERF); \
|
||||
\
|
||||
while (get_base_elapsed(PERF) < CALIBRATE_TIME) { \
|
||||
_iter = estimate_perf_iterations(PERF, _iter, \
|
||||
2 * CALIBRATE_TIME); \
|
||||
_iter = estimate_perf_iterations(PERF, _iter, 2 * CALIBRATE_TIME); \
|
||||
perf_start(PERF); \
|
||||
for (_i = 0; _i < _iter; _i++) { \
|
||||
FUNC_CALL; \
|
||||
} \
|
||||
perf_stop(PERF); \
|
||||
} \
|
||||
(PERF)->iterations=_iter; \
|
||||
}
|
||||
(PERF)->iterations = _iter; \
|
||||
}
|
||||
|
||||
#define PERFORMANCE_TEST(PERF, RUN_TIME, FUNC_CALL) { \
|
||||
#define PERFORMANCE_TEST(PERF, RUN_TIME, FUNC_CALL) \
|
||||
{ \
|
||||
unsigned long long _i, _iter = (PERF)->iterations; \
|
||||
unsigned long long _run_total = RUN_TIME; \
|
||||
_run_total *= UNIT_SCALE; \
|
||||
_iter = estimate_perf_iterations(PERF, _iter, _run_total);\
|
||||
_iter = estimate_perf_iterations(PERF, _iter, _run_total); \
|
||||
(PERF)->iterations = 0; \
|
||||
perf_start(PERF); \
|
||||
for (_i = 0; _i < _iter; _i++) { \
|
||||
@ -239,8 +270,7 @@ static inline unsigned long long estimate_perf_iterations(struct perf *p,
|
||||
perf_pause(PERF); \
|
||||
(PERF)->iterations += _iter; \
|
||||
\
|
||||
if(get_base_elapsed(PERF) < _run_total && \
|
||||
BENCHMARK_TYPE == BENCHMARK_MIN_TIME) { \
|
||||
if (get_base_elapsed(PERF) < _run_total && BENCHMARK_TYPE == BENCHMARK_MIN_TIME) { \
|
||||
_iter = estimate_perf_iterations(PERF, _iter, \
|
||||
_run_total - get_base_elapsed(PERF) + \
|
||||
(UNIT_SCALE / 16)); \
|
||||
@ -251,10 +281,11 @@ static inline unsigned long long estimate_perf_iterations(struct perf *p,
|
||||
perf_pause(PERF); \
|
||||
(PERF)->iterations += _iter; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
#define BENCHMARK(PERF, RUN_TIME, FUNC_CALL) { \
|
||||
if((RUN_TIME) > 0) { \
|
||||
#define BENCHMARK(PERF, RUN_TIME, FUNC_CALL) \
|
||||
{ \
|
||||
if ((RUN_TIME) > 0) { \
|
||||
CALIBRATE(PERF, FUNC_CALL); \
|
||||
PERFORMANCE_TEST(PERF, RUN_TIME, FUNC_CALL); \
|
||||
\
|
||||
@ -264,36 +295,41 @@ static inline unsigned long long estimate_perf_iterations(struct perf *p,
|
||||
FUNC_CALL; \
|
||||
perf_stop(PERF); \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_CYCLES
|
||||
static inline void perf_print(struct perf p, long long unit_count) {
|
||||
static inline void
|
||||
perf_print(struct perf p, long long unit_count)
|
||||
{
|
||||
long long total_units = p.iterations * unit_count;
|
||||
|
||||
printf("runtime = %10lld ticks", get_base_elapsed(&p));
|
||||
if (total_units != 0) {
|
||||
printf(", bandwidth %lld MB in %.4f GC = %.2f ticks/byte",
|
||||
total_units / (1000000), get_time_elapsed(&p),
|
||||
get_base_elapsed(&p) / (double)total_units);
|
||||
printf(", bandwidth %lld MB in %.4f GC = %.2f ticks/byte", total_units / (1000000),
|
||||
get_time_elapsed(&p), get_base_elapsed(&p) / (double) total_units);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#else
|
||||
static inline void perf_print(struct perf p, double unit_count) {
|
||||
static inline void
|
||||
perf_print(struct perf p, double unit_count)
|
||||
{
|
||||
long long total_units = p.iterations * unit_count;
|
||||
long long usecs = (long long)(get_time_elapsed(&p) * 1000000);
|
||||
long long usecs = (long long) (get_time_elapsed(&p) * 1000000);
|
||||
|
||||
printf("runtime = %10lld usecs", usecs);
|
||||
if (total_units != 0) {
|
||||
printf(", bandwidth %lld MB in %.4f sec = %.2f MB/s",
|
||||
total_units / (1000000), get_time_elapsed(&p),
|
||||
((double)total_units) / (1000000 * get_time_elapsed(&p)));
|
||||
printf(", bandwidth %lld MB in %.4f sec = %.2f MB/s", total_units / (1000000),
|
||||
get_time_elapsed(&p),
|
||||
((double) total_units) / (1000000 * get_time_elapsed(&p)));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline uint64_t get_filesize(FILE * fp) {
|
||||
static inline uint64_t
|
||||
get_filesize(FILE *fp)
|
||||
{
|
||||
uint64_t file_size;
|
||||
fpos_t pos, pos_curr;
|
||||
|
||||
@ -304,7 +340,7 @@ static inline uint64_t get_filesize(FILE * fp) {
|
||||
fseeko(fp, 0, SEEK_END);
|
||||
#endif
|
||||
fgetpos(fp, &pos);
|
||||
file_size = *(uint64_t *) & pos;
|
||||
file_size = *(uint64_t *) &pos;
|
||||
fsetpos(fp, &pos_curr); /* Restore position */
|
||||
|
||||
return file_size;
|
||||
|
@ -37,105 +37,115 @@
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/types.h>
|
||||
#include <sys/endian.h>
|
||||
# define isal_bswap16(x) bswap16(x)
|
||||
# define isal_bswap32(x) bswap32(x)
|
||||
# define isal_bswap64(x) bswap64(x)
|
||||
#elif defined (__APPLE__)
|
||||
#define isal_bswap16(x) bswap16(x)
|
||||
#define isal_bswap32(x) bswap32(x)
|
||||
#define isal_bswap64(x) bswap64(x)
|
||||
#elif defined(__APPLE__)
|
||||
#include <libkern/OSByteOrder.h>
|
||||
# define isal_bswap16(x) OSSwapInt16(x)
|
||||
# define isal_bswap32(x) OSSwapInt32(x)
|
||||
# define isal_bswap64(x) OSSwapInt64(x)
|
||||
#elif defined (__GNUC__) && !defined (__MINGW32__)
|
||||
# include <byteswap.h>
|
||||
# define isal_bswap16(x) bswap_16(x)
|
||||
# define isal_bswap32(x) bswap_32(x)
|
||||
# define isal_bswap64(x) bswap_64(x)
|
||||
#define isal_bswap16(x) OSSwapInt16(x)
|
||||
#define isal_bswap32(x) OSSwapInt32(x)
|
||||
#define isal_bswap64(x) OSSwapInt64(x)
|
||||
#elif defined(__GNUC__) && !defined(__MINGW32__)
|
||||
#include <byteswap.h>
|
||||
#define isal_bswap16(x) bswap_16(x)
|
||||
#define isal_bswap32(x) bswap_32(x)
|
||||
#define isal_bswap64(x) bswap_64(x)
|
||||
#elif defined _WIN64
|
||||
# define isal_bswap16(x) _byteswap_ushort(x)
|
||||
# define isal_bswap32(x) _byteswap_ulong(x)
|
||||
# define isal_bswap64(x) _byteswap_uint64(x)
|
||||
#define isal_bswap16(x) _byteswap_ushort(x)
|
||||
#define isal_bswap32(x) _byteswap_ulong(x)
|
||||
#define isal_bswap64(x) _byteswap_uint64(x)
|
||||
#endif
|
||||
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define to_be16(x) isal_bswap16(x)
|
||||
# define from_be16(x) isal_bswap16(x)
|
||||
# define to_be32(x) isal_bswap32(x)
|
||||
# define from_be32(x) isal_bswap32(x)
|
||||
# define to_be64(x) isal_bswap64(x)
|
||||
# define from_be64(x) isal_bswap64(x)
|
||||
# define to_le16(x) (x)
|
||||
# define from_le16(x) (x)
|
||||
# define to_le32(x) (x)
|
||||
# define from_le32(x) (x)
|
||||
# define to_le64(x) (x)
|
||||
# define from_le64(x) (x)
|
||||
#define to_be16(x) isal_bswap16(x)
|
||||
#define from_be16(x) isal_bswap16(x)
|
||||
#define to_be32(x) isal_bswap32(x)
|
||||
#define from_be32(x) isal_bswap32(x)
|
||||
#define to_be64(x) isal_bswap64(x)
|
||||
#define from_be64(x) isal_bswap64(x)
|
||||
#define to_le16(x) (x)
|
||||
#define from_le16(x) (x)
|
||||
#define to_le32(x) (x)
|
||||
#define from_le32(x) (x)
|
||||
#define to_le64(x) (x)
|
||||
#define from_le64(x) (x)
|
||||
#else
|
||||
# define to_be16(x) (x)
|
||||
# define from_be16(x) (x)
|
||||
# define to_be32(x) (x)
|
||||
# define from_be32(x) (x)
|
||||
# define to_be64(x) (x)
|
||||
# define from_be64(x) (x)
|
||||
# define to_le16(x) isal_bswap16(x)
|
||||
# define from_le16(x) isal_bswap16(x)
|
||||
# define to_le32(x) isal_bswap32(x)
|
||||
# define from_le32(x) isal_bswap32(x)
|
||||
# define to_le64(x) isal_bswap64(x)
|
||||
# define from_le64(x) isal_bswap64(x)
|
||||
#define to_be16(x) (x)
|
||||
#define from_be16(x) (x)
|
||||
#define to_be32(x) (x)
|
||||
#define from_be32(x) (x)
|
||||
#define to_be64(x) (x)
|
||||
#define from_be64(x) (x)
|
||||
#define to_le16(x) isal_bswap16(x)
|
||||
#define from_le16(x) isal_bswap16(x)
|
||||
#define to_le32(x) isal_bswap32(x)
|
||||
#define from_le32(x) isal_bswap32(x)
|
||||
#define to_le64(x) isal_bswap64(x)
|
||||
#define from_le64(x) isal_bswap64(x)
|
||||
#endif
|
||||
|
||||
static inline uint16_t load_native_u16(uint8_t * buf)
|
||||
static inline uint16_t
|
||||
load_native_u16(uint8_t *buf)
|
||||
{
|
||||
uint16_t ret;
|
||||
memcpy(&ret, buf, sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint16_t load_le_u16(uint8_t * buf)
|
||||
static inline uint16_t
|
||||
load_le_u16(uint8_t *buf)
|
||||
{
|
||||
return from_le16(load_native_u16(buf));
|
||||
}
|
||||
|
||||
static inline uint16_t load_be_u16(uint8_t * buf)
|
||||
static inline uint16_t
|
||||
load_be_u16(uint8_t *buf)
|
||||
{
|
||||
return from_be16(load_native_u16(buf));
|
||||
}
|
||||
|
||||
static inline uint32_t load_native_u32(uint8_t * buf)
|
||||
static inline uint32_t
|
||||
load_native_u32(uint8_t *buf)
|
||||
{
|
||||
uint32_t ret;
|
||||
memcpy(&ret, buf, sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint32_t load_le_u32(uint8_t * buf)
|
||||
static inline uint32_t
|
||||
load_le_u32(uint8_t *buf)
|
||||
{
|
||||
return from_le32(load_native_u32(buf));
|
||||
}
|
||||
|
||||
static inline uint32_t load_be_u32(uint8_t * buf)
|
||||
static inline uint32_t
|
||||
load_be_u32(uint8_t *buf)
|
||||
{
|
||||
return from_be32(load_native_u32(buf));
|
||||
}
|
||||
|
||||
static inline uint64_t load_native_u64(uint8_t * buf)
|
||||
static inline uint64_t
|
||||
load_native_u64(uint8_t *buf)
|
||||
{
|
||||
uint64_t ret;
|
||||
memcpy(&ret, buf, sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint64_t load_le_u64(uint8_t * buf)
|
||||
static inline uint64_t
|
||||
load_le_u64(uint8_t *buf)
|
||||
{
|
||||
return from_le64(load_native_u64(buf));
|
||||
}
|
||||
|
||||
static inline uint64_t load_be_u64(uint8_t * buf)
|
||||
static inline uint64_t
|
||||
load_be_u64(uint8_t *buf)
|
||||
{
|
||||
return from_be64(load_native_u64(buf));
|
||||
}
|
||||
|
||||
static inline uintmax_t load_le_umax(uint8_t * buf)
|
||||
static inline uintmax_t
|
||||
load_le_umax(uint8_t *buf)
|
||||
{
|
||||
switch (sizeof(uintmax_t)) {
|
||||
case sizeof(uint32_t):
|
||||
@ -147,22 +157,26 @@ static inline uintmax_t load_le_umax(uint8_t * buf)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void store_native_u16(uint8_t * buf, uint16_t val)
|
||||
static inline void
|
||||
store_native_u16(uint8_t *buf, uint16_t val)
|
||||
{
|
||||
memcpy(buf, &val, sizeof(val));
|
||||
}
|
||||
|
||||
static inline void store_le_u16(uint8_t * buf, uint16_t val)
|
||||
static inline void
|
||||
store_le_u16(uint8_t *buf, uint16_t val)
|
||||
{
|
||||
store_native_u16(buf, to_le16(val));
|
||||
}
|
||||
|
||||
static inline void store_be_u16(uint8_t * buf, uint16_t val)
|
||||
static inline void
|
||||
store_be_u16(uint8_t *buf, uint16_t val)
|
||||
{
|
||||
store_native_u16(buf, to_be16(val));
|
||||
}
|
||||
|
||||
static inline void store_native_u16_to_u64(uint64_t * buf, uint16_t val)
|
||||
static inline void
|
||||
store_native_u16_to_u64(uint64_t *buf, uint16_t val)
|
||||
{
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
store_native_u16((uint8_t *) buf, val);
|
||||
@ -171,32 +185,38 @@ static inline void store_native_u16_to_u64(uint64_t * buf, uint16_t val)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void store_native_u32(uint8_t * buf, uint32_t val)
|
||||
static inline void
|
||||
store_native_u32(uint8_t *buf, uint32_t val)
|
||||
{
|
||||
memcpy(buf, &val, sizeof(val));
|
||||
}
|
||||
|
||||
static inline void store_le_u32(uint8_t * buf, uint32_t val)
|
||||
static inline void
|
||||
store_le_u32(uint8_t *buf, uint32_t val)
|
||||
{
|
||||
store_native_u32(buf, to_le32(val));
|
||||
}
|
||||
|
||||
static inline void store_be_u32(uint8_t * buf, uint32_t val)
|
||||
static inline void
|
||||
store_be_u32(uint8_t *buf, uint32_t val)
|
||||
{
|
||||
store_native_u32(buf, to_be32(val));
|
||||
}
|
||||
|
||||
static inline void store_native_u64(uint8_t * buf, uint64_t val)
|
||||
static inline void
|
||||
store_native_u64(uint8_t *buf, uint64_t val)
|
||||
{
|
||||
memcpy(buf, &val, sizeof(val));
|
||||
}
|
||||
|
||||
static inline void store_le_u64(uint8_t * buf, uint64_t val)
|
||||
static inline void
|
||||
store_le_u64(uint8_t *buf, uint64_t val)
|
||||
{
|
||||
store_native_u64(buf, to_le64(val));
|
||||
}
|
||||
|
||||
static inline void store_be_u64(uint8_t * buf, uint64_t val)
|
||||
static inline void
|
||||
store_be_u64(uint8_t *buf, uint64_t val)
|
||||
{
|
||||
store_native_u64(buf, to_be64(val));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user