1 /****************************************************************************** 2 * Copyright (c) Intel Corporation - All rights reserved. * 3 * This file is part of the LIBXSMM library. * 4 * * 5 * For information on the license, see the LICENSE file. * 6 * Further information: https://github.com/hfp/libxsmm/ * 7 * SPDX-License-Identifier: BSD-3-Clause * 8 ******************************************************************************/ 9 /* Hans Pabst (Intel Corp.) 10 ******************************************************************************/ 11 #ifndef LIBXSMM_HASH_H 12 #define LIBXSMM_HASH_H 13 14 #include <libxsmm_macros.h> 15 16 /* Map number of Bits to corresponding routine. */ 17 #define LIBXSMM_CRC32U(N) LIBXSMM_CONCATENATE(libxsmm_crc32_u, N) 18 /* Map number of Bytes to number of bits. */ 19 #define LIBXSMM_CRC32(N) LIBXSMM_CONCATENATE(libxsmm_crc32_b, N) 20 #define libxsmm_crc32_b4 libxsmm_crc32_u32 21 #define libxsmm_crc32_b8 libxsmm_crc32_u64 22 #define libxsmm_crc32_b16 libxsmm_crc32_u128 23 #define libxsmm_crc32_b32 libxsmm_crc32_u256 24 #define libxsmm_crc32_b48 libxsmm_crc32_u384 25 #define libxsmm_crc32_b64 libxsmm_crc32_u512 26 27 28 /** Function type representing the CRC32 functionality. */ 29 LIBXSMM_EXTERN_C typedef LIBXSMM_RETARGETABLE unsigned int (*libxsmm_hash_function)( 30 unsigned int /*seed*/, const void* /*data*/, ... /*size*/); 31 32 /** Initialize hash function module; not thread-safe. */ 33 LIBXSMM_API_INTERN void libxsmm_hash_init(int target_arch); 34 LIBXSMM_API_INTERN void libxsmm_hash_finalize(void); 35 36 LIBXSMM_API_INTERN unsigned int libxsmm_crc32_u32(unsigned int seed, const void* value, ...); 37 LIBXSMM_API_INTERN unsigned int libxsmm_crc32_u64(unsigned int seed, const void* value, ...); 38 LIBXSMM_API_INTERN unsigned int libxsmm_crc32_u128(unsigned int seed, const void* value, ...); 39 LIBXSMM_API_INTERN unsigned int libxsmm_crc32_u256(unsigned int seed, const void* value, ...); 40 LIBXSMM_API_INTERN unsigned int libxsmm_crc32_u384(unsigned int seed, const void* value, ...); 41 LIBXSMM_API_INTERN unsigned int libxsmm_crc32_u512(unsigned int seed, const void* value, ...); 42 43 /** Calculate the CRC32 for a given quantity (size) of raw data according to the seed. */ 44 LIBXSMM_API_INTERN unsigned int libxsmm_crc32(unsigned int seed, const void* data, size_t size); 45 46 #endif /*LIBXSMM_HASH_H*/ 47 48